8 Replies Latest reply on Oct 14, 2009 3:55 AM by Harbs.

    Setting default preferences (CS3)


      Hi, I seem to be losing my preferences a lot recently, when I have a crash, and it's becoming quite tedious fixing them manually.

      I've managed to successfully java script a few things to work on startup. However there are a few things I don't know the code for:


      1. Uncheck "Dimensions include stroke weight"

      2. Uncheck "Adjust stroke weight when scaling"

      3. Printer prefs > Graphics > images > send data "all" (Needs to be for the application default printer preferences, NOT the current document preferences)


      Is there a list available that covers all these things? Can't seem to find them in the Adobe scripting reference or guide.



        • 1. Re: Setting default preferences (CS3)
          [Jongware] Most Valuable Participant

          The built-in Help of the ESTK ought to be the definitive reference -- it uses an XML file that gets generated by the application itself. But browsing or searching it is ... cumbersome ... (mildly stated). I used a free text search on my version of this help [*] and immediately found these:


          Application -> TransformPreference -> adjustStrokeWeightWhenScaling ("Whether strokes are scaled when objects are scaled.") and dimensionsIncludeStrokeWeight ("If true, includes the stroke weight when displaying object dimensions. If false, measures objects from the path or frame.").


          Under Document/Book -> PrintPreferences, I found this: sendImageData; ImageDataTypes.ALL_IMAGE_DATA ("Sends full-resolution data.")

          [*] I took the XML file and ran an XSLT transform on it to convert to easy-to-read HTML (and added lots of internal links as well). This huge set of HTML files, and a single Windows compatible CHM file, can be found on http://www.jongware.com/idjshelp.html. "Free text search" is not really an option in the HTML files; perhaps your browser allows it. The CHM file is very user friendly, though -- for Windows users. The CS4 version is even a bit better. If you don't mind me tootin' own horns and all

          1 person found this helpful
          • 2. Re: Setting default preferences (CS3)
            timothyj09 Level 1

            Cool, I did a search on the InDesign Scripting reference and and found them too.


            It's pretty much just trial and error for me, as this is my first shot at java script (I have no idea what I'm doing )

            This is what I've got below, everything works perfectly, except for the last two parts:



            pageHeight = "297mm";

            pageWidth = "210mm";

            pageOrientation = PageOrientation.portrait;

            pagesPerDocument = 1;

            facingPages = false;

            documentBleedBottomOffset = "0mm";

            documentBleedTopOffset = "0mm";

            documentBleedInsideOrLeftOffset = "0mm";

            documentBleedOutsideOrRightOffset = "0mm";



            with (app.marginPreferences){

            bottom = "0mm"

            left = "0mm"

            right = "0mm"

            top = "0mm"




            horizontalMeasurementUnits = MeasurementUnits.millimeters;

            verticalMeasurementUnits = MeasurementUnits.millimeters;




            DimensionsIncludeStrokeWeight = false;

            ScaleStrokes = false;




            sendImageData = ImageDataTypes.allImageData;


            • 3. Re: Setting default preferences (CS3)
              [Jongware] Most Valuable Participant

              First thing to do is grasp the difference between name of an object and name of a property

              "TransformPreference" is the name of an object -- a 'type', just as "Number" is, and "String", and lots of Others. As sort of convention, these are written with an initial capital. You cannot assign a value to an object; you need a variable of that type instead. And an object, in turn, may contain new variables (its 'properties').


              So, if I say that an Application contains an object TransformPreference that has a property adjustStrokeWeightWhenScaling, you cannot literally copy-and-paste everything together. Besides, you really have to check case usage. Javascript is Case Sensitive!


              • "app" is the name of the Application object we are working with (you got that right)
              • the transform preference object is called 'transformPreferences'
              • and that, in turn, has a boolean 'dimensionsIncludeStrokeWeight' (note case)


              So a full assignment line would be


              app.transformPreferences.dimensionsIncludeStrokeWeight = false;


              or, in the alternative notation


              with(app.transformPreferences) {
              dimensionsIncludeStrokeWeight = false;
              adjustStrokeWeightWhenScaling = false;


              (which reminds me, where did you ever get "ScaleStrokes" from?)


              The Print Preference thingy is something different. The "application" doesn't have any print preferences you can set! Only a Document or a Book (which is kind of a document, I suppose) can have these. The print preferences are what "get changed" if you take a print preset and change those before actually pressing the 'print' button.

              The short of it is that you cannot set default 'print preferences' for the program; however, that ought not to be a problem because that's what Print Presets are for. And you don't need a script to save/restore these.

              1 person found this helpful
              • 4. Re: Setting default preferences (CS3)
                timothyj09 Level 1

                That's fantastic, I'm learning a lot here. That worked perfectly.


                I found the "ScaleStrokes" in this: http://www.kahrel.plus.com/indesign/id4-dict.pdf

                I was probably way off the mark with my interpretation of the document.


                More importantly...

                If you go to file > print presets > define [Default]. Is there no way to script these printer settings, or is it handled through the OS?

                All that I know is when my InDesign crashes, I lose these settings (which apply themselves to every new document - hence my frustration when they revert back to their default default status - and god knows where that comes from! Maybe that's what I need to be changing? The default default settings )


                You're right on the money though, the code I used for this was just a modified version of the code I found for the document printer presets.


                hope that wasn't too confusing...

                • 5. Re: Setting default preferences (CS3)
                  Harbs. Level 6

                  This is not going to help with CS3, but for CS4, here's a really cool way to save and load preferences: http://in-tools.com/wordpress/indesign/scripts/preference-manager-script


                  (The reason it's CS4-only is because the E4X implementation in CS3 was incomplete, and I wasn't going to break my head writing the code without E4X...)

                  • 6. Re: Setting default preferences (CS3)
                    [Jongware] Most Valuable Participant
                    [id4-dict.pdf] .. I was probably way off the mark with my interpretation of the document. ..


                    Now that was weird. I didn't get it for a while -- and I was wondering why the ever-so-punctual Peter Kahrel called this a list for "InDesign 4". That's frowned upon over here in the forums, because the full name of that version is "CS4".

                    Then the penny dropped: this is a list for CS2, and (most likely) for Visual Basic, not for Javascript. Hence the unknown commands and strange (for JS) capitalization.

                    • 7. Re: Setting default preferences (CS3)
                      timothyj09 Level 1

                      Yep, I found that one when searching Harbs. Phenomenal work there. Should be upgrading to CS4 soon, so It'll be nice to try out.


                      In the meantime, can anyone shed any light on scripting the default application printer presets? Is it possible?

                      • 8. Re: Setting default preferences (CS3)
                        Harbs. Level 6

                        PrinterPresets are a collection.


                        You will need to use app.printerPresets.add() for each preset you want 

                        and add it with whatever properties you need.