5 Replies Latest reply on Oct 31, 2016 4:39 AM by Kasyan Servetsky

    Random problems with PDF-export: zero sized PDFs

    Kasyan Servetsky Level 5

      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.



        • 1. Re: Random problems with PDF-export: zero sized PDFs
          Laubender Adobe Community Professional & MVP

          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…




          • 2. Re: Random problems with PDF-export: zero sized PDFs
            Trevorׅ Adobe Community Professional

            Hi Kas,


            Maybe you are closing the document or InDesign before the PDF export is done?





            • 3. Re: Random problems with PDF-export: zero sized PDFs
              Loic.Aigon Adobe Community Professional

              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.





              • 4. Re: Random problems with PDF-export: zero sized PDFs
                La0s Level 1

                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:


                • 5. Re: Random problems with PDF-export: zero sized PDFs
                  Kasyan Servetsky Level 5

                  Thank you all guys for the quick reply!



                  1. All documents contain only placed jpeg-files and some text. A document, in most cases, has about 40 pages with 4-12 images per page. I don’t see any dependency because the problem occurred only once on my side and the heaviest file (12 images per page) was exported successfully then. My client tested it on two machines -- on Windows 10 and the latest version of InDesign – and experienced this issue from time to time.
                  2. The client has a dedicated machine for the purpose: nobody is using it while the script is running. I also didn’t use my computer while testing the script.
                  3. I don’t remember if the browser was open during the problematic test. Usually I keep Firefox open and have some add-ons installed. Closing all unnecessary apps before running the script is a good idea.



                  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) {
                          else {
                      catch(err) {
                          try {
                              LogError("Error: " + err.message + ", file: " + doc.name + ", function 'ExportPDF', line: " + err.line);
                              $.writeln(err.message + ", line: " + err.line);
                          catch(err) {
                              $.writeln(err.message + ", line: " + err.line);



                  The preset used is the built-in "[Press Quality]". As far as I know, they don’t print this in a printing shop.



                  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.