QuarkXPress: add a tint panel to every page

A bit of background: I work for a commercial printer. Often, the jobs we print need sealing. This means that a sealer plate has to be created. It fits nicely into our Kodak Brisque workflow to have the sealer added to every page of the QuarkXPress document on a separate layer, so I wrote a script to do just that.

I’m very new to AppleScripting and a lot of the commands in this script came from various sources on the web, but mostly from people here who have been good enough to post their code, so I thought I’d reciprocate. Hope someone else finds it helpful.

-- Script to add a sealer to every page in the QuarkXPress document.
-- Creates a new colour called "sealer" with 12% or each of CMYK (same values as V1_Varnish on Brisque)
-- Creates a new layer called "sealer" to enable sealers to be switched on and off
-- Draws a box 6mm bigger than page (3mm bleed all around), filled with "sealer" colour.

-- DOESN'T CHECK TO SEE IF THE LAYER OR COLOUR ALREADY EXIST!

-- Kalessin, 6 July 2006

tell application "QuarkXPress Passport"
	activate
	if not (front document exists) then return -- make sure a document is open
	set sName to "sealer"
	-- if (exists (color spec whose name is sName)) then return -- this doesn't work (to be fixed in a later version)
	-- if (layer sName exists) then return -- this doesn't work (to be fixed in a later version)
	tell document 1
		set thePageWidth to the (width of the bounds of page 1 as real)
		set thePageHeight to the (height of the bounds of page 1 as real)
		set theOldPageOrSpreadRulerChoice to the item spread coords -- keep this value to reset afterwards
		set the item spread coords to false -- page co-ordinates, not spread
		set theOldRulerOrigin to the page rule origin -- keep this value to reset afterwards
		set the page rule origin to {0, 0} -- reset default ruler position
		make new layer at beginning with properties {name:"sealer"} -- new layer goes above other layers
		make new color spec at beginning with properties {name:"sealer", CMYK color value:{7864, 7864, 7864, 7864}} -- CMYK values of 12% each
		try
			tell every page
				make new generic box at beginning with properties ¬
					{bounds:{-3, -3, thePageHeight + 3, thePageWidth + 3}, color:"sealer", shade:"80", runaround:none runaround, layername:"sealer", background trap:overprint} -- includes 3mm bleed all around the page
			end tell
		on error
			display dialog "An error occurred." buttons {"OK"} default button 1
		end try
		set the page rule origin to theOldRulerOrigin -- revert to original settings
		set the item spread coords to theOldPageOrSpreadRulerChoice -- revert to original settings
	end tell
end tell