Copy link to clipboard
Copied
I am new to ExtendScript. Im still trying to wrap my mind around the Indesign Object Model among other things. Im just fiddling around here trying to do simple tasks. Im having trouble exporting a pdf. Can anyone help me troubleshoot this script?
Main();
// If you want the script to be un-doable, comment out the line above, and remove the comment from the line below
// app.doScript(Main, undefined, undefined, UndoModes.ENTIRE_SCRIPT,"Run Script");
function Main() {
// Check to see whether any InDesign documents are open.
// If no documents are open, display an error message.
if (app.documents.length > 0) {
var myDoc = app.activeDocument;
myDoc.asynchronousExportFile(PDF,/Users/greer/Desktop/test.pdf,false,SmallestFileSize);
// Do something here
alert("Finished!");
}
else {
// No documents are open, so display an error message.
alert("No InDesign documents are open. Please open a document and try again.");
}
}
Copy link to clipboard
Copied
HI,
Line11 is wrong.. have to use quotes for path..please look the below thread..so you got some ideas how to perform
Re: cancelTask() & cancelAllTask()
Copy link to clipboard
Copied
Here's a tid bit i came across on here. It will allow you to define your Presets and location.
var myPDFExportPreset = app.pdfExportPresets.item("[Smallest File Size]"); // Change myPDFpreset to the name of the preset you want to use
var myFileLocation = Folder.selectDialog("/Volumes/"); // Change this to your FOlder location
myFolder = new Folder ([myFileLocation]);
myFolderContents = myFolder.getFiles("*.indd"); // array
myFileAmount = (myFolderContents.length - 1);
// ===== Open, Export as PDF, and Close files ===== \\
for (i = myFileAmount; i >= 0; i--)
{
app.open(File (myFolderContents));
app.activeDocument.exportFile(
ExportFormat.pdfType,
new File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"),
false,
myPDFExportPreset
);
app.activeDocument.close(SaveOptions.no);
}
Copy link to clipboard
Copied
The problem is that you use strings for the document and the preset, where you should use file and preset objects. The correct form of your export statement is as follows:
myDoc.asynchronousExportFile (ExportFormat.PDF_TYPE, File ('/Users/greer/Desktop/test.pdf'), false, app.pdfExportPresets.item('[Smallest File Size]'))
Peter
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more