How can I auto export a PDF File using the "Smallest File Size" preset and set the Exported File Name based on information from an Imported PDF?

Greetings all,
I am trying to create a script to automate a PDF export process for my company for inDesign. I’m fairly new to inDesign itself and have no previous experience with javascript, although I did take C++ in high school and have found it helpful in putting this code together.
We have an inDesign template file and then use the Multi-page PDF importer script to import PDF files. We then have to export two version of each file that we import, then delete the imported file and all of the pages to reset the template. This has to be done for nearly 1000 pdf files each month and is quite tedious. I’m working on automating the process as much as possible. I’ve managed to piece together code that will cleanup the file much quicker and am now trying to automate the PDF exports themselves.
The files are sent to us as “TRUGLY#####_Client” and need to be exported as “POP#####_Client_Date-Range_North/South.pdf”
For example, TRUGLY12345_Client needs to be exported as POP12345_Client_Mar01-Mar31_North and POP12345_Client_Mar01-Mar31_South.
There are two templates built into the template file for the north and south file that are toggled easily via layer visibility switches. I need to get a code that can ideally read the #s from the imported Trugly file as well as the Client and input those into variables to use when exporting. The date range is found in the same place in the top right of each pdf file. I am not sure if this can be read somehow or if it will have to be input manually. I can put North or South into the file name based on which template layer is visible.
I am not sure how to go about doing this. I did find the following code for exporting to PDF with preset but it requires me to select a preset and then type the full file name. How can I set it to automatically use the “Smallest File Size” preset without prompting me to choose and then automatically input some or preferably all of the file name automatically? (If the entire filename is possible then I don’t even want a prompt to appear so it will be fully automated!)
PDF Export Code (Originally from here: Simple PDF Export with Preset selection | IndiSnip [InDesign® Snippets]):
var myPresets = app.pdfExportPresets.everyItem().name;
myPresets.unshift("- Select Preset -");
var myWin = new Window('dialog', 'PDF Export Presets');
myWin.orientation = 'row';
with(myWin){
    myWin.sText = add('statictext', undefined, 'Select PDF Export preset:');
    myWin.myPDFExport = add('dropdownlist',undefined,undefined,{items:myPresets});
    myWin.myPDFExport.selection = 0;
    myWin.btnOK = add('button', undefined, 'OK');
myWin.center();
var myWindow = myWin.show();
if(myWindow == true && myWin.myPDFExport.selection.index != 0){
    var myPreset = app.pdfExportPresets.item(String(myWin.myPDFExport.selection));
    myFile = File(File.saveDialog("Save file with preset: " + myPreset.name,"PDF files: *.pdf"));
    if(myFile != null){
        app.activeDocument.exportFile(ExportFormat.PDF_TYPE, myFile, false, myPreset);
    }else{
        alert("No File selected");
}else{
    alert("No PDF Preset selected");
So far my code does the following:
1) Runs the Multi-Page PDF Import Script
2) Runs PDF Export Script Above
3) Toggles the Template
4) Runs #2 Again
5) Deletes the imported PDF and all pages and toggles template again.
It’s close and much better than the original process which was almost 100% manual but I’d like to remove the Preset prompt from the PDF script and have it automatically select the “Smallest File Size” preset. and then if there’s a way to have it auto-fill in the file name so no user input is required at all other than selecting each file to import. (If there’s a way to setup a batch action for the multi-import script that would be even better!)
Thanks in advance and if there’s anything else I can provide that would help please let me know! Even a nudge in the right direction will be a big help!

If you hold down the option key, it will typically show the location. Or you can often hit option-return on the file and it will reveal the file in the Finder, instead of opening it.
Final option is to open it, and just option-click the filename in the toolbar of Preview and it should show you the location.
It's probably an attachment to an email you've received. If you have Mail set to cache emails and their attachments it'll be stashed in a subdirectory of ~/Library/Mail. Which is fine.

Similar Messages

Maybe you are looking for

  • Does "Adobe Send" memorize the e-mail addresses I send to repeatedly, as "Send Now" did?

    In Adobe "Send Now", it was much easier to send a personalized link to multiple e-mail addresses.  Plus, once I used and e-mail address, it memorized it.  I am a university professor at a school where we use the Exchange type of account.  How can I a

  • "#" character showing up when saving as PDF in FM 8?

    Hello, We've used FM for years, for operator and service manuals - we just upgraded to FM8, and have a new problem. When we save as a PDF, we get the # character at random points in the PDF - there is no rhyme or reason for their appearance or their

  • Material workbench displays a zero quantity

    Dear All, When I did a Miscellaneous Issue of an item, it was still showing onhand quantity Item Available is 1 No Did Miscellaneous Issue: 1 No Not available in the Transactions Temp (pending Transactions) but now in the Material Workbench the item

  • Client Configuration

    i have two controllers 4402and 15 WAP 1250s with both radio AGN i need to configure the client to support maximum Speed please advice what is the best Practice configuration for Both WLC and client (the maximum speed for 2.4Ghz GN-radio) the Laptop a

  • How to call other Entity service

    Hi, How to call other Entity service to our entity service? Regards Ashif