need to get this script to run on os9, quark 4.11

I found this code on this site and was elated to see that it could do a tedious task that I have to do weekly, namely which is to make a whole series of pdf files from quark documents from various sized documents.

I wanted to create a script that opens the file, gets the document size, sets the print set up paper size to the width and height of the document, and spits out a post script file to a specific folder on my hard drive.

This is almost what I need, and I believe I owe a debt of gratitude to PR9000 for getting me this far.

I’ve tried to run it, but it snags inseveral spots, namely

set paper width to newPaperWidth,

where it tells me I can’t do this

I’m a real newbie and would be grateful to anyone for their time and vast knowledge in solving this problem for me.

tell application “QuarkXPress”
activate

set myDoc to (document 1)

– determine new paper width, height and orientation
set paper_width to (page width of myDoc) as number
– display dialog paper_width
set paper_height to (page height of myDoc) as number
– display dialog paper_height
if paper_width > paper_height then
set newPaperHeight to (paper_width)
set newPaperWidth to (paper_height)
set myOrientation to landscape
else
set newPaperWidth to (paper_width)
set newPaperHeight to (paper_height)
set myOrientation to portrait
end if

tell print setup of myDoc
– print setup settings
set printer type to “Acrobat Distiller”

  set paper width to newPaperWidth 
  set paper height to newPaperHeight 
  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 myOrientation 
   
  -- print document settings 
  set seperation 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 tiling to off 
   
   
   
  -- print options settings 
  set flip horizontal to false 
  set flip vertical to false 
  set invert image to false 
  set print quality to normal 
  set full res rotated objects to false 
  set data format to binary data 

end tell
set myName to (name of document 1) as text
set thePath to path to the desktop as text
–display dialog thePath
set PS_file_path to (thePath & myName & “.ps”) as text
–display dialog PS_file_path
print front document PostScript file PS_file_path

end tell

This has nagged me for a long time. So I decided to beat it up. I used Quark 5, but I think it will work with Quark 4.1.1 as well. I’m not sure if this will pan out for all situations, but here’s my findings:

  1. Quark will NOT print fo file unless the file you wish to print to already exists!?!? :rolleyes:
  2. By creating a dummy file you can now print-to-disk as that dummy file.
  3. Quark will now write the PS file to a new name (ie: Drive:Path:FileName.ps will become Drive:Path:FileName.1.ps). If Drive:Path:FileName.1.ps exists, then Quark will write the output to Drive:Path:FileName.2.ps etc, incrementing the name as necessary.
  4. Do some copy/delete stuff with the Finder to get the Quark’s output to be your filename
  5. Quark 4 doesn’t allow setting of the “paper height” of the print setup only the “paper width”, I think it may be broke. So I can’t address that problem. But it does work in Quark 5.

So here’s what I came up with. (The code here requires the scripting addition Jon’s Commands)

	tell application "QuarkXPress" to set myName to (name of document 1) as text
	set thePath to path to the desktop as text
	set My_PS_file_path to (thePath & myName & ".ps") as text
	set Quarks_PS_file_path to (thePath & myName & ".1.ps") as string

-- write the dummy file
	set handle to open for access file (My_PS_file_path) with write permission
	set eof handle to 0
	write "HelloWorld" to handle
	close access handle

	tell application "QuarkXPress" to print document1 PostScript file (My_PS_file_path)
	
	tell application "Finder"
		repeat until file (My_PS_file_path) exists
			delay 1
		end repeat
		delay 1
		repeat while fileIsBusy (My_PS_file_path)
			delay 1
		end repeat
		copyFile (Quarks_PS_file_path) to (My_PS_file_path) with replacing
		delay 1
		deleteFile Quarks_PS_file_path
	end tell

This is a kludgie workaround, but I think it’ll solve your problem. Implement this in to your script and give it a try. If there is a better way, please let me know! And by all means, backup your files BEFORE you test this out!

Lemeeno
Jeff