7 Replies Latest reply on Oct 29, 2010 4:33 AM by deerowbear

    preflightProcess.saveReport not working in CS5?

    cweger79

      Hi all,

       

      I'm trying to use the Scripting Guide demo script "ProcessPreflightProfile.jsx" to save a preflight report. It doesn't create a file at all. The relevant lines of code are:

       

       

      var myProcess = app.preflightProcesses.add(myDoc, myProfile);

      myProcess.waitForProcess();

      var myResults = myProcess.processResults;

      //If errors were found

      if (myResults != "None")

      {

      //Export the file to PDF. The "true" value selects to open the file after export.

      myProcess.saveReport(File("~/Desktop/PreflightResults.pdf"), true);

       

       

      I'm using the demo script exactly as distributed, unmodified (except for the File path, which in the original script was "/C/blah blah").
      I know there are results, because myResults.length = 44, and I can see it in the debugger.
      Is there something amiss with saveReport? I've also tried setting the file extension to ".txt" which also does not generate a file.
      I'm hoping I'm just doing something stupid (the usual case) and someone will point me to the correct solution.
      Thanks,
      Chuck
        • 1. Re: preflightProcess.saveReport not working in CS5?
          deerowbear Level 1

          Try taking out the ~ put the full path

          • 2. Re: preflightProcess.saveReport not working in CS5?
            deerowbear Level 1

            This function will allow you to save a pdf....it expects a document to be currently open and a parameter of type string for the ouput directory:

             

             

            /*************************

            Export PDF

            @param string output

            the path to save the pdf

            **************************/

            function exportPDF(output)

            {

                with(app.pdfExportPreferences)

                {

                    //Basic PDF output options.

                    pageRange = PageRange.allPages;

                    acrobatCompatibility = AcrobatCompatibility.acrobat6;

                    exportGuidesAndGrids = false;

                    exportLayers = false;

                    exportNonPrintingObjects = false;

                    exportReaderSpreads = false;

                    generateThumbnails = false;

                    try

                    {

                        ignoreSpreadOverrides = false;

                    }

                    catch(e)

                    {}

                    includeBookmarks = true;

                    includeHyperlinks = true;

                    includeICCProfiles = true;

                    includeSlugWithPDF = false;

                    includeStructure = false;

                    interactiveElementsOption = InteractiveElementsOptions.doNotInclude;

                    //Setting subsetFontsBelow to zero disallows font subsetting;

                    //set subsetFontsBelow to some other value to use font subsetting.

                    subsetFontsBelow = 0;

                    //

                    //Bitmap compression/sampling/quality options.

                    colorBitmapCompression = BitmapCompression.zip;

                    colorBitmapQuality = CompressionQuality.eightBit;

                    colorBitmapSampling = Sampling.none;

                    //thresholdToCompressColor is not needed in this example.

                    //colorBitmapSamplingDPI is not needed when colorBitmapSampling

                    //is set to none.

                    grayscaleBitmapCompression = BitmapCompression.zip;

                    grayscaleBitmapQuality = CompressionQuality.eightBit;

                    grayscaleBitmapSampling = Sampling.none;

                    //thresholdToCompressGray is not needed in this example.

                    //grayscaleBitmapSamplingDPI is not needed when grayscaleBitmapSampling

                    //is set to none.

                    monochromeBitmapCompression = BitmapCompression.zip;

                    monochromeBitmapSampling = Sampling.none;

                    //thresholdToCompressMonochrome is not needed in this example.

                    //monochromeBitmapSamplingDPI is not needed when

                    //monochromeBitmapSampling is set to none.

                    //

                    //Other compression options.

                    compressionType = PDFCompressionType.compressNone;

                    compressTextAndLineArt = true;

                    cropImagesToFrames = true;

                    optimizePDF = true;

                    //

                    //Printers marks and prepress options.

                    //Get the bleed amounts from the document's bleed.

                    bleedBottom = app.activeDocument.documentPreferences.

                    documentBleedBottomOffset;

                    bleedTop = app.activeDocument.documentPreferences.documentBleedTopOffset;

                    bleedInside = app.activeDocument.documentPreferences.

                    documentBleedInsideOrLeftOffset;

                    bleedOutside = app.activeDocument.documentPreferences.

                    documentBleedOutsideOrRightOffset;

                    //If any bleed area is greater than zero, then export the bleed marks.

                    if(bleedBottom == 0 && bleedTop == 0 && bleedInside == 0 && bleedOutside == 0)

                    {

                        bleedMarks = true;

                    }

                    else

                    {

                    bleedMarks = false;

                    }

                    colorBars = true;

                    colorTileSize = 128;

                    grayTileSize = 128;

                    cropMarks = true;

                    omitBitmaps = false;

                    omitEPS = false;

                    omitPDF = false;

                    pageInformationMarks = true;

                    //pageMarksOffset = 12;

                    pdfColorSpace = PDFColorSpace.unchangedColorSpace;

                    //Default mark type.

                    pdfMarkType = 1147563124;

                    printerMarkWeight = PDFMarkWeight.p125pt;

                    registrationMarks = true;

                    try

                    {

                    simulateOverprint = false;

                    }

                    catch(e)

                    {}

                    useDocumentBleedWithPDF = true;

                    //Set viewPDF to true to open the PDF in Acrobat or Adobe Reader.

                    viewPDF = false;

                }

                //Now export the document. You'll have to fill in your own file path.

                var output_file = new File(output);

            var file = new File(output_file.fsName.toString() + "\\" + app.activeDocument.name.substring(0, app.activeDocument.name.lastIndexOf(".")) + ".pdf");

                app.activeDocument.exportFile(ExportFormat.pdfType, file,false);

            }

            • 3. Re: preflightProcess.saveReport not working in CS5?
              cweger79 Level 1

              Thanks for your posts, but post #1 is incorrect and post #2 has nothing to do with my question.

               

              Re post #1: "A path name can start with a tilde (~) to indicate the user’s home directory. It corresponds to the platform’s HOME environment variable."

              -- JavaScript Tools Guide (CS5), page 41.

              I use tildes all the time in paths without a problem.

               

              Re post #2: I don't need to know how to export a PDF of the document; I want to save the preflight report, which according to the docs you can do by calling the method named "saveReport" on the preflightProcess object.

               

              Regards,

              Chuck

              • 4. Re: preflightProcess.saveReport not working in CS5?
                Larry G. Schneider Adobe Community Professional & MVP

                Do you have a Preflight profile called Test?

                • 5. Re: preflightProcess.saveReport not working in CS5?
                  cweger79 Level 1

                  Larry,

                   

                  Good suggestion, but if I did not have a "Test" profile, the script would have failed at this line:

                   

                  app.preflightProcesses.add(myDoc, myProfile);

                   

                  with the ever-popular "undefined is not an object" message.

                   

                  Since it's not failing there, and since I DO have a "Test" profile, I'm afraid I can't award you points for the right answer. But, we have some lovely parting gifts AND a set of Samsonite luggage for you...

                   

                  Regards,

                  Chuck

                  • 6. Re: preflightProcess.saveReport not working in CS5?
                    cweger79 Level 1

                    Additional information:

                     

                    It turns out the the preflight report is actually implemented in ExtendScript, by a file named "ExportPreflightReport.jsx" inside the InDesign app's Scripts folder.

                     

                    This script is apparently called by some C++ code inside InDesign. It's passed an array of arguments in the global "arguments" variable.

                     

                    However, in my case, the "arguments" is zero-length; the C++ code is not supplying any arguments to the script.

                     

                    Not sure what I can do about that at this point, but it was (for me) an interesting discovery.

                    • 7. Re: preflightProcess.saveReport not working in CS5?
                      deerowbear Level 1

                      This worked for me and made a pdf....I took the itemByName("Test"); out.

                       

                      //ProcessPreflightProfile.jsx
                      //An InDesign CS5 JavaScript
                      //
                      //Shows how to process an InDesign preflight profile.

                      main();

                      function main(){
                      mySetup();
                      mySnippet();
                      myTeardown();
                      }

                      //<setup>
                      function mySetup(){
                      }
                      //</setup>

                      //<snippet>
                      function mySnippet(){
                      //<fragment>
                      // Assume there is a document.
                      var myDoc = app.documents.item(0);
                      // Assume the Test preflight profile exists.
                      var myProfile = app.preflightProfiles;
                      //Process the myDoc with the rule



                          try
                          {
                      var myProcess = app.preflightProcesses.add(myDoc, myProfile);
                          }
                      catch(e)
                      {
                             alert(e);
                          }
                      myProcess.waitForProcess();
                      var myResults = myProcess.processResults;
                      //If errors were found
                      if (myResults != "None")
                      {
                        //Export the file to PDF. The "true" value selects to open the file after export.
                        myProcess.saveReport(File("/c/PreflightResults.pdf"), true);
                      }
                      //Cleanup
                      myProcess.remove();
                      //</fragment>
                      }
                      //</snippet>

                      //<teardown>
                      function myTeardown(){
                      }
                      //</teardown>