Copy link to clipboard
Copied
Dear forum,
I wrote a script that batch processes folders which contain CSV-files and images. Reading the information from CSV-files, it creates documents from templates, places images, enters text data and finally exports them to PDF-files using exportFile method.
On rare occasions, this results in zero sized PDFs which obviously doesn’t open in Acrobat; sometimes in almost zero sized PDFs which opens in Acrobat but most objects are missing.

I handled this situation by script: right after export it checks for the size of the pdf-file and if it’s below a certain limit, it writes an error message into the log file on the desktop so the user could know about the problem and reprocess the problematic files.

However, I’d like to polish it up. Any ideas about why it happens and how to solve it? The script was used in InDesign CC 2015.4 on Windows 10 with enough free disk space and other resources.
Regards,
Kasyan
Copy link to clipboard
Copied
Hi Kasyan,
I can offer not much.
Just some questions:
1. Can you make out some mutual characteristics for documents that fail to export?
Placed Adobe Illustrator files come to my mind. ( We had some problems with placed AI files and PDF export by scripting in the past. )
2. What does the user do while a document is exported?
Clicking around in InDesign because the export does not happen in the background like usual?
Switching to a different app doing some work there?
3. Are there any web browser apps open while InDesign is exporting the PDFs?
I read here in the forums, that some browser plug-ins or extras could influence InDesign…
Best,
Uwe
Copy link to clipboard
Copied
Thank you all guys for the quick reply!
@Uwe
@Trevor
No, the document is closed only after the export is complete and I don’t quit InDesign by script. Here’s the relative function:
function ExportPDF(doc, obj) {
try {
var pdfFile = new File(obj.pdfExportFolderPath + obj.schoolNameShort + ((obj.product == "Class order summary") ? "" : " - " + obj.classNameShort ) + " - " + obj.product + " - Print Files.pdf");
app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
progressTxt1.text = "Exporting PDF-file: " + pdfFile.displayName;
doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, pdfPreset);
if (pdfFile.length < pdfSizeLimit) {
LogError("Failed to export pdf-file: '" + pdfFile.fsName + "'; file size is less then " + pdfSizeLimit / 1000 + " Kb");
}
if (set.cbSaveInDesignFilesValue) {
doc.close(SaveOptions.YES);
}
else {
doc.close(SaveOptions.NO);
}
}
catch(err) {
try {
LogError("Error: " + err.message + ", file: " + doc.name + ", function 'ExportPDF', line: " + err.line);
$.writeln(err.message + ", line: " + err.line);
doc.close(SaveOptions.NO);
}
catch(err) {
$.writeln(err.message + ", line: " + err.line);
}
}
}
@Loic
The preset used is the built-in "[Press Quality]". As far as I know, they don’t print this in a printing shop.
@La0s
In this script I don’t use Background Tasks – or asynchronous export in scripting terms: asynchronousExportFile() – since according to my testing, in total, it takes the same time as exportFile(). I was also unable to close a document after a background task was complete so with a great number of documents open simply InDesign crashed.
Regards,
Kasyan
Copy link to clipboard
Copied
Hi Kas,
Maybe you are closing the document or InDesign before the PDF export is done?
Regards
Trevor
Copy link to clipboard
Copied
I got a similar issue with a client. I used a PDF/X-1a preset to ensure transparency was flattened and it worked fine for 99,999% of the files. But then recently one outputted 0K0 pdfs. I suspect that the combination of spots colors in the document corrupted the PDF export. As the RIP was APPE compliant, I set the PDFX to PDF/X-4 and then the problem went away.
I didn't have time to go deeper on that issue but at least the files are now correctly outputted. But if the RIP was a ghostscript one, I think it would have needed deeper analysis.
FWIW
Loic
Copy link to clipboard
Copied
I think i had a similar problem that was related to InDesign Background Tasks.
As Trevor mentioned, the documents could possibly be closed before the background tasks are finnished. I solved it then by using Marijan Tompas Background Export Toggle Script.
I cant find it now at his site, but here is a download link:
http://www.existonline.com.au/disable-adobe-indesign-background-tasks/
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more