Skip to main content
Community Expert
April 24, 2021
Question

Save & Export at same time

  • April 24, 2021
  • 4 replies
  • 425 views

Looking for a way to have the document save and export to PDF at the same time. 

 

Basically, the modification date of both InDesign and PDF have to be identical for this set of projects. 

 

Looking to have a 1 step solution - maybe it's best to ask in the InDesign User Voice - a new command like Save & Export would be nice.

 

But if anyone knows a quick shortcut to have these 2 commands combined it would be welcomed. 

This topic has been closed for replies.

4 replies

rob day
Community Expert
Community Expert
April 24, 2021

Hi Eugene, Could the save happen after the export is complete? That should give you matching modification dates. This worked with a file containing a 300mb image (Edit, basically the same as Mike’s script but with a PDF Preset list dialog):

 

 

 

var eFolder = Folder.selectDialog("Choose a folder for the PDF"); 
var pdfDropdown;
makeDialog();

function makeDialog(){
    var theDialog = app.dialogs.add({name:"Choose a Preset", canCancel:true});
    with(theDialog.dialogColumns.add()){
        pdfDropdown = dropdowns.add({stringList:getPresets(app.pdfExportPresets), selectedIndex:3, minWidth:80});
    }
    if(theDialog.show() == true){
        pdfDropdown = app.pdfExportPresets.item(pdfDropdown.selectedIndex);
        main();
        theDialog.destroy();
	}
}


/**
* Export to the chosen PDF preset and save 
*  void 
* 
*/
function main(){
    var doc = app.activeDocument;
    var fn = doc.name.replace(/\.[^\.]+$/, '')
    doc.exportFile(ExportFormat.pdfType, File(eFolder + "/" + fn + ".pdf"));
    doc.save();
}


/**
* Returns a list of item names from the provided collection 
*  the collection 
*  array of names 
* 
*/
function getPresets(p){
    var a = new Array;
    for(var i = 0; i < p.length; i++){
        a.push(p.item(i).name);
    }
    return a
}

 

 

Community Expert
April 25, 2021

Ok, great points everyone - and thank you for the scripts - I will definitely try them.

 

The queries have got me thinking - so thank you for taking the time and considerations.

 

Ideally the Modification dates for the InDesign file and the PDF:

InDesign file

07.10 am

 

PDF

07.11 am

 

But not the other way around - that is the PDF can be a little bit later than the InDesign file.

But the InDesign file cannot be 07.11 and the PDF 07.10 - as it doesn't offer proof of any changes after the PDF creation.

 

For what it's worth - the largest gap is ideally 2 minutes between InDesign and PDF (+2 minutes).

 

It's a very good point about large files and the time it would take the PDF to export. That also needs to be considered. But it takes as long as it takes and if it's 3 minutes I'll need to note that it is unavoidable. 

 

 

Dave Creamer of IDEAS
Community Expert
Community Expert
April 24, 2021

Just a note... Depending on the complexity of the InDesign file, it may not be possible to have identical times. It may take longer to process the PDF, giving it a different created/modified date (by minutes).

David Creamer: Community Expert (ACI and ACE 1995-2023)
Jumpenjax
Community Expert
Community Expert
April 24, 2021

If you use File>Package it gives you the option to set up how you want your pdf to be saved along with your InDesign file.

Lee- Graphic Designer, Print Specialist, Photographer
Community Expert
April 25, 2021

Thank you - but I need to keep a certain file structure. Packaging might work, worth looking at again.

 

Thanks

Legend
April 24, 2021

Hello Eugene,

 

Below is a script with the 2 commands combined together.......it may need to be modified for any additional requirements you may have.

 

FYI, if you uncomment the last line it will close the document after it's done exporting the pdf.

var doc = app.documents[0];

var myFolder = doc.filePath;

var fileName = app.activeDocument.name.replace(/.indd$/i, "");

doc.save();

export_preset = app.pdfExportPresets.itemByName("[High Quality Print]");

app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES

doc.exportFile(ExportFormat.PDF_TYPE, File(myFolder +"/"+ fileName + ".pdf"), false, export_preset);

doc.save();

// app.activeDocument.close(SaveOptions.NO);

 

Regards,

Mike