does anyone know of an easy way to select all objects in a 1 page Quark document, and change the size of the document so that there is no extra space on the right and bottom of the page?
I don’t have much practice in Quark, so figured I’d ask if anyone has something that does this already
Weird, I just made something that does almost that same thing yesterday…
This assumes that the origin point of everything on your page is at x:0 y:0 (that’s how I was using it). It should be pretty simple to add in the “left of bounds” and “top of bounds” measurement if your objects will not be at 0,0.
Note that getting measument properties as Number or as Real will give you a number out to like 14 decimal places. That’s why there is the odd code in there to cut it back down to 3 decimal points.
Hope this gets you started at least.
Oh, I am in Quark 6.5 in OS 10.3.9. Some adjustments might be necessary in other versons of the OS or Quark.
tell application "QuarkXPress"
tell front document
set horizontal measure to inches
set vertical measure to inches
set AppleScript's text item delimiters to "."
set tool mode to drag mode
select every generic box
try --This traps the error if there is nothing on the page
set testing to properties of current box
on error
return
end try
set BoxWidthTemp to ((get width of bounds of current box) as real) as string
set BWCount to the count of characters in the second text item of BoxWidthTemp
if BWCount is greater than 3 then
set BWCount to 3
end if
set BoxWidth to ((the first text item of BoxWidthTemp as string) & "." & (text 1 thru BWCount of the second text item of BoxWidthTemp as string)) as number
set BoxHeightTemp to ((get height of bounds of current box) as real) as string
set BHCount to the count of characters in the second text item of BoxHeightTemp
if BHCount is greater than 3 then
set BHCount to 3
end if
set BoxHeight to ((the first text item of BoxHeightTemp as string) & "." & (text 1 thru BHCount of the second text item of BoxHeightTemp as string)) as number
set page width to BoxWidth
set page height to BoxHeight
end tell
end tell
Model: Mac G5 OS 10.3.9
Browser: Safari 312.3.1
Operating System: Mac OS X (10.3.9)
Matt-Boy, not sure you need all that code to get the height & width see this example for moving a picture box to add bleed and reposition the offset:
tell application "QuarkXPress"
try
set thisBox to current box
if box type of thisBox is not picture box type or (file type of image 1 of current box) is null then error
on error
error "A single picture box containing an image must be selected."
end try
set CurBox to object reference of current box
set origin of bounds of current box to {(-0.125), (-0.125)}
set boxW to ((width of bounds of current box) as inch units) as real
set boxH to ((height of bounds of current box) as inch units) as real
try
set (width of bounds of current box) to (boxW + 0.25) as inch units
end try
try
set (height of bounds of current box) to (boxH + 0.25) as inch units
end try
copy (coerce ((offset of image 1 of CurBox) as measurements point) to list) to {Xoffset, Yoffset}
set Xoffset to Xoffset as real
set Yoffset to Yoffset as real
try
set (offset of image 1 of CurBox) to {(Xoffset + 0.125), (Yoffset + 0.125)}
end try
end tell
I tweaked the script a bit to deal with the case that the selected group of all page items does not start at the 0,0 origins, just by temporarily adding a new box at the 0,0 before the select, and then deleting the box after the resize of the page
Now let me ask another question, is it possible in applescript to select and move the guides?
here’s my tweaked piece:
tell application "QuarkXPress"
tell front document
set horizontal measure to inches
set vertical measure to inches
set AppleScript's text item delimiters to "."
set tool mode to drag mode
set tempBox to make new picture box at beginning of page 1 with properties {bounds:{"0\"", "0\"", "0.25\"", "0.25\""}}
select every generic box
try --This traps the error if there is nothing on the page
set testing to properties of current box
on error
return
end try
set BoxWidthTemp to ((get width of bounds of current box) as real) as string
set BWCount to the count of characters in the second text item of BoxWidthTemp
if BWCount is greater than 3 then
set BWCount to 3
end if
set BoxWidth to ((the first text item of BoxWidthTemp as string) & "." & (text 1 thru BWCount of the second text item of BoxWidthTemp as string)) as number
set BoxHeightTemp to ((get height of bounds of current box) as real) as string
set BHCount to the count of characters in the second text item of BoxHeightTemp
if BHCount is greater than 3 then
set BHCount to 3
end if
set BoxHeight to ((the first text item of BoxHeightTemp as string) & "." & (text 1 thru BHCount of the second text item of BoxHeightTemp as string)) as number
set page width to BoxWidth
set page height to BoxHeight
delete tempBox
end tell
end tell
Bace, there’s no need to return the “box width” as text then process it back to a number using ASTID’s just ask for it in unit measure (a number) as real. Also if you use TID’s you should always reset afterwards so Im lead to beleive. here is your script simplified. “less is more”
tell application "QuarkXPress"
tell front document
set horizontal measure to inches
set vertical measure to inches
set tool mode to drag mode
set tempBox to make new picture box at beginning of page 1 with properties ¬
{bounds:{"0\"", "0\"", "0.25\"", "0.25\""}}
select every generic box
set BoxWidth to ((width of bounds of current box) as inch units) as real
set BoxHeight to ((height of bounds of current box) as inch units) as real
set page width to BoxWidth
set page height to BoxHeight
delete tempBox
end tell
end tell