Skip navigation
TonyMacerony
Currently Being Moderated

[AS] InDesign CS5.5 page orientation error

Jan 26, 2012 7:00 AM

Tags: #indesign_cs5.5 #page_orientation #applescript

I have a strange issue with setting the page orientation of a new document in InDesign CS5.5.

 

In CS5 I used the following script:

tell application "Adobe InDesign CS5"

          set vTemplate to make new document

          tell vTemplate

    set page orientation of document preferences of active document to landscape


          end tell

end tell

 

But the same script in CS5.5 gives an error:

"Adobe InDesign CS5.5 got an error: Can’t set page orientation of document preferences of active document of active document to landscape."

 

Can somebody pint me in the right direction?

 

Thanks!

 
Replies
  • Currently Being Moderated
    Jan 26, 2012 9:23 AM   in reply to TonyMacerony

    It looks to me like it should error; I would wonder why it works in any version. I think this line:

     

    set page orientation of document preferences of active document to landscape

     

    should be:

     

    set page orientation of document preferences to landscape

     

    Since that line is in a tell block, the of active document is redundant—you're telling the document object already.

     

    Jeff

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 11:05 AM   in reply to TonyMacerony

    Ton, your error code would still sugest you are double referencing the document… I just tried Jeff's suggestion and it works just fine on 10.6.8

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 12:28 PM   in reply to TonyMacerony

    You have now lost reference to both document objects… What works is…

     

    tell application "Adobe InDesign CS5" -- issue commands to indesign

                 set vTemplate to make new document

                 tell vTemplate -- issue commands to the newly created document

                                set page orientation of document preferences to landscape

                 end tell -- end commands to document

    end tell -- commands to indesign

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 12:40 PM   in reply to TonyMacerony

    I just got a chance to test it on CS5.5. I got:

    Adobe InDesign CS5.5 got an error: Invalid value for set property 'page orientation'. Expected landscape/portrait, but received landscape.

     

    I don't understand this at all.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 12:49 PM   in reply to TonyMacerony

    Tony, Jeff has a different error message to what you posted… I don't have 5.5 but I wouldn't make sence of that either…?

     

    Expected landscape/portrait, but received landscape hum…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 12:55 PM   in reply to Muppet Mark

    Yes, CS5 works, but CS5.5 doesn't—but not in the way Tony originally posted!

     

    FWIW, the equivalent assignment in JavaScript:

     

    app.activeDocument.documentPreferences.pageOrientation = PageOrientation.LANDSCAPE;
    

     

    works in CS5.5 as expected. I really don't know Applescript—I just saw what looked like a pretty clear-cut error in Tony's code—are there other ways to refer to these enumerator objects in it?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 1:17 PM   in reply to absqua

    AppleScript is typically fairly forgiving in its parameters, so you could try both the value 2003395685 and the string 'wide' it represents (see http://jongware.mit.edu/idcsjs5.5/pe_PageOrientation.html).

     

    I agree this would indicate some sort of bug in the scripting interface.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 1:23 PM   in reply to absqua

    I use AppleScript far less than I used to a couple of years back… I answer the odd post here because help with AppleScript is not as readily available. I recall the some of the syntax thou… I don't think there is anything that could be done from the user point of view it's down to the app's scripting terminology when you compile the code 'landscape' is NOT a variable its a recognised application term… It will get some >>blah<< identifer behind the scenes so to speak… AppleScript became a PITA when dealing with ibm/intel macs/apps using the ESTK has meant I avoided this…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 1:53 PM   in reply to Muppet Mark

    Would it be a viable workaround ad hoc solution to switch "page width" and "page height"?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 2:05 PM   in reply to [Jongware]

    make new document is pretty open ended is just going to be the app's user default… size, orientation etc. It would be better to us the 'with properties' and supply the required list of settings at creation time…

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 3:17 PM   in reply to Muppet Mark

    yes, it's  either that (which gives you all freedom), or create a document preset first and use that instead.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 5:21 PM   in reply to TonyMacerony

    The problem is essentially a bug introduced in 5.5. Basically, the dictionary uses the terms "portrait" and "landscape" in two places, with different underlying codes.

     

    The offending terminology relates to the "set folio orientation" command, which defines landscape as «class eIOh», as opposed to the original definition of «class wide».

     

    Anyway, the solution is to use something like this:

     

                        set page orientation of document preferences to «class wide»


    Feel free to log it as a bug.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 6:18 PM   in reply to Shane Stanley

    Clarity!

     

    Would you care to explain, Shane, how you go about discovering those underlying <<class>> identifiers?

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 6:26 PM   in reply to absqua

    absqua wrote:

     

    Would you care to explain, Shane, how you go about discovering those underlying <<class>> identifiers?

     

    I use Script Debugger, which has an option to show them (View -> Show Raw (Chevron) Syntax) .

     

    You can also see them if you open the dictionary in AppleScript Editor, choose Save As, and save as an .sdef file. That's an XML file you can look at in a text editor. But it's very tedious, especially for something with a big dictionary like ID.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 7:45 PM   in reply to Shane Stanley

    Thank you Shane. I've seen the chevrons pop up in compiled Applescripts before but have never invested the time to learn how to track them back to the “regular” identifiers.

     

    Poking around a bit, it looks like Apple also provides a command-line tool, sdef, to dump them:

     

    sdef /Applications/Adobe\ InDesign\ CS5.5/Adobe\ InDesign\ CS5.5.app | xmllint --format - | grep landscape

     

    as a quick-and-dirty way to get those of us without Script Debugger at least sort of into the general vicinity.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2012 7:55 PM   in reply to absqua

    absqua wrote:

     

    Poking around a bit, it looks like Apple also provides a command-line tool, sdef, to dump them:

     

    That's essentially what AppleScript Editor does when you open a dictionary for an app that doesn't have an .sdef file, like ID.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 3, 2012 7:28 AM   in reply to absqua

    @ absqua - Thanks for this!

    app.activeDocument.documentPreferences.pageOrientation = PageOrientation.LANDSCAPE;
    

     

    When the totally green newbie JS student (like me) tries to follow a tutorial, say for example like the DocumentTemplate tutorial script beginning on the bottom of page 29 in Adobe InDesign CS6 Scripting Tutorial, and who unknowingly, but mistakenly thought something as benign as following sundry script examples, etc. (because they're working with many windows open) would best be facilitated with a default document in LANDSCAPE orientation, this little line of code will overtly address the problem created by the tutorial script writer who similarly and unknowingly, but mistakenly thought something as benign as orientation would not coyly gum up the works.

     

    You helped fix that problem and I thank you very much!

     

    Kind regards,

     

    Kelly

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points