Quark printing reference

I have made a script that goes through versioning layers of a Quark document (the same essential script I did for InDesign first-works like a charm). But I cannot get the print syntax called out right. It was very simple in InDesign, but Quark is elusive, not knowing how to talk to it. Right now, it gets to printing the first time and crashes. Applescript calls out an error: “QuarkXPress got an error: Connection is invalid.”

Here’s my printing call:

repeat with r from 1 to count of Layers_Switching
set visible of layer (item r of Layers_Switching) of document 1 to true
if r = 1 then --this allows user to set up the printing correctly first
print document 1 with print dialog --to be able to double-check the printing setup
else
print document 1 without print dialog --the the rest print
end if
set visible of layer (item r of Layers_Switching) of document 1 to false
end repeat

Earlier trials would just go through the layer switching and end, no printing would occur at all.

What would be the proper way to print from QuarkXPress?

Thanks for your help!

This might help you… I use this code to bypass the print dialog. This code is for printing with crop marks. You can modify it to print without crop marks if need be.


tell application "QuarkXPress"
	activate
	tell document 1
		set tool mode to drag mode
		set documentWidth to page width as number
		set documentHeight to page height as number
		set documentWidth to documentWidth + 1 -- Plus One Inch To Allow For Bleeds
		set documentHeight to documentHeight + 1 -- Plus One Inch To Allow For Bleeds
		set documentName to name
		
		-- Print Setup
		tell print setup
			-- Print Setup Settings 
			set printer type to "Generic Imagesetter" -- Change This To Your Postscript Print Description Name
			set paper size to "custom"
			set paper width to documentWidth
			set paper height to documentHeight
			set paper offset to 0
			set page gap to 0
			set reduce or enlarge to "100%"
			set fit in area to false
			set page position to center position
			set orientation to portrait
			
			-- Print Document Settings
			set separation to false
			set print spreads to false
			set include blank pages to false
			set print thumbnails to false
			set back to front to false
			set page sequence to all pages
			set registration marks to centered
			set registration marks offset to 12
			set bleed to ".5"
			set tiling to off
			set data format to binary data
			
			-- Print Output Settings
			set print colors to composite CMYK
			set print quality to normal
			set resolution to 2540
			set halftone screen to 400
		end tell
		
		-- Print Document To Postscript File
		set postscriptPath to ((path to desktop) as string) & documentName & ".ps"
	end tell
	print document 1 PostScript file {postscriptPath}
end tell

CarbonQuark

I use this to check for missing images and fonts in my printing automation scripts. It pauses/stops script if a mssing image or font is found (script does not detect missing fonts in placed graphics).


tell application "QuarkXPress"
	activate
	set missingFont to {}
	set missingImages to {}
	set fontList to font list of document 1
	set documentImages to properties of every image of document 1 as list
	try
		repeat with fontName in fontList
			if ID of fontName is less than 1 then set end of missingFont to name of fontName
		end repeat
	end try
	try
		repeat with documentImage in documentImages
			if missing of documentImage is true then
				set missingImage to file path of documentImage as text
				set missingImage to my getName(missingImage)
				set end of missingImages to missingImage
			end if
		end repeat
	end try
end tell

set alertIcon to 0

if missingFont is not {} then
	set text item delimiters to return
	set missingFont to text items of missingFont as string
	set text item delimiters to ""
	set missingFont to "These fonts are not loaded:" & return & missingFont
	set alertIcon to 1
else
	set missingFont to "All fonts are loaded!"
end if

if missingImages is not {} then
	set text item delimiters to return
	set missingImages to text items of missingImages as string
	set text item delimiters to ""
	set missingImages to "These images are missing:" & return & missingImages
	set alertIcon to 1
else
	set missingImages to "Images are all linked!"
end if

if alertIcon is 1 then
	tell application "QuarkXPress" to display dialog missingFont & return & return & missingImages & return & return & "Print anyway?" with icon stop buttons {"Cancel", "OK"} default button {"Cancel"}
end if

on getName(missingImage)
	set text item delimiters to ":"
	set missingImage to text item -1 of missingImage
	set text item delimiters to ""
	return missingImage
end getName

CarbonQuark

Thanks for useful info. It seems it is rather difficult to print out of QXP!

If I had a print style would it be OK to use that? And how would I indicate that in a script?

Also, if I wanted to print to the printer, not to a PS file, how would that be stated?

Thanks!

Hi T-Rex

Can’t help you with the print style but to just print to a printer is simple
something similar to this will work:

tell application "QuarkXPress""
	activate
	tell document 1
		tell print setup
			set printer type to "PS-NX5100 Color Server Ver 2.0"
			set paper size to "A4"
			set fit in area to true
		end tell
		print
	end tell
	close document 1 saving no
end tell

the only way to use printer style through quark is by using GUI scripting… blah

heres an alternate way to set print properties


tell application "QuarkXPress"
	activate
	tell document 1
		set properties of print setup to {printer type:"AdobePDF 7.0", tiling:off, back to front:false, bleed:0, collate:false, data format:binary data, fit in area:false, flip horizontal:false, flip vertical:false, halftone screen:"100", include blank pages:false, orientation:portrait, page position:center position, page sequence:all pages, paper size:"Custom", paper width:8.5, paper height:11, print colors:composite CMYK, print quality:normal, print spreads:false, print thumbnails:false, reduce or enlarge:"100%", resolution:300, separation:false}
	end tell
end tell

I am sorry everyone,

All of your ideas are great, but I still get no ability to print. My script just says: “QuarkXPress can’t get print setup”
and so, QXP just won’t print. Here’s the script I am on. Maybe it is throwing something bad into the mix.

tell application “QuarkXPress”
–first get the layer names
set the_layers to the name of layers of document 1
–try to get layers that will always print, user-defined
tell application “Finder”
set DefaultLayers to (choose from list the_layers with prompt “Choose the layers that will always print:” with multiple selections allowed)
if DefaultLayers is false then --that is, the user hit “Cancel”
display dialog “You have Canceled this script. You won’t get any printouts!”
return
end if
–extract the layers left - that were not chosen always print.3
set Layers_left to {}
repeat with x from 1 to count of the_layers
if item x of the_layers is not in DefaultLayers then
set Layers_left to Layers_left & item x of the_layers
end if
end repeat
–try to get layers that will NOT print. If there are none, the rest are run through.
set always_off_layers to (choose from list Layers_left with prompt “Choose any layers that will not print. If they will all print, just choose "Cancel"” with multiple selections allowed)
if always_off_layers is false then --that is, the user has no layers to keep off
set Layers_Switching to Layers_left
else
set Layers_Switching to {}
repeat with r from 1 to count of Layers_left
if item r of Layers_left is not in always_off_layers then
set Layers_Switching to Layers_Switching & item r of Layers_left
end if
end repeat
end if
end tell
activate
–turn off the always off layers
if always_off_layers is not false then
repeat with h from 1 to count of always_off_layers
set visible of layer (item h of always_off_layers) of document 1 to false
end repeat
end if
–Next, turn on those always-on layers!
repeat with x from 1 to count of DefaultLayers
set visible of layer (item x of DefaultLayers) of document 1 to true
end repeat
–Next step: turn off all alternating layers (toto_layers)
repeat with n from 1 to count of Layers_Switching
set visible of layer (item n of Layers_Switching) of document 1 to false
end repeat
–then turn on the first toto layer, print, turn off. Shuffle through the list
repeat with r from 1 to count of Layers_Switching
set visible of layer (item r of Layers_Switching) of document 1 to true
set properties of print setup to {printer type:“IKON500_50C-K_Print”, tiling:off, back to front:false, bleed:0.5, collate:false, data format:binary data, fit in area:false, flip horizontal:false, flip vertical:false, halftone screen:“85”, include blank pages:false, orientation:portrait, page position:center position, page sequence:all pages, paper size:“11x17”, paper width:11, paper height:17, print colors:composite CMYK, print quality:normal, print spreads:false, print thumbnails:false, reduce or enlarge:“100%”, resolution:600, separation:false}
print --all the print setup stuff goes here
set visible of layer (item r of Layers_Switching) of document 1 to false
end repeat
end tell

Thanks for your help!

Hi T-Rex

I’m not sure whether this helps cause i’m tinkering with this and don’t have a printer setup on this machine.
but i don’t think you want to set properties of print setup, ithink you can just tell print set up to whatever!!!
try this, like i say sorry if i’m way off!!

tell application "QuarkXPress Passport"
	--first get the layer names
	set the_layers to the name of layers of document 1
	--try to get layers that will always print, user-defined
	tell application "Finder"
		set DefaultLayers to (choose from list the_layers with prompt "Choose the layers that will always print:" with multiple selections allowed)
		if DefaultLayers is false then --that is, the user hit "Cancel"
			display dialog "You have Canceled this script. You won't get any printouts!"
			return
		end if
		--extract the layers left - that were not chosen always print.3
		set Layers_left to {}
		repeat with x from 1 to count of the_layers
			if item x of the_layers is not in DefaultLayers then
				set Layers_left to Layers_left & item x of the_layers
			end if
		end repeat
		--try to get layers that will NOT print. If there are none, the rest are run through.    
		set always_off_layers to (choose from list Layers_left with prompt "Choose any layers that will not print. If they will all print, just choose \"Cancel\"" with multiple selections allowed)
		if always_off_layers is false then --that is, the user has no layers to keep off
			set Layers_Switching to Layers_left
		else
			set Layers_Switching to {}
			repeat with r from 1 to count of Layers_left
				if item r of Layers_left is not in always_off_layers then
					set Layers_Switching to Layers_Switching & item r of Layers_left
				end if
			end repeat
		end if
	end tell
	activate
	--turn off the always off layers
	if always_off_layers is not false then
		repeat with h from 1 to count of always_off_layers
			set visible of layer (item h of always_off_layers) of document 1 to false
		end repeat
	end if
	--Next, turn on those always-on layers!
	repeat with x from 1 to count of DefaultLayers
		set visible of layer (item x of DefaultLayers) of document 1 to true
	end repeat
	--Next step: turn off all alternating layers (toto_layers)
	repeat with n from 1 to count of Layers_Switching
		set visible of layer (item n of Layers_Switching) of document 1 to false
	end repeat
	--then turn on the first toto layer, print, turn off. Shuffle through the list 
	repeat with r from 1 to count of Layers_Switching
		set visible of layer (item r of Layers_Switching) of document 1 to true
		tell document 1 to tell print setup to {printer type:"IKON500_50C-K_Print", tiling:off, back to front:false, bleed:0.5, collate:false, data format:binary data, fit in area:false, flip horizontal:false, flip vertical:false, halftone screen:"85", include blank pages:false, orientation:portrait, page position:center position, page sequence:all pages, paper size:"11x17", paper width:11, paper height:17, print colors:composite CMYK, print quality:normal, print spreads:false, print thumbnails:false, reduce or enlarge:"100%", resolution:600, separation:false}
		print --all the print setup stuff goes here
		set visible of layer (item r of Layers_Switching) of document 1 to false
	end repeat
end tell

you might want to tell document 1 as well this can help!!

pidge1

you said

I gave him that bit of code and I use it all the time hundreds of different clients and it works. my fear is that something else is wrong the bes thing to do and I had to do this when i made this code is to start with one parameter and get that to work and keep adding a parameter until you get an error then trouble shot that part

mm

Hi mm

My apologies i’m sure it works fine, i’ve never used it to print myself but if it works good, Like i said i don’t have a printer set up on this machine at the mo and it was that line that threw up the error.

Thanks pidge1,

I will have to check it out tomorrow at work. I have no copy of QuarkXPress running on OS X at home.
I will find out then, hopefully, whether there is any hope.

Model: Hm: 20" Intel Core 2 Duo iMac, 2Gb RAM Wk: 2Ghz Dual G5, 4.5 Gb RAM
AppleScript: AS 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Why involve finder then reactivate quark? no need or at least I don’t see any from a quick glance.

As far as I can tell, the problem with the original script was that you were telling “Print Setup” of “QuarkXPress”, instead of telling “Print Setup” of “Document 1” of “QuarkXPress”. The print setup must be inside the “tell Front Document” or “Tell document 1” block.

The error message you got is consistent with what happens when you are not directing the command to the right spot.

Browser: Safari 419.3
Operating System: Mac OS X (10.4)

No dice for me, may be a system problem… Any command to print to “Adobe PDF” crashes Quark. I have even tried to print to .ps files without luck…

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox 2.0.0.6
Operating System: Mac OS X (10.4)

what version of quark are you using again ?

mm

Quark XPress 6.52

ok then lets start with the basics

Does this work ?

set dt to path to desktop
set PSFile to "" & dt & "test.ps"
tell application "QuarkXPress"
	activate
	tell document 1
		set properties of print setup to {printer type:"AdobePDF 7.0"}
		print PostScript file PSFile
	end tell
end tell

mm

That actually does work… thanks!

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/Script Debugger 4
Browser: Firefox 2.0.0.6
Operating System: Mac OS X (10.4)

cool, so now all you have to do is start adding properties to the list :slight_smile:

Thanks! I will let you know if I run into any bumps along the trail.

Levon