Archiv der Kategorie: QuarkXPress

AppleScript: quarkxpress export all layouts as pdf

set TargetFolder to choose folder with prompt "Please choose the folder where to save the PDFs"
tell application "QuarkXPress"
    set MyProject to object reference of project 1
    tell MyProject
        repeat with i from 1 to count of layout space
            try
                export layout space i as "PDF" in ((TargetFolder as string) & name of layout space i & ".pdf")
            on error errMsg number errNum
            end try
        end repeat
    end tell
end tell

 

Rename and Relinking Images in QuarkXPress using AppleScript

set piclist to {}
set datlist to {}
global missed
set missed to {}
global dat, datlist, fileID
global textFile, available
set SourceFile to (choose file with prompt "Choose any quark document file...")
set textFile to (choose file with prompt "Choose text file ...")
set thepath to choose folder with prompt "Select folder to images in..."

tell application "Finder"
    if (file textFile exists) then
        set fileID to open for access textFile
        try
            set myfilecontents to read textFile
        on error
            display dialog "Check the text file..."
            return
        end try
        close access textFile
    end if
end tell

tell application "QuarkXPress"
    try
        open SourceFile use doc prefs yes remap fonts no do auto picture import no
    on error
        display dialog "check the file is already opened..."
        return
    end try

    tell document 1
        set pb to count of images

        set the Tmppara_list to every paragraph of myfilecontents
        repeat with i from 1 to count of paragraph of myfilecontents
            set Tmpln to i
            set Tmp_p1 to paragraph i of myfilecontents
            set TmpTextpara to Tmp_p1
            set prevTIDs to text item delimiters of AppleScript
            set text item delimiters of AppleScript to tab
            --set subject to text items of "A   B"
            set subject to text items of TmpTextpara
            set srcImg to item 1 of subject
            set desImg to item 2 of subject
            set text item delimiters of AppleScript to prevTIDs
            --end repeat
            set available to false
            repeat with i from 1 to count of images
                tell image i
                    set ImageBox to object reference of picture box 1
                    -- Copy writable properties
                    set Img_file_path to (file path) as text
                    if (Img_file_path ? "null" and Img_file_path ? "no disk file") then
                        set theImageName to my NameFromPath(Img_file_path)
                        if (theImageName ? "null" and theImageName ? "no disk file") then
                            if theImageName = srcImg then
                                set available to true
                                if not missing then
                                    set Img_angle to angle
                                    set Img_color to color
                                    set Img_greek_pictures to greek pictures
                                    set Img_image_trap to image trap
                                    set Img_invert_runaround to invert runaround
                                    --set Img_model to model
                                    set Img_name to name
                                    --set Img_negative to negative
                                    set Img_offset to offset
                                    set Img_scale to scale
                                    set Img_screen to screen
                                    set Img_screen_angle to screen angle
                                    set Img_screen_frequency to screen frequency
                                    set Img_screen_function to screen function
                                    set Img_shade to shade
                                    set Img_show_half_tone to show half tone
                                    set Img_skew to skew
                                    set Img_suppress_printing to suppress printing

                                    set Img_file_path to (file path) as text

                                    tell application "Finder"
                                        try
                                            set the datlist to files of thepath
                                        end try
                                        repeat with dat in datlist
                                            set fname to name of dat as string
                                            if fname = srcImg then
                                                set name of dat to desImg
                                                exit repeat
                                            end if
                                        end repeat
                                    end tell

                                    -- Get new image path
                                    set Img_file_path to (file path) as text
                                    set Img_file_path to my FindReplace(srcImg, desImg, Img_file_path)

                                    -- Re-import picture
                                    try
                                        set image 1 of ImageBox to file Img_file_path

                                        -- Re-set image properties
                                        tell image 1 of ImageBox
                                            set angle to Img_angle
                                            set color to name of Img_color
                                            set greek pictures to Img_greek_pictures
                                            set image trap to Img_image_trap
                                            set invert runaround to Img_invert_runaround
                                            --set model to Img_model
                                            set name to Img_name
                                            --set negative to Img_negative
                                            set offset to Img_offset
                                            set scale to Img_scale
                                            set screen to Img_screen
                                            set screen angle to Img_screen_angle
                                            try
                                                set screen frequency to Img_screen_frequency
                                            end try
                                            set screen function to Img_screen_function
                                            set shade to Img_shade
                                            set show half tone to Img_show_half_tone
                                            set skew to Img_skew
                                            set suppress printing to Img_suppress_printing
                                        end tell
                                    end try
                                end if
                                --else
                                --available = false
                            end if
                        end if
                    end if
                end tell

            end repeat
            if available = false then
                --display dialog srcImg
                set missed to missed & srcImg & return
            end if
        end repeat
    end tell
    save document 1
    --copy (choose file name default name "missed" & ".txt") as string to dataFile
    set SourceFile to SourceFile as string
    set dataFile to my FindReplace(".qxd", ".txt", SourceFile)
    try
        open for access file (dataFile) with write permission
        set eof of file (dataFile) to 0
        write item 1 of missed to file (dataFile) starting at 0
        repeat with i from 2 to length of missed
            try
                write item i of missed to file (dataFile)
            end try
        end repeat
        close access file (dataFile)
    on error errtext number errNum
        close access file (dataFile)
        tell application "QuarkXPress"
            activate
            --          display dialog errtext
            display dialog "No missed files..."
        end tell
    end try

    display dialog "completed"
    return
end tell

on FindReplace(FindWhat, ReplaceBy, ThisString)
    copy the text item delimiters to OldDelims
    set the text item delimiters to {FindWhat}
    set TempList to every text item of ThisString
    set the text item delimiters to {ReplaceBy}
    set NewString to TempList as text
    set the text item delimiters to OldDelims
    return NewString
end FindReplace

on NameFromPath(theImagePath)
    set theOffset to the offset of ":" in (the reverse of every character of theImagePath) as string
    set theImageName to (characters -(theOffset - 1) thru -1 of theImagePath) as string
    return theImageName
end NameFromPath

 

AppleScript: quarkxpress version droplet

(*
this in a older examples that i found in the web...
*)

on open fileList
  repeat with aDoc in fileList
    set filePath to aDoc as string
    if filePath ends with ":" then
    else
      set fileInfo to (info for file filePath)
      if file type of fileInfo is in {"XDOC", "XPRT"} then
        set docName to name of fileInfo
        set docVers to getVers(filePath)
        display dialog "Die Version des Dokuments " & docName & ": " & docVers & "." buttons "OK" default button 1 with icon 1
      end if
    end if
  end repeat
end open

on getVers(filePath)
  set versionClue to read file filePath for 12
  if versionClue contains "MM" then
    if versionClue ends with "?" then
      return "QuarkXPress 3.x (Mac)"
    else if versionClue ends with "A" then
      return "QuarkXPress 4.x (Mac)"
    else if versionClue ends with "B" then
      return "QuarkXPress 5.x (Mac)"
    else if versionClue ends with "C" then
      return "QuarkXPress 6.x (Mac)"
    else
      return "unbekannt (Mac)"
    end if
  else if versionClue contains "II" then
    set testChar to character 11 of versionClue
    if character 11 of versionClue = "?" then
      return "QuarkXPress 3.x (Windows)"
    else if character 11 of versionClue = "A" then
      return "QuarkXPress 4.x (Windows)"
    else if character 11 of versionClue = "B" then
      return "QuarkXPress 5.x (Windows)"
    else if character 11 of versionClue = "C" then
      return "QuarkXPress 6.x (Windows)"
    else
      return "unbekannt (Windows)"
    end if
  end if
end getVers

 

AppleScript: coerce – coercion of measurement units/values in quarkxpress

(*
qxp_coerce_01.applescript

Coerce the swiss army knife to convert measurement units.
*)

tell application "QuarkXPress Passport"
    tell document 1
        -- get bounds of generic box 1 of document 1.
        set {t, l, b, r} to bounds of generic box 1 as list

        -- for example t (top of bounds) would be coerced from
        -- vertical measurement ('FXVM') of QuarkXPress to a real number
        -- "8,467 mm" => 8.466644287109
        set t_as_real to coerce t to real

        -- for example l (left of bounds) would be coerced from
        -- horizontal measurement ('FXHM') of QuarkXPress to a string
        -- "20,461Â mm" => "20,461Â mm"
        set l_as_string to coerce l to string

    end tell
end tell

 

AppleScript: duplicate object in quarkxpress document

(*
qxp_duplicate_01.applescript

Duplicates an object.
*)

tell application "QuarkXPress Passport"
    -- Example 1: copy a object from layout space 1 to layout space 2
    tell project 1
        duplicate generic box 1 of layout space 1 to beginning of layout space 2
    end tell

    -- Example 2: copy a object from document 1 to document 2 
    duplicate generic box 1 of layout space 1 of project 1 to beginning of layout space 1 of project 2
end tell

 

AppleScript: make new text box in quarkxpress

(*
qxp_textbox_01.applescript

Creates a new text box

Properties are for example.
*)

tell application "QuarkXPress Passport"
    tell document 1
        make new text box at end with properties {class:text box, content:text content, box type:text box type, box shape:rectangular, first baseline minimum:ascent baseline, first baseline offset:"0 mm", runaround all sides:false, storage:"", text outset:{"0 pt", "0 pt", "0 pt", "0 pt"}, vertical justification:top justified, columns:1, gutter:"4,233 mm", name:"LOG_TEST_MODUL", shade:"20%", runaround:none runaround, color:color spec "Gelb", blend:{style:solid blend}, frame:{style:dotted line, inside trap:default, outside trap:default, gap color:null, gap opacity:"0%", gap shade:"0%", width:"6 pt", color:color spec "Magenta"}, bounds:{"0 mm", "0,269 mm", "183,132 mm", "47,269 mm"}}
        set text of last generic box to "Das ist ein kleiner Test"
        set style sheet of paragraph 1 of story 1 of last generic box to object reference of style spec "Normal"
        set character style of every text of last generic box whose it is "Das ist ein kleiner Test" to object reference of character spec "Normal"
    end tell
end tell

 

AppleScript: make new picture box in quarkxpress

(*
qxp_picturebox_01.applescript

Creates a new picture box

Properties are for example. It seems that not all properties are set properly when
a new picture box is generated.
Setting of image 1 of an picture box is some times a little bit buggy?
*)

tell application "QuarkXPress Passport"
    tell document 1
        make new picture box at end with properties {class:picture box, name:"m_bilder_TEST", content:picture content, box type:picture box type, box shape:rounded corner, bounds:{"0 mm", "48 mm", "112,818 mm", "188 mm"}, storage:"", blend:{style:solid blend}, frame:{style:sparsely dashed line, inside trap:default, outside trap:default, gap color:null, gap opacity:"0%", gap shade:"0%", width:"3 pt", color:color spec "Schwarz"}, text outset:{"0 pt", "0 pt", "6 pt", "0 pt"}, corner radius:"10 mm", shade:"20%", runaround:item runaround, color:color spec "Schwarz"}
        -- Fixing some stuff
        set properties of last generic box to {corner radius:"10 mm", bounds:{"0 mm", "48 mm", "112,818 mm", "188 mm"}}
        -- Image file path & Image Properties
        try
            set image 1 of last generic box to file ("BootHD:Users:csg:Desktop:export_preissuchmaschine.png")
            -- another way to set image 1
            --set image 1 of last generic box to ("BootHD:Users:csg:Desktop:export_preissuchmaschine.png" as alias)
            set properties of image 1 of last generic box to {actual bounds:{"-51,279 mm", "-38,459 mm", "268,111 mm", "274,461 mm"}, screen function:dot spot, offset:{"-38,459 mm", "-51,279 mm"}, scale:{"100%", "100%"}, invert runaround:false, show half tone:false, color:color spec "Schwarz"}
        end try
    end tell
end tell