• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Define specific PDF export preset for specific InDesign document

Explorer ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Hello,

I have an InDesign document that I use for my invoices, each time I make a new one I export the last page of the document using a specific preset, which I only use for this invoice document. Given that InDesign by default keeps the latest export preset, there's a great chance that when I export a document from this or any other document the preset is not the right one, which is not a huge deal but in the long run it's a bit annoying, since each document export might need some specific settings, but this particular one always needs the same.

My question is: is there a way to tell InDesign that whenever I'm exporting a page from the invoice document, the preset must be by default set to the one I indicate?

 

Thank you,

L

TOPICS
Feature request , How to , Import and export

Views

265

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

File/Adobe PDF Pre Sets/Define. Create and name your styles, and when exporting directly choose that style. Easy.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Thank you Frans. Perhaps my wording wasn't very clear: I have already saved my preset for this kind of export. What I hope I could do was to assign that preset to this specific document, so that each time I'm exporting a PDF from this particular document (cmd+E), it has by default the characteristics set in the preset without having to select it in the exporting dialog.

But as you mentioned this command, I have realized that I can go to File>Adobe PDF Pre Sets and select the one I want from the menu, which is slightly faster than selecting it from the dialog box. If only there was a way to assign to that particular preset a keyboard shortcut...

Thank you,

L

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

@Oreri

 

Why are you using InDesign for invoices?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

quote

@Oreri

 

Why are you using InDesign for invoices?

 


By @Robert at ID-Tasker

Why not? I do it too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

A bit overkill - and no math operations. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Well, my billing doesn't require complex math and I can produce a much nicer form in InDesign than I can in other programs.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

@Robert at ID-TaskerYes, it's a bit of an overkill, but like @Peter Spier I like to have them neat and stylish 🙂 Also, in Italy we have a system that sends the invoices straight to the tax agency via some other intermediate softwares that do the real math (and also can export automatic courtesy invoices, all pretty ugly though), so the invoices I do on InDesign are more of a courtesy for the customer with no real legal value. I would like to find a way to make some InDesign templates that I can fill in via some other program (like a Google sheet, Excel, or Word) but if that's possible it's well beyond my capabilities. Any suggestion on how to do that is welcome, too 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

What I'd do, Oreri, is I'd write a little script that I'd call "Export Invoice" and assign a keyboard shortcut to the script. I didn't really test the following code all that much, and I've yet to figure out how to just harvest the name of the file without the .indd extension, but I think it does what you want - it silently saves a PDF in the same directory as your INDD invoice, with the PDF export preset you specify in the code.  

main()

function main(){
    var doc = app.activeDocument,
	myPreset = app.pdfExportPresets.itemByName("Put the name of your invoice PDF preset here");
    if (!doc.saved) {
        alert("Please save before exporting PDF; this tool needs a file path that it gets from where the invoice is saved.")
        return
    }
    var whereToSavePDF = doc.filePath + "/" +  doc.name + ".pdf";
	doc.exportFile(ExportFormat.pdfType, File(whereToSavePDF), false, myPreset);	
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Mmmhh, I never wrote a script, I'll try that with my very limited (to say the least) coding abilities. I'll let you know if I suceed. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Well, I think that all you'd have to do, with either my script, or the one-liner that @Tá´€W posted, would be to put the name of your PDF export preset in the right spot in the script, then save the file in the right location.

 

The "right location" is easy to find by:

  1. going to your Scripts panel in InDesign
  2. right-clicking on a script there and choosing "Reveal in Finder" or "Reveal in Explorer" depending on whether you're using Mac or Windows

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

I've opened the script editor and tried both, adding the script name where it said so, and the file path, but when I try to run it or save it in the location I get a dialog saying "Expected expression, property or key form, etc. but found unknown token." I think I might have to write somethig more specific into it, but I have no idea what. This is what I have at the moment, with the preset name in the 5th line and the path in the 11th:

 

main()

function main(){
    var doc = app.activeDocument,
	myPreset = app.pdfExportPresets.itemByName("Fatture OIE");
    if (!doc.saved) {
        alert("Please save before exporting PDF; this tool needs a file path that it gets from where the invoice is saved.")
        return
    }
    var whereToSavePDF = /Users/oreri/MEGA/WORK/OIE/OIE ADMINISTRATION/ALESSANDRO FIORINA/FATTURE/2025 FATTURE + "/" +  Fattura N + ".pdf";
	doc.exportFile(ExportFormat.pdfType, File(whereToSavePDF), false, myPreset);	
}

What am I missing? Thank you very much for helping me!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

var whereToSavePDF = "/Users/oreri/MEGA/WORK/OIE/OIE ADMINISTRATION/ALESSANDRO FIORINA/FATTURE/2025 FATTURE" + "/" +  "Fattura N" + ".pdf";

 

You missed some double quotes. 

 

Which can be just: 

 

var whereToSavePDF = "/Users/oreri/MEGA/WORK/OIE/OIE ADMINISTRATION/ALESSANDRO FIORINA/FATTURE/2025 FATTURE/Fattura N.pdf";

 

But if you're looking for some kind of auto-numbering - it needs to be done differently. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2025 Feb 02, 2025

Copy link to clipboard

Copied

Well, my idea wasn't to send you off on a script-development adventure. Either my script, or the one-liner that @Tá´€W posted, should have been fairly easy to install and just run. His script should skip the preset-selection dialog and hop straight to the save-a-file dialog. My script should have silently just saved a PDF of the entire document. Reading your initial post, I don't think either one does what you need. 

 

However, we must have both dropped the ball in explaining exactly what to do with these scripts. We both wrote in ExtendScript, which is the name of Adobe's ancient version of Javascript that is used to automate stuff in InDesign. The error message you posted, "Expected expression, property or key form, etc. but found unknown token" is an AppleScript error message. 

 

So, what you ought to do with either Ariel's script, or mine, is more like this:

1) Copy the script to your clipboard

2) Paste it into TextEdit

3) Click on Format and choose Make Plain Text (I'm doing this from memory and haven't seen the inside of MacOS in more than five years, so my instructions might be incorrect here)

4) Save the file with a ".jsx" extension in the Scripts folder that I guided you to in the previous post

 

That should keep InDesign from assuming that the script is AppleScript.

 

All of the other things that Robert pointed out are still true - if you want to force all of your invoices to be saved in the 2025 FATTURE folder, then he's already pointed out the edits you'd need to make. Likewise, if you'd like one of these scripts to automagically export only the last page, I'm sure that I could edit my script to specify that as well. 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2025 Feb 02, 2025

Copy link to clipboard

Copied

@Joel Cherney

 

app.pdfExportPreferences.pageRange = doc.pages[-1].name;

 

just before doc.exportFile() should do the trick. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2025 Feb 02, 2025

Copy link to clipboard

Copied

Yep!

 

Although I think that the "last page" value might stick. It might make more sense to store whatever value the pageRange currently has in a variable, then set it to -1 temporarily, export the PDF, then set the pageRange value back to whatever we stored in the variable? I don't know, but if @Oreri comes back to the thread, I'll totally test that out (at some point when I'm not reading the forums on my phone). 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2025 Feb 02, 2025

Copy link to clipboard

Copied

@Joel Cherney

 

Anyone should ALWAYS check which pages will be exported - plus few other things - so I don't think it matters what value will be "left" by the script?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2025 Feb 05, 2025

Copy link to clipboard

Copied

LATEST

@Joel Cherney

 

var myFileName = myDocument.name.replace(/\.indd$/, '');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

Ah, I see, misunderstood;-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

quote

If only there was a way to assign to that particular preset a keyboard shortcut...


By @Oreri

 

You should be able to do this with a 3rd-party macro utility. I'd recommend Keyboard Maestro (not free), but some free ones should be around too. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 01, 2025 Feb 01, 2025

Copy link to clipboard

Copied

This one-line script (save it from a text editor with a .jsx extension) will export your document using whatever pdf preset you choose (just change the string between the quotes to the name of your preset):

document.exportFile(ExportFormat.PDF_TYPE, File.saveDialog(), true, app.pdfExportPresets.item("YourPresetName"));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines