6 Replies Latest reply on Sep 20, 2013 12:11 AM by Laubender

    [JS, CC] pdfExportPresets Grayscale for Mac and Windows

    tobias.wantzen

      Hi,

       

      I have to do a grayscale PDF export by scripting. Therefore I tried to define flattener and PDF export presets in the following function:

       

       

      function pdfSettingsCheck (myFlattenerPresetName, myPDFExportPresetName)
      {
          // definitions
          // check flattener
          var tempFlattenerPreset = app.flattenerPresets.itemByName(myFlattenerPresetName);
          if ( tempFlattenerPreset == null )
          {
              var flattenerPreset = app.flattenerPresets.add(
              {
                  name:myFlattenerPresetName,
                  rasterVectorBalance: FlattenerLevel.HIGH,
                  lineArtAndTextResolution: 2400.0,
                  gradientAndMeshResolution: 300.0,
                  convertAllTextToOutlines: true,
                  convertAllStrokesToOutlines: true,
                  clipComplexRegions: false
              });
          }
          // check PDF settings
          var pdfExportPreset = app.pdfExportPresets.itemByName(myPDFExportPresetName);
          if ( pdfExportPreset == null ){
              pdfExportPreset = app.pdfExportPresets.add({   // this line throws the error!
                  name:myPDFExportPresetName, 
                  subsetFontsBelow:100, 
                  pdfColorSpace:({}), 
                  includeICCProfiles:({}), 
                  omitEPS:false, 
                  omitPDF:false, 
                  omitBitmaps:false, 
                  cropImagesToFrames:true, 
                  generateThumbnails:false, 
                  optimizePDF:true, 
                  includeStructure:false, 
                  acrobatCompatibility:({}), 
                  simulateOverprint:false, 
                  pdfDestinationProfile:"Generic Gray Profile", 
                  pdfXProfile:"Generic Gray Profile", 
                  includeHyperlinks:false, 
                  includeBookmarks:false, 
                  exportNonprintingObjects:false, 
                  exportGuidesAndGrids:false, 
                  exportLayers:false, 
                  standardsCompliance:({}), 
                  outputCondition:"", 
                  colorBitmapSampling:({}), 
                  colorBitmapSamplingDPI:400, 
                  colorBitmapCompression:({}), 
                  colorBitmapQuality:({}), 
                  grayscaleBitmapSampling:({}), 
                  grayscaleBitmapSamplingDPI:400, 
                  grayscaleBitmapCompression:({}), 
                  grayscaleBitmapQuality:({}), 
                  monochromeBitmapSampling:({}), 
                  monochromeBitmapCompression:({}), 
                  compressTextAndLineArt:true, 
                  thresholdToCompressColor:800, 
                  thresholdToCompressGray:800, 
                  thresholdToCompressMonochrome:1800, 
                  colorTileSize:128, 
                  grayTileSize:128, 
                  compressionType:({}), 
                  exportReaderSpreads:false, 
                  pageMarksOffset:5, 
                  cropMarks:false, 
                  pageInformationMarks:false, 
                  bleedMarks:false, 
                  colorBars:false, 
                  registrationMarks:false, 
                  printerMarkWeight:({}), 
                  bleedTop:0, 
                  bleedInside:0, 
                  bleedBottom:0, 
                  bleedOutside:0, 
                  pdfMarkType:({}), 
                  useDocumentBleedWithPDF:false, 
                  includeSlugWithPDF:false, 
                  ignoreSpreadOverrides:true, 
                  outputConditionName:"", 
                  ocRegistry:"", 
                  interactiveElementsOption:({}), 
                  effectivePDFDestinationProfile:"Generic Gray Profile", 
                  effectiveOCRegistry:"", 
                  effectiveOutputCondition:"", 
                  effectivePDFXProfile:"Generic Gray Profile", 
                  exportWhichLayers:({}), 
                  parent:resolve("/"), 
              });
          }
          // actively reset flattener and PDF compliance
          pdfExportPreset.standardsCompliance = PDFXStandards.NONE;
          pdfExportPreset.appliedFlattenerPreset = app.flattenerPresets.itemByName(myFlattenerPresetName);  
      }
      

       

      This works fine for Macintosh, but it has to work on both Windows and Mac (I’m developing on a Mac). I suggest it’s the profile name which makes Windows InDesign to throw an error (I marked the line in the code): error # 30615.

       

      Thanks for your help!

      Cheers

      Tobias

        • 1. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
          tobias.wantzen Level 1

          Meanwhile I tested »Dot Gain 15%«, which is available on both platforms. But the error remains. When manually checking the PDF preset in the UI, it is there but the profile name is »sRGB« with the warning, that an unknown profile is mentioned in the preset.

           

          When manually choosing the correct profile, the script still terminates with the same error on the same line. It’s a bit confusing, because the PDF preset is applied in InDesign and with »if ( pdfExportPreset == null )« it should’nt do the »pdfExportPreset = app.pdfExportPresets.add{}« line.

           

          Tobias

          • 2. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
            Laubender Adobe Community Professional & MVP

            @Tobias – I cannot test right now, but did you try:

             

            myCurrentPdfExportPreset.isValid

             

            instead of:

             

            myCurrentPdfExportPreset == null

             

            ?

             

            Oh. And maybe use a different variable name for your specific pdfExportPreset.

            That name could be reserved…

             

            I won't try with the plain:

             

            var pdfExportPreset = app.pdfExportPresets.itembyName("HereGoesTheNameOfThePreset");

             

            Instead I would use something like this:

             

            var myCurrentPdfExportPreset = app.pdfExportPresets.itembyName("HereGoesTheNameOfThePreset");

             

            Uwe

            • 3. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
              tobias.wantzen Level 1

              Uwe,

               

              thanks for checking my code.

               

              .isValid:

              Meanwhile I chanced to .isValid. Interestingly on the Mac == null  works fine. .idValid works on both platform.

               

              var name:

              You’re right - this is much to close to the object name of InDesign.

               

              I collected the values with a script snippet and .toSource() from a manually applied PDF preset. Now I see more things that aren’t defined ideally (spoken nicely ...):

              parent:resolve("/"),

              acrobatCompatibility:({}),

              etc.

               

              I changed my workflow and exported the manual presets to a .joboptions file. The script now imports the presets from this file, if it is not already available in InDesign. This works perfekt on Mac and Windows and has the further advantage that the presets could be changed without the need to go back to scripting (accepting the drawbacks that come having a multi file script).

               

              Tobias

              • 4. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
                Laubender Adobe Community Professional & MVP

                @Tobias – glad, you sorted this out…

                 

                 

                Well, it was past midnight in my time zone, when I wrote my answer.

                So I did:

                 

                itembyName

                 

                instead of:

                 

                itemByName

                 

                Should be written with an capital "B", of course!
                CamelCase…

                 

                 

                Uwe

                • 5. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
                  tobias.wantzen Level 1


                  Well, it was past midnight in my time zone, when I wrote my answer.

                  Considering your name we’re both from Germany (or nearby), so: first answer 01:13, second answer 07:31 – busybusy

                   

                  Tobias

                  • 6. Re: [JS, CC] pdfExportPresets Grayscale for Mac and Windows
                    Laubender Adobe Community Professional & MVP

                    You are right. I'm from Germany.

                    Too much coffee in the evening…

                     

                    Uwe