8 Replies Latest reply on Feb 12, 2009 11:57 PM by (Rasmus_Olsen)

    [CS3 JS] A little help setting flattener prefs

      Ladies and gentlemen,

      A little help setting flattener preferences when exporting is needed. I can't seem to grasp why I can use with(app.colorSettings){ to set the properties of the ColorSetting object but with(app.flattenerPreferences){ ESTK gives me "Object does not support the property or method.."

      I'm requesting a little kick in the right direction, thanks :-)

      Best regards,
        • 1. Re: [CS3 JS] A little help setting flattener prefs
          Hi Rasmsus / Hej Rasmus

          with(app.flattenerPresets) {

          This will alert the name of the first flattenerPreset.
          app.flattenerPresets holds the defined presets and is read only.

          The properties you can set, is listed here: http://www.indesignscriptingreference.com/CS3/JavaScript/FlattenerPreset.htm

          with(app.flattenerPresets) {
          item(0).rasterVectorBalance = 100;

          Should set the rasterVectorBalance to 100 for the first flattenerPreset (If the first preset is a Adobe preset [low resolution] you can only change it with scripting it seems)

          Hope this helps (DK: Du er velkommen til at sende mig en mail på mail (at) nobrainer (dot) dk hvis du har brug for hjælp til andet.
          • 2. Re: [CS3 JS] A little help setting flattener prefs
            Level 1
            Hi Thomas,

            Thank you for taking time to help me with this :-)

            Setting the properties of the app.flattenerPresets.item(0) object does just that; you changes the properties of the "[Low Resolution]" flattener preset. What I need to know is: How do I instruct InDesign to use "x" flattener preset or flattener preferences when exporting a PDF?

            In addition to this: When scanning through the InDesign object model viewer I can't help noticing the FlattenerPreference object. In my export script I set various properties of the ColorSetting object with(app.colorSettings){ - trying the same approach with(app.flattenerPreferences){ gives me the exception: "Object does not support the property or method FlattenerPreference" - so how do I set the properties of this object?

            I hope that you understand my question(s) :-)

            BTW I test the flattener preferences in effect upon export by using a filled frame with the Bevel and Emboss effect applied. The effect will get rasterized by the flattener when exporting a PDF version 1.3 from the document. Using Acrobat preflight on the resulting PDF I'm able to scan for image resolution and check whether or not the specific flattener property 'lineArtAndTextResolution = 300' was honoured. So far InDesign have been using 'lineArtAndTextResolution = 150' - this is a property of the Medium Resolution flattener preset. Sigh..
            • 3. Re: [CS3 JS] A little help setting flattener prefs

              First, the reason why you cannot use with(app.flattenerPreferences) is just as the exception says: app doesn't have flattenerPreferences property... only spreads have such...
              So I think the way you should go:

              -create either manually or by script a flattenerPreset (app.flattenerPresets) and set the lineArtAndTextResolution to a value you need

              -then create a PDFExportPreset (app.pdfExportPresets) where you set its appliedFlattenerPreset property to the desired preset

              -then use document.exportFile(format, to, showingOptions, using) where you set the using parameter to the previously created PDFExportPreset.

              Hope it helped!
              • 4. Re: [CS3 JS] A little help setting flattener prefs
                Level 1
                Hi Balázs,

                > appliedFlattenerPreset

                This must be it! ;-) Will give it a shot - thanks man..

                • 5. Re: [CS3 JS] A little help setting flattener prefs
                  Level 1
                  Referring to a flattener preset in either a PDF preset or app.pdfexportPreferences will do the job. I've wrote this function to create my flattener presets. Its based on the InDesign CS3 document preset sample script. If you replace the app.flattenerPresets array object with app.pdfexportPresets and replaces the preset attributes the function can be used to create PDF presets as well.

                  A big thanks to Thomas and Balázs for the kick(s) in the right direction. ;-)

                  function createFlattenerPreset(myPresetName){
                     var myPreset = app.flattenerPresets.item(myPresetName);
                     try {
                        myPresetName = myPreset.name;
                        alert("Flattener preset found\nResetting preset attributes...");
                           rasterVectorBalance = 100;
                           lineArtAndTextResolution = 914; //Res12 output/2
                           gradientAndMeshResolution = 300;
                           convertAllTextToOutlines = false;
                           convertAllStrokesToOutlines = false;
                           clipComplexRegions = true;
                        alert("Flattener preset not found\nCreating preset with attributes...");
                        myPreset = app.flattenerPresets.add(
                              lineArtAndTextResolution:914, //Res12 output/2
                        var presets = app.flattenerPresets;
                        for(var i = 0; i < presets.length; i++){
                           var ifFound;
                           if(presets.item(i).name == "myPreset"?ifFound = true:ifFound = false);
                        if(ifFound == true?alert("Preset succesfully created!"):alert("Houston we have a problem!"));

                  • 6. Re: [CS3 JS] A little help setting flattener prefs
                    Level 1
                    Believe I've found a bug:
                    > clipComplexRegions:true

                    When visually inspecting the flattener preset the value of this variable is beeing reported as N/A. This same goes for false as well. Hmm.

                    • 7. Re: [CS3 JS] A little help setting flattener prefs
                      Level 1
                      Hi Rasmus,

                      When rasterVectorBalance = 100, clipComplexRegions is not available.


                      • 8. Re: [CS3 JS] A little help setting flattener prefs
                        Level 1
                        Hi Ole,

                        After consulting the "Transparency in Adobe Applications Print Production Guide" this makes perfectly sense. Thank you for correcting me.