8 Replies Latest reply on May 31, 2013 5:45 AM by enbanat

    Strange behavior function Document.exportFile()

    enbanat

      My script uses the exportFile to get files PDF. Usually this is a fairly lengthy process.

       

      When you run the script sometimes disappear from the exported files attached pictures PDF. If at the time of export of the user presses any key on the keyboard is a strange case. From this point on the attached PDF-images disappear from the resulting exported PDF. The same thing occurs during the print to PostScript file.

       

      I wrote a little sketch showing the problem. You can download it here: http://zalil.ru/34525491

       

      Is not there a way to avoid this?

        • 1. Re: Strange behavior function Document.exportFile()
          Laubender Adobe Community Professional & MVP

          @enbanat – what kind of method do you use to export to PDF?

           

          1. "exportFile()" //InDesign CS1 (?) and above

           

          or

           

          2. "asynchronousExportFile()" //InDesign CS5 and above

           

          ??

           

          If you use the method in 2. you could try the one, the "old" one, in 1.

          Then the user is unable to do anything with objects on pages during export time.

           

          Uwe

          • 2. Re: Strange behavior function Document.exportFile()
            enbanat Level 1

            Laubender wrote:

             

            @enbanat – what kind of method do you use to export to PDF?

             

            1. "exportFile()" //InDesign CS1 (?) and above

             

            or

             

            2. "asynchronousExportFile()" //InDesign CS5 and above

             

             

            Uwe, thanks for the idea! I will explore a method asynchronousExportFile.

             

            I use a very old script. Age of CS. It has been used for a long time and worked flawlessly. In versions of CS4+ began a strange error associated with typing on the keyboard while exports.

             

            Here is a small script written to demonstrate this.  He demands to him in the same folder was "PDF link.pdf". This file must be bigger than 1 MB.

             

             

            try {
                      var scriptFolder = app.activeSctipt.parent;
            } catch (e) {
                      var scriptFolder = (new File(e.fileName)).parent;
            }
            
            var linkedFile = new File(scriptFolder.absoluteURI + '/PDF link.pdf');
            
            if (!linkedFile.exists) {
              
                      alert('Error\nFile "PDF link.pdf" not found.');
                      exit();
            }
            
            if (linkedFile.length < 777777) {
              
                      alert('Error\nFile "PDF link.pdf" too low. You need to use 1Mb PDF file.');
                      exit();
            }
            
            var exportFolder = new Folder(Folder.desktop + "/Extport Tests/" + 
                      (new Date()).toString().replace(/:/g, '-'));
            
            if (!exportFolder.create()) {
                      alert('Error\nCan not create folder ' + File.decode(exportFolder));
                      exit();
            }
            
            
            if (Number(String(app.version).split('.')[0]) < 6) {
                      alert('Start PDF export\n' +
                                'Please, type any text on you keyboard for test.\n' +
                                'Press ESC for exit.\n' + 
                                'See test files in ' + File.decode(exportFolder));
            } else {
                      // show dialog;
                      var window = new Window('palette', 'test');
                      window.alignChildren = 'left';
                      window.add('statictext', undefined, 'PDF export started.');
                      window.add('statictext', undefined, 'Please, type any text on you keyboard for test.');
                      window.add('statictext', undefined, 'Press ESC for exit.');
                      window.add('statictext', undefined, 'See test files in ' + File.decode(exportFolder));
            }
            
            
            // make test document
            var document = app.documents.add();
            var page = document.pages[0];
            
            // do export
            app.pdfExportPreferences.pageRange = '1';
            
            var n = 0, errorsCounter = 0;
            
            while (true) {
              
                      page.place(linkedFile);
              
                      var file = new File(exportFolder.absoluteURI + '/' + ++n + '.pdf');
                      document.exportFile(ExportFormat.PDF_TYPE, file, false);
              
                      page.pageItems.everyItem().remove();
              
                      window && window.show();
                      $.sleep(111);
              
                      if (file.length < 33333 && errorsCounter++) {
              
                                alert('Bingo!\nBroken file detected:\n' + file.fsName);
                                exportFolder.execute();
                                exit();
                      }
            }
            
            • 3. Re: Strange behavior function Document.exportFile()
              absqua Level 4

              I've posted about this bug before (see http://forums.adobe.com/message/4898153#4898153), and filed the bug with Adobe for at least a couple of releases. Others have run across it as well.

               

              I've tried any number of workarounds, including asynchronousExportFile(), without success.

               

              Please file your own bug report if you can: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform .

               

              Jeff

              • 4. Re: Strange behavior function Document.exportFile()
                Ville Järvensivu

                In reply to: enbanat

                 

                Yes please, file new bug report. I've done it also.

                It's serious issue, which should have been fixed ages ago!

                • 5. Re: Strange behavior function Document.exportFile()
                  enbanat Level 1

                  Many thanks.

                   

                  Can add to your post, that the same bug is repeated when printing to a PS-printer.

                   

                  I use a script almost every day. It is now three years with each new version hope that will fix this error.

                  • 6. Re: Strange behavior function Document.exportFile()
                    Ville Järvensivu Level 1

                    ..and you have also filed bug reports?

                     

                    (just checking)

                    • 8. Re: Strange behavior function Document.exportFile()
                      enbanat Level 1

                      In desperation, did the test in Applescript. The result is the almost same.

                       

                      set _dest to path to desktop as string
                      set n to 0
                      set _pdf to choose file with prompt "Select an PDF-file to place in Indesign"
                      
                      tell application "Adobe InDesign CS6"
                                set _doc to make new document
                      
                                repeat
                                          set n to n + 1
                      
                                          tell _doc
                      
                                                    delete all page items
                                                    place _pdf on page 1
                                                    export format PDF type to (_dest & n & ".pdf")
                      
                                          end tell
                                end repeat
                      end tell