8 Replies Latest reply on Aug 28, 2012 8:05 AM by lhanneman

    [AS CS5] Exporting PDFs in background

    SuperMacGuy Level 2

      So CS5 has background exporting for PDFs. If I have a script that exports multiple PDFs or JPGs etc, like each page individually, or multiple settings sequentially (or now concurrently?), how do I know when it's done? Applescript normally "waits" until the process is done. But now what happens? How do I know that exporting is done and I can close the file, or PDFs are successfully made?

      I see there is a "background task" class now, and a "wait for task" command. Any examples on how to work with that? (Sorry I haven't had time to work with it just yet, working on other IDCS5/Snow Leopard things still.)

      TIA, Chris

        • 1. Re: [AS CS5] Exporting PDFs in background
          nope0000 Level 1

          I don't no anything about

          the scripting possibilitys nor do i about applescript.

           

          However, if everything else isn't possible:

           

          At least in VBcript it is no problem to check if the job finished. Either by checking the thread or by checking the pdf files.

          • 2. Re: [AS CS5] Exporting PDFs in background
            brettpolo Level 1

            If you're script still uses document. exportFile(),  nothing will change. For example, the following code will still work:

             

            t = app.activeDocument.exportFile(ExportFormat.pdfType, File("~/Desktop/Test.pdf"));
            alert("Task is done")

             

            If you want to use the 'background tasks'  functionality, you'll need to use document.asynchronousExportFile().  AsynchronousExportFile returns a background task, which has the method waitForTask().  You can use it something like this:

             

            t = app.activeDocument.asynchronousExportFile(ExportFormat.pdfType, File("~/Desktop/Test.pdf"));
            t.waitForTask();
            alert("Task is done")
            

             

            This will export your document as a PDF using a background task, wait for the export to complete, and then pop up an alert.  The problem is that you loose the advantages of a background task (namely, you can do other things while the file is exporting in the background).

             

            The backgroundTask object has a property status, which returns the status of the task, including TaskState.COMPLETED.  You could probably add an event listener to check for the state change from TaskState.RUNNING to TaskState.COMPLETED.  When I get a bit more time later, i'll check it out and try to provide some sample code.

             

            Again, if your concern is the behavior of scripts you already have, then nothing should change.  If you're looking to take advantage of the new background tasks, then there's some work to do.

             

            /dan

            • 3. Re: [AS CS5] Exporting PDFs in background
              SuperMacGuy Level 2

              Thanks, this makes sense. A quick test has pretty well confirmed it.

              I never make any assumptions about things not changing, when a new application version hits. Maybe for 1 version of ID, things were "the same" and did not require me to overhaul lots of scripts. So at this point I assume everything important I do is broken so I go over it and check everything out. (Guess I'm gun shy from all the changes. Damn you Adobe, Apple!)

              • 4. Re: [AS CS5] Exporting PDFs in background
                rottenuncle Level 1

                Anyone know if background exporting to pdf is more memory efficient? Also, do you need to turn it on in a script (AS)?

                 

                I've been using scripts to automate pdf exporting for years. But (after fairly recently moving to CS5) I ran into a case where, when exporting what should have been a 99 MB pdf, the finished pdf was smaller than that and was missing a few placed graphics toward the end of the document. On repeated attempts, this was repeated somewhat randomly (sometimes more, sometimes fewer graphics dropped). I was finally able to get it to work by manually exporting.

                 

                I noticed that the script export was not in the background, so now I'm thinking, maybe background exporting just works better in CS5?

                • 5. Re: [AS CS5] Exporting PDFs in background
                  sstanleyau Level 4

                  I don't know if it uses memory differently -- it just does the export on a background thread. You don't turn it on; you just use a different command, asynchronous export file. I haven't used it myself, but given your problems, it sounds worth a try.

                  • 6. Re: [AS CS5] Exporting PDFs in background
                    lhanneman Level 1

                    Do you know if asynchronousExportFile is available on InDesign Server? I'm testing a script that works locally on my computer with ESTK but when the script executes on IDS, it throws the following error:

                     

                    Uncaught JavaScript exception: ReferenceError: myDoc.asynchronousExportFile is not a function

                     

                    Where 'myDoc' is a document object (like I said, it works fine when I test it locally).

                     

                    Any thoughts?

                    • 7. Re: [AS CS5] Exporting PDFs in background
                      Laubender Adobe Community Professional & MVP

                      Check the Server documentation at:

                       

                      http://www.jongware.com/idjshelp.html

                       

                      It seems that "asynchronousExportFile" is not available with server…
                      Neither CS5 nor CS6.

                      Uwe

                      • 8. Re: [AS CS5] Exporting PDFs in background
                        lhanneman Level 1

                        @Uwe, thank you for the info.