in

Quark Forums

Updating script to support QuarkXPress 8 from 7

Last post 06-01-2009 4:09 PM by JRS. 18 replies.
Page 1 of 2 (19 items) 1 2 Next >
Sort Posts: Previous Next
  • 04-28-2009 3:58 PM

    Lightning [li] Updating script to support QuarkXPress 8 from 7

     Ok, I've been beating my head against my desk long enough, any help would be GREATLY appreciated. The following script worked just fine using Quark 7 but my recent upgrade to Quark 8 broke it  (alot) :)

    Basically what's going on in we open a QuarkXPress doc, save it off as an eps, do some other stuff... then import the file into a template that will be used for proffing purposes. 

     

                        -- *****************************
                        --        SAVE QUARK DOC AS EPS
                        -- *****************************
                        tell application "QuarkXPress"
                            activate
                            open file (filePath & ":" & fileName) given «class KPRF»:yes, «class RMPF»:no
                           
                            tell document fileName
                                set «class visc» to "100%" -- This must be here for image size to be correct, save page uses view scale
                            end tell
                           
                            --save page 1 of document fileName in ((filePath & ":" & epsName) as alias) as "EPSF" EPS format Standard     EPS EPS data binary EPS OPI include images
                            save «class page» 1 of document fileName in (filePath & ":" & epsName) as "EPSF" given «class PEPS»:«constant PEPSSEPS», «class DEPS»:«constant DEPSBINE», «class OEPS»:«constant OEPSINCE»
                            -- save page 1 of document fileName in file (filePath & ":" & epsName) EPS data binary EPS OPI include     images
                            -- save page 1 of document 1 in alias ("Graphics Station J:junk" as string as alias) as "EPSF" EPS format     Standard EPS EPS data binary EPS OPI include images
                           
                            close document fileName saving no
                        end tell -- application QuarkXPress       

    ----------------------------------------------------------------------------------

    //////////////////////////////// much later in the script ////////////////////////////

    ----------------------------------------------------------------------------------

                        -- ********************************************
                        --        OPEN TEMPLATE DOC AND IMPORT EPS FILE
                        -- ********************************************
                        open file (ADPATH & ":" & ADFILE) given «class KPRF»:yes, «class RMPF»:no
                        tell document ADFILE
                            set «class visc» to «constant VSCLFPWN»
                           
                            -- Set units to points because image dimensions seem to always be in points
                            set «class VMEA» to «constant measUPNT»
                            set «class HMEA» to «constant measUPNT»
                           
                            --make picture box at beginning with properties {color:"none"}
                            make «class PICB» at beginning
                            set boundsBuf to ((bounds of «class page» 1) as list)
                            -- commenting out because it throws a "can't convert to unicode text" error
                            --set px0 to my makeNum((item 2 of boundsBuf) as text)
                            --set py0 to my makeNum((item 1 of boundsBuf) as text)
                            --set px1 to my makeNum((item 4 of boundsBuf) as text)
                            --set py1 to my makeNum((item 3 of boundsBuf) as text)
                            set px0 to ((item 2 of boundsBuf) as number)
                            set py0 to ((item 1 of boundsBuf) as number)
                            set px1 to ((item 4 of boundsBuf) as number)
                            set py1 to ((item 3 of boundsBuf) as number)
                            set pageWidth to (px1 - px0)
                            set pageHeight to (py1 - py0)
                           
                            tell «class page» 1
                                tell «class PICB» 1
                                    set «class IMAG» 1 to (filePath & ":" & epsName) as alias
                                   
                                    -- ********************************************
                                    --        CENTER IMAGE ON PAGE
                                    -- ********************************************
                                    set boundsBuf to bounds of «class IMAG» 1
                                    -- commenting out because it throws a "can't convert to unicode text" error
                                    --set y0 to my makeNum((item 2 of boundsBuf) as text)
                                    --set x0 to my makeNum((item 1 of boundsBuf) as text)
                                    --set y1 to my makeNum((item 4 of boundsBuf) as text)
                                    --set x1 to my makeNum((item 3 of boundsBuf) as text)
                                    set y0 to ((item 2 of boundsBuf) as number)
                                    set x0 to ((item 1 of boundsBuf) as number)
                                    set y1 to ((item 4 of boundsBuf) as number)
                                    set x1 to ((item 3 of boundsBuf) as number)
                                    set imageWidth to (x1 - x0)
                                    set imageHeight to (y1 - y0)
                                   
                                   
                                    set cx0 to (pageWidth / 2 - imageWidth / 2)
                                    set cy0 to (pageHeight / 2 - imageHeight / 2)
                                    set cx1 to (cx0 + imageWidth)
                                    set cy1 to (cy0 + imageHeight)
                                   
                                   
                                    set cx0 to ((cx0 as text) & " pt")
                                    set cx1 to ((cx1 as text) & " pt")
                                    set cy0 to ((cy0 as text) & " pt")
                                    set cy1 to ((cy1 as text) & " pt")
                                    --display dialog "cx0=" & cx0 & "cy0=" & cy0 & "cx1=" & cx1 & "cy1=" & cy1
                                    set bounds to {cy0, cx0, cy1, cx1}
                                   
                                end tell -- picture box
                               
                                -- ********************************************
                                --        PLACE TEXT BOX WITH PAGE INFO
                                -- ********************************************
                               
                                make «class TXTB» at beginning with properties {bounds:{"9.75\"", "0.5\"", "10.375\"", "4.625\""}}
                                --set propName to "Name Of Property:"
                                set adNumber to (text items 2 through (length of fileName) of fileName) & "PROOF"
                                set timeStamp to ((current date) as text)
                                set stringBuf to "Ad Number: " & adNumber & (ASCII character 13) & ¬
                                    timeStamp & " " & (ASCII character 13) & "Artist: " & usrName
                                tell text flow 1 of «class TXTB» 1
                                    set contents of it to stringBuf
                                    set font to "Times"
                                end tell
                               
                            end tell -- page
                           
                        end tell -- document ADFILE
                    end tell -- application QuarkXPress
                   
                end repeat --end loop file list
               
            end tell -- application Finder
           
        on error errMsg number errNum
            set errMsg to "AdToEPS" & errMsg
            tell ASUtils
                get errorHandler(errMsg, errNum)
            end tell
        end try
     

    java developer who drew the short straw, now maintaining applescripts :)
  • 04-30-2009 1:12 AM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 553

    Re: Updating script to support QuarkXPress 8 from 7

     

    Hi, kind of hard to know where to start here without knowing what isn't working. From your post, the only obvious thing wrong is the items which are showing the raw class codes instead of the proper values you should see in the compiled script. I can't explain that from a technical standpoint, but I know it may relate to running multiple versions, and possibly Script Editor having an incompatible dictionary in memory.

    I'd suggest starting by seeing if the script will compile properly if you bring it in as clean text. Try to quit all versions of XPress and Script Editor, then launch XPress 7. Open Script Editor, and open your old script. Confirm it displays properly when compiled, and then copy the whole script and paste it into a TextEdit document. Then quit QXP7 and Script Editor.

    Now launch XPress 8, then launch Script Editor. Make a new script document, and paste in the text version of the script, then compile. Do you still get the substituted display as shown in your posting here, or do you see proper values from the XPress script dictionary?

    If this method gives you a script that compiles correctly for XPress 8, then you can try running the script, and focus on any specific statements that are not working for you. I have not done much scripting with XPress 8, but from what I have tried I don't think this script should need more than minor adjustments, if any.

  • 05-20-2009 10:54 AM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

     Ok, sorry had some time to revisit and here's where I am... 

     

    1. I'm having difficulties exporting a QuarkXPress document to EPS. I've tried saving the XPRJ file as an EPS file using "save document fileName in (filePath & ":" & epsName) as "EPS" " but the eps file created is not valid (meaning it can only be opened with Quark, not distiller). If I manually open the XPRJ file and do a > File > Export > Layout as EPS, I am able to distill with no problem. So I tried the following in applescript "export page 1 of document 1 in (filePath & ":" & epsName) as "EPSF"" and recieved and error stating that the document doesn't recognize the export command.

     

    2.  Further along in my scrip, I reopen the newly created EPS file to place it in a picture box. I'm now unable to open a new document to house the eps using the following... the error returned is "some object wasn't found"

    tell application "Finder"
        set diskName to name of startup disk as text
        set ADPATH to diskName
        set ADFILE to "ProofBlank"
    end tell

    tell application "QuarkXPress"
        open file (ADPATH & ":" & ADFILE) use doc prefs yes remap fonts no

     

    java developer who drew the short straw, now maintaining applescripts :)
  • 05-21-2009 4:18 AM In reply to

    • Emma
    • Top 10 Contributor
    • Joined on 07-07-2004
    • Leeds, UK
    • Posts 1,014

    Re: Updating script to support QuarkXPress 8 from 7

    1. The syntax for exporting as EPS seems to be a nightmare. But try searching this forum (i.e. the Applescripting one) for 'EPS' and you'll find several threads where people have worked out what works and what doesn't (I can't remember it all myself and just refer back if needed!).

     2. I suppose it couldn't be something as simple as the fact that having been unable to save it earlier, it now can't find it? Otherwise double check your file paths, save locations etc. Is filePath just the startup disk, or have you saved it in a folder somewhere?

  • 05-21-2009 11:42 PM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 553

    Re: Updating script to support QuarkXPress 8 from 7

     

    Saving as EPS requires specifying a page, otherwise you will be saving in XPress format (despite with an EPS extension.) Try running the following sample alone with your drive name, if it works you should be able to adapt for the script:

     

    tell application "QuarkXPress"
    set EPS_Path to "Mac HD:test.eps"
    tell document 1
    save page 1 in EPS_Path EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
    end tell
    end tell

     

    As for the startup disk name, I think I've seen a problem with that under the Finder, can't recall if it is an OS issue or what. But you may be able to work around it by changing the line getting the disk name to

    set diskName to (name of startup disk) of application "System Events"

    You should be able to use that line inside a tell Finder section if desired.

  • 05-22-2009 5:54 AM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

    Standard Additions has "Path to" which allows an easy & flexible way to supply paths to lots of popular folder locations.

    "as Unicode text" is safer when using Tiger OS and not required when using Leopard OS as eveything is Unicode text. 

    001    set Default_Path to (path to desktop folder as Unicode text)
    002   
    003    tell application "QuarkXPress"
    004         tell document 1
    005              save page 1 ¬
    006                   in file (Default_Path & "Page.eps") ¬
    007                   include preview true ¬
    008                   EPS format Mac color ¬
    009                   EPS data binary EPS ¬
    010                   bleed 0 ¬
    011                   scale 100 ¬
    012                   without transparent page
    013         end tell
    014    end tell
     

  • 05-22-2009 9:21 AM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

    JRS:
     

    Saving as EPS requires specifying a page, otherwise you will be saving in XPress format (despite with an EPS extension.) Try running the following sample alone with your drive name, if it works you should be able to adapt for the script:

     

     

    tell application "QuarkXPress"
    set EPS_Path to "Mac HD:test.eps"
    tell document 1
    save page 1 in EPS_Path EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
    end tell
    end tell

     

    As for the startup disk name, I think I've seen a problem with that under the Finder, can't recall if it is an OS issue or what. But you may be able to work around it by changing the line getting the disk name to

    set diskName to (name of startup disk) of application "System Events"

    You should be able to use that line inside a tell Finder section if desired.


     ah ok great thanks

    that was in fact the symtom I was having... when trying to open the eps file it was being recognized as an XPRJ file. Unfortunately I've been unable to save the page getting the error "class page doesn't understand the save message" tried the following variations...

    1. 

    tell document 1
    save page 1 in (filePath & ":" & epsName) EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
    end tell

    2.

    save page 1 of document 1 in (filePath & ":" & epsName) EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page

     3. 

    save page in (filePath & ":" & epsName) EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page

     

     

    java developer who drew the short straw, now maintaining applescripts :)
  • 05-22-2009 9:50 AM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

    after the first word "in" in all3 cases try adding the word "file" as shown above
  • 05-22-2009 12:25 PM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 553

    Re: Updating script to support QuarkXPress 8 from 7

     

    I saw that page 1 can't understand message when I first tried my simple script, but that was after running your sample code, so the open document in XPress was already one that had been saved as an "EPS", and I think that was the cause somehow.

    When I made a new document the sample script above worked fine, so you might see if that was the case here as well. Since I forgot to mention, I ran that script successfully with XPress 8.01 on OS X 10.4.11.

    I think larsen67 hit on the problem with the disk name; you need path to startup disk, not name of startup disk. By default that returns an alias, or if you get it as text or string it will return the format you wanted.

  • 05-22-2009 12:47 PM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

     still no such luck, tried the following and still get the class doesn't recognize the save command

     

        tell document 1
                                save current page in file (filePath & ":" & epsName) EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
                            end tell
                           
    save page 1 of document 1 in file (filePath & ":" & epsName) EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
                           
    save document fileName in file (filePath & ":" & epsName) as "EPSF" EPS format Standard EPS EPS data binary EPS scale 100
                           

    java developer who drew the short straw, now maintaining applescripts :)
  • 05-22-2009 12:50 PM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

    JRS:
     

    I saw that page 1 can't understand message when I first tried my simple script, but that was after running your sample code, so the open document in XPress was already one that had been saved as an "EPS", and I think that was the cause somehow.

    When I made a new document the sample script above worked fine, so you might see if that was the case here as well. Since I forgot to mention, I ran that script successfully with XPress 8.01 on OS X 10.4.11.

    I think larsen67 hit on the problem with the disk name; you need path to startup disk, not name of startup disk. By default that returns an alias, or if you get it as text or string it will return the format you wanted.

     

     

    Yes larsen67 was correct regarding diskname (thanks for that too btw larsen67) but unfortunately I'm still not able to save a page, I wonder if it's because I'm using a page element when calling page 1 of document 1 instead of the page object???

    java developer who drew the short straw, now maintaining applescripts :)
  • 05-22-2009 1:11 PM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

     to simplify a bit, I've liberated the offending code and am trying to get just the save piece to work. Here's the whole script now....

     

    tell application "QuarkXPress"
        activate
        open file "somepath"
       
        tell document 1
            save page 1 in file "somepath&".eps" EPS format Standard EPS EPS data ASCII EPS scale 100 with transparent page
        end tell
       
    end tell

     

    The original quark doc is opened correctly but when saving, I still get the same err

    java developer who drew the short straw, now maintaining applescripts :)
  • 05-22-2009 2:19 PM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 553

    Re: Updating script to support QuarkXPress 8 from 7

     

    Sorry, I think you've stumped me, that code works fine here, with or without the word file. About the only possibilities I see now are that you need to quit and relaunch Script Editor due to having some conflicting dictionary definition in memory, or a second version of XPress running, or else you have a non-core XTension that is affecting the behavior. (I have the QPS XTensions loaded, but no other non-standard XPress 8 ones.) Otherwise, I can't think what else to suggest.

  • 05-23-2009 6:55 AM In reply to

    Re: Updating script to support QuarkXPress 8 from 7

    Unoriginal, this can't be your full script as no where have you assinged the variable "somepath" this does not even compile for me in Script Editor. You have the "&" opperator inside the quotes so it is NOT an oppperator but part of a string that won't work because of the unslashed quote. I have no idea where "Standard" came from as a format (but then I am using 6.5 on Leopard) format options look like this: [Mac black and white/Mac color/Mac DCS/Mac DCS2/PC black and white/PC color/PC DCS/PC DCS2]

    Give this a try and see how you go on:

    001    set Default_Path to (path to desktop folder as Unicode text) -- This is a HFS file path as string
    002    set Quark_File to (choose file with prompt "Where is a Quark File?") -- This returns file alias
    003    
    004    tell application "QuarkXPress"
    005         open Quark_File -- Open using the alias specifier
    006         tell document 1
    007              set Doc_Name to name -- This is string
    008              save page 1 ¬
    009                   in file (Default_Path & Doc_Name & ".eps") ¬
    010                   include preview true ¬
    011                   EPS format Mac color ¬
    012                   EPS data ASCII EPS ¬
    013                   bleed 0 ¬
    014                   scale 100 ¬
    015                   without transparent page
    016              close saving yes
    017         end tell
    018    end tell

     

  • 05-23-2009 2:20 PM In reply to

    • JRS
    • Top 25 Contributor
    • Joined on 05-29-2004
    • Colorado
    • Posts 553

    Re: Updating script to support QuarkXPress 8 from 7

     

    Hi Larsen67, the XPress 8 dictionary has new options. EPS format options are now Standard EPS/Multiple File DCS/Single File DCS, and preview options are just none/TIFF/PICT. I obviously didn't actually run the bit of code with the & out of place, but the exact code I posted a couple of messages ago is valid and works with XPress 8, and I don't think the XPress 6 code will without adjustments.

    - John

Page 1 of 2 (19 items) 1 2 Next >
Powered by Community Server (Commercial Edition), by Telligent Systems