Copy link to clipboard
Copied
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.
Cheers
Copy link to clipboard
Copied
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
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.")
Copy link to clipboard
Copied
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:
with(app.documentPreferences){
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"
}
with(app.viewPreferences){
horizontalMeasurementUnits = MeasurementUnits.millimeters;
verticalMeasurementUnits = MeasurementUnits.millimeters;
}
with(app.TransformPreference){
DimensionsIncludeStrokeWeight = false;
ScaleStrokes = false;
}
with(app.printPreferences){
sendImageData = ImageDataTypes.allImageData;
}
Copy link to clipboard
Copied
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!
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.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
[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.
Copy link to clipboard
Copied
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...) ![]()
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Harbs
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more