Copy link to clipboard
Copied
Hi all,
our customer sends us indd files which represent magazine pages and are in spread format. But for print we have to send each indd file separated into two single pages. For example: we receive 002_003_ABC.indd and the exported pdfs should be 002_000_ABC.pdf (left page) and 000_003_ABC.pdf (right page). I'm trying to create a script to automate the process. From ExtendScript API 2020 Object Model I'm using PDFExportPreset method with .exportAsSinglePages property but I'm getting an error message " Object does not support the property or method PDFExportPreset". Should I use this method or is there better solution for this problem ? I'm very grateful if somebody can help me on that.
Here is the script so far:
function exportPdf(currentDocPath) {
app.open(currentDocPath)
currentDoc = app.activeDocument;
var folderContainer = currentDoc.filePath.fullName;
var newFolder = new Folder(folderContainer + '/PDF');
if (!newFolder.exists) {
newFolder.create();
}
preset1 = {};
// Check before export to be sure links are updated
if (currentDoc.modified == false) {
var clearName = '';
if (currentDoc.name.match(/(.*?)\..*/i)) {
var fetchNameWithoutExt = currentDoc.name.match(/(.*?)\..*/i);
clearName = fetchNameWithoutExt[1];
} else {
clearName = currentDoc.name;
}
var newNames = clearName.match(/^(\w*)\_(\d{3})\_(\d{3})\_(.*?)$/i);
var newPDFFiles = [];
newPDFFiles.push(newNames[1] + "_" + newNames[2] + "_000_" + newNames[4]);
newPDFFiles.push(newNames[1] + "_000_" + newNames[3] + "_" + newNames[4]);
for (var index = 0; index < newPDFFiles.length; ++index) {
var pdfFileName = folderContainer + '/PDF/' + newPDFFiles[index] + ".pdf";
}
preset1.item = app.pdfExportPresets.item("High_Quality_Print");
preset1.exportAsSinglePages = app.PDFExportPreset.exportAsSinglePages;
if (!(preset1.item.isValid)) {
alert("The preset does not exist. Please check spelling carefully.");
exit();
}
for (x = 0; x < currentDoc.pages.length; x++) {
// Get current page name
var myPageName = currentDoc.pages[x].name;
// Set the PDF export page range to the page name
app.PDFExportPreferences.pageRange = myPageName;
currentDoc.exportFile(ExportFormat.PDF_TYPE, new File(pdfFileName[x]), false, preset1);
}
currentDoc.close(SaveOptions.NO);
} else {
alert("save first");
}
}
function getDocuments() {
var folderPath = Folder.selectDialog("Select folder for process");
var filesListing = folderPath.getFiles();
for (var m = 0; m < filesListing.length; m++) {
var getCurrentFileForChecking = File(filesListing[m].fsName);
if (getCurrentFileForChecking instanceof Folder === true) {
continue;
}
var fetchNameWithoutExt = getCurrentFileForChecking.name.match(/(.*?)\.(.*)/i);
if (fetchNameWithoutExt[2] != "null") {
fileExt = fetchNameWithoutExt[2];
} else {
fileExt = '';
}
if (fileExt == "indd") {
exportPdf(getCurrentFileForChecking);
}
}
}
var currentPdfSettings = app.pdfExportPreferences;
getDocuments();
Also the .exportAsSinglePages property set to true exports each page or spread as a separate PDF file, it's the exportReaderSpreads property that determines whether a facing page document is exported as spreads or single pages.
Copy link to clipboard
Copied
Hello,
I didn't try or test your code but you could try changing......
preset1.item = app.pdfExportPresets.item("High_Quality_Print");
To: preset1.item = app.pdfExportPresets.itemByName("High_Quality_Print");
Regards,
Mike
Copy link to clipboard
Copied
Hi Mike,
thank you for this suggestion. I replaced item with itemByName, but I still get the same error messageRuntime Error: Error Code# 55: Object does not support the property or method 'PDFExportPresets' @ file '~/Desktop/dev/exportPDFUlla%20copy.jsx' [line:34, col:1]
Copy link to clipboard
Copied
our customer sends us indd files which represent magazine pages and are in spread format. But for print we have to send each indd file separated into two single pages.
Just to clarify, the actual page dimensions of the InDesign file are twice as wide as they should be—i.e, the page should be 8.5"x11" but the client’s page dimension is 17"x11"? If that’s the case, exporting as single pages vs. spreads wouldn’t split the 17"x11" pages.
Copy link to clipboard
Copied
Also the .exportAsSinglePages property set to true exports each page or spread as a separate PDF file, it's the exportReaderSpreads property that determines whether a facing page document is exported as spreads or single pages.
Copy link to clipboard
Copied
Hi Rob,
thank you for this clarification. It really helped , because I was misguided by the description of exportReaderSpreads property in API's documentation.
Greetings,
Tsvetelina
Copy link to clipboard
Copied
It sounds like the documents you are receiving are single pages, but the Document Setup is Facing Pages?
If that’s the case Facing Pages simply changes the layout of the document pages—the pages are not actually spreads, but two pages facing each other so they view as a spread.
Acrobat has the same options under View>Page Display, so if for some reason you want the intial view of the exported facing page PDF to be single rather than facing pages, I think you would want to look at the .pdfPageLayout property—PageLayoutOptions.SINGLE_PAGE_CONTINUOUS, or PageLayoutOptions.SINGLE_PAGE
Copy link to clipboard
Copied
Hi Tsvetelina,
app.PDFExportPreset.exportAsSinglePages
cannot run without error. The property PDFExportPreset does not exist with application.
The error message for this should be:
"Object does not support the property or method 'PDFExportPreset'"
There is app.pdfExportPresets but I really don't know what you like to do with that line in your code.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Yes, I've solved the problem by different approach. The error you're mentioning was fixed by completely changing the way the props are assigned:
preset1 = app.pdfExportPresets.item("print_style");
...
preset1.exportReaderSpreads = false;
preset1.exportAsSinglePages = false;
...
currentDoc.exportFile(ExportFormat.PDF_TYPE, new File(newFileName), false, preset1);
and it works flawlessly.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more