Copy link to clipboard
Copied
I wrote a script to export a PDF file, which works perfectly in InDesign but fails in InDesign Server with just "Error: Failed to Export the PDF file."
I've tried searching for other reports of this problem but haven't found anything that helps so far.
Am I doing something wrong?
var isServer = app.name === "Adobe InDesign Server";
var inddFile = File(inddFileFullPath);
var pdfFile = File(inddFile.fullName.replace(".indd", ".pdf"));
if (isServer) {
var pdfExportPreset = app.pdfExportPresets.itemByName("[Smallest File Size]");
app.open(tempFile, OpenOptions.openOriginal);
app.documents[0].exportFile(ExportFormat.PDF_TYPE, pdfFile);
}
else {
app.open(inddFile, false, OpenOptions.openOriginal);
app.documents[0].exportFile(ExportFormat.pdfType, pdfFile, false);
}
app.documents[0].close(SaveOptions.NO);
Copy link to clipboard
Copied
Hi,
Try this ...
var isServer = app.name === "Adobe InDesign Server";
var inddFile = File(inddFileFullPath);
var pdfFile = File(inddFile.fullName.replace(".indd", ".pdf"));
if (isServer) {
var pdfExportPreset = app.pdfExportPresets.itemByName("[Smallest File Size]");
//app.open(tempFile, OpenOptions.openOriginal);
app.open(inddFile);
app.documents[0].exportFile(ExportFormat.PDF_TYPE, pdfFile);
}
else {
app.open(inddFile, false, OpenOptions.openOriginal);
app.documents[0].exportFile(ExportFormat.pdfType, pdfFile, false);
}
app.documents[0].close(SaveOptions.NO);You don't use pdfExportPreset, it's normal ?
Copy link to clipboard
Copied
Thanks. This doesn't work for me either. It still throws the "Failed to Export the PDF file" error.
So far it hasn't seemed to matter whether I use pdfExportPreset or not. I posted this question partly to find out what's normal, in case I'm doing something wrong.
Copy link to clipboard
Copied
the three parameters Are
1.ExportFormat.PDF_TYPE
2.FILE
3.PRESET Name
try this,
var myDoc=app.documents[0]
var docPath=myDoc.filePath
var printOption="yourPresetName"
var docName=myDoc.name
myDoc.exportFile(ExportFormat.PDF_TYPE, File(docPath.parent + "/" + "PDF/" + docName.split(".")[0] + "_PrintPDF.pdf"), printOption.toString()); // For Server
Copy link to clipboard
Copied
Don'tknow enough about indeign server but why is the indesign exporting to:
ExportFormat.pdfType
and the server:
ExportFormat.PDF_TYPE
Copy link to clipboard
Copied
The InDesign API documentation lists the enum as ExportFormat.PDF_TYPE, but in JavaScript/ExtendScript it doesn't seem to matter if I use that or ExportFormat.pdfType. I probably should have standardized them before posting this.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more