Reply To: Export pdf in Original Folder

#89631

If I understand the question correct, the name of the preset is “LR-Bleed-Crops-Slug” and the pdf should get “_LR” as part of the name?

I would:
1. Check, if the preset exists
2. Check, if the current document was saved before (otherwise there is no file path) and even modified
3. Make a reference to the new file name and file path
4. Export with the preset
5. Close without saving

// your preset name
var pdfPreset = app.pdfExportPresets.itemByName("LR-Bleed-Crops-Slug");
if (!pdfPreset.isValid) {  
  alert("Your preset doesn’t exist!");
  exit();
}

while (app.documents.length) {
  var curDoc = app.activeDocument;

  // check if the doc was saved or modified
  if (!curDoc.saved || curDoc.modified) {
    alert ("Save your doc before!");
    exit();
  }

  // built the PDF name
  var pdfName = curDoc.name.replace(/\.indd$/i,"_LR.pdf");

  // path to the folder of the indd-file
  var fPath = curDoc.filePath;

  // reference to the new file
  var pdfFile = new File(fPath + "/" + pdfName);  

  // export the current file …
  curDoc.exportFile(ExportFormat.pdfType, pdfFile, false, pdfPreset);

  // … and close the document
  curDoc.close(SaveOptions.NO);
}

Kai

This article was last modified on November 8, 2016

Comments (0)

Loading comments...