Revisions to my quark to pdf script....

Hello,
OK-here is my second revision request of the day :wink:

I was using this script, but I would love to run it away from my desk… In order to make it more automated, I have to modify a few things.

1-I would like it in the beginning to ask where I want my PDF’s to go. Right now, I pick the folder every time it asks in the save as dialog box. It won’t hold my last location, so I have to pick it every time. Would rather find away to maybe make that decision in the beginning so it defaults to that same location.

2-I also, am just making these pdfs for my own back ups, so I don’t need the art work that is linked or the missing fonts (as the ones that might show up missing are not critical)…
So, with that said, as the Quark files open, I want it to bypass the missing font dialog box, or have the computer select the continue button as its choice.
Then, once it goes to export the PDF, I need it to not ask for the images that are missing, or, if that is not possible, at least have the computer choose OK from the button choices so again, it just bypasses it…

If I can get it to do those things, I can drag a bunch of files onto it and just walk away…and that would be great.
see script below thus far…
thanks!!!

on open fileList
	set deskPath to path to desktop as Unicode text
	tell application "Finder"
		repeat with i from 1 to count of items of fileList
			set theFile to item i of fileList
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return
			end if
			--Determine whether to use InDesign subroutines or Quark subroutines
			if (kind of theFile starts with "InDesign") then -- Process as InDesign
				set fileName to name of theFile
				my createInDesignPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			else -- Process as Quark
				my createQuarkPDF(theFile)
			end if
		end repeat
	end tell
end open


on createInDesignPDF(theFile, savePath, docName)
	tell application "Adobe InDesign CS3"
		open theFile
		set theProps to properties of PDF export preset "[Press Quality]"
		set newProps to {view PDF:true, crop marks:false, bleed marks:false, color bars:false, registration marks:false} & theProps
		set oldProps to properties of PDF export preferences
		set properties of PDF export preferences to newProps
		export front document format PDF type to (savePath & docName & ".pdf") without showing options
		set properties of PDF export preferences to oldProps
		close front document saving no
	end tell
end createInDesignPDF

on createQuarkPDF(theFile)
	tell application "QuarkXPress"
		open theFile
		activate application
	end tell
	tell application "System Events"
		tell process "QuarkXPress"
			click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			delay 5
			click button "Save" of window "Export as PDF"
			delay 5
		end tell
	end tell
	tell application "QuarkXPress"
		activate
		close front document saving no
	end tell
end createQuarkPDF

Set the folder path before the repeat loop, not in the save as dialog:

on open fileList
	set deskPath to path to desktop as Unicode text
	--instead, target a destination for the PDF output instead of the desktop
	set destinationPath to (choose folder) as Unicode text
	--then use it later when making PDFs out of all the files in fileList 
	--ie, in the handler 'my createInDesignPDF(theFile, deskPath, (text 1 thru -6 of fileName))'
	--use 'my createInDesignPDF(theFile, destinationPath, (text 1 thru -6 of fileName))'
	tell application "Finder"
		repeat with i from 1 to count of items of fileList
		--etc....

Change the open command for Quark (see applescript dictionary for all of Quark’s open command options):

tell application "QuarkXPress"
	open theFile do auto picture import no remap fonts no with Suppress All Warnings
	--etc....

The reason there might be the same warnings when exporting as PDF even when it’s opened that way is because you’re scripting the GUI which will give the same warnings as if you used the GUI to open the document instead of the applescript ‘open’ command, so it will probably report errors prior to exporting regardless of how the file was opened. While it’s possible to get around the problem by scripting a click on “OK” when it happens, that will be an error itself when it doesn’t happen (there are no missing fonts or links) and the script tries to take action on a GUI element that is not there.

I’m almost certain that using GUI scripting for making Quark export as PDF will not be usable for complete automation in other areas, such as choosing the PDF location and name. Essentially, to get Quark to make PDFs as automatically as InDesign, your handler for Quark needs to pass the same variables, ie.;

my createQuarkPDF(theFile, deskPath[or destinationPath], (text 1 thru -6 of fileName)))

It might work, such as having System Events type the fileName into after activating the export menu; but I’m not certain that you’ll be able to get the folder location as a Unicode string, such as deskPath or destinationPath, to work with navigating the export dialog. Previous solution of scripting Quark to print to a postscript file and then script Acrobat, Distiller, or the terminal command ‘pstopdf’ to convert that into a PDF file in the location and with a name set at the beginning of the script. It’s true - Quark does not have objects, commands, and properties for PDF export because Adobe provides it only in the Quark GUI of its Export as PDf menu item, while InDesign does have all the options of PDf export in applescript because Adobe provides both InDesign and Acrobat/Distiller with the same or similar applescript objects, commands, and properties.

However Quark does have all the objects, commands, and properties for printing as a postscript file which are nearly the same as the options for exporting as a PDF file, and a postscript file is easily converted to PDF (the PDF format is essentially portable postscript). That’s the only way to be certain a script can process Quark files unattended. The GUI scripting will always be subject to unforeseen conditions and errors that must be attended for each unique instance of the process.

Hey there,
Ok…I will start with this and see how far I get …
thanks!!!
barbara

Hello,
OK, the set destination isn’t working yet,but, I am looking at another script I got help with today so I am still working on that…
The suppress is working for the fonts…but I can’t get the images not to be missing…I removed the auto import from your suppress, but that didn’t help. I tried to add a click OK after the export area you will see, but that is incorrect and I am trying to research how I might get that dialog box to be noticed by the GUI I am trying to do…

here is what I have modified…any thoughts/??
thanks!!!
barb

on open fileList
	set deskPath to path to desktop as Unicode text
	--	set destinationPath to (choose folder) as Unicode text
	
	tell application "Finder"
		repeat with i from 1 to count of items of fileList
			set theFile to item i of fileList
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return
			end if
			--Determine whether to use InDesign subroutines or Quark subroutines
			if (kind of theFile starts with "InDesign") then -- Process as InDesign
				set fileName to name of theFile
				my createInDesignPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			else -- Process as Quark
				my createQuarkPDF(theFile)
			end if
		end repeat
	end tell
end open


on createInDesignPDF(theFile, savePath, docName)
	tell application "Adobe InDesign CS3"
		open theFile
		set theProps to properties of PDF export preset "[Press Quality]"
		set newProps to {view PDF:true, crop marks:false, bleed marks:false, color bars:false, registration marks:false} & theProps
		set oldProps to properties of PDF export preferences
		set properties of PDF export preferences to newProps
		export front document format PDF type to (savePath & docName & ".pdf") without showing options
		set properties of PDF export preferences to oldProps
		close front document saving no
	end tell
end createInDesignPDF

on createQuarkPDF(theFile)
	tell application "QuarkXPress"
		open theFile remap fonts no with Suppress All Warnings
		activate application
	end tell
	tell application "System Events"
		tell process "QuarkXPress"
			click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			delay 5
			click button "Save" of window "Export as PDF"
			delay 5
			--right now the delay allows us enough time to pick a folder...once I get a default folder, I can remove this
			click button "OK"
			--take this out if it doesn't work
		end tell
	end tell
	tell application "QuarkXPress"
		activate
		close front document saving no
	end tell
end createQuarkPDF

For the Quark open command import picture options, try “yes” to have pictures relink without the dialog (options are yes/no/ask). Won’t help if links are missing, tho. I’m also new to the “Suppress All Warnings” option of the open command; it might override ‘picture import yes’ option, tho intuitively it shouldn’t and only suppress warnings (like pictures missing).

I avoid GUI scripting. Too many variables and too little consistency in how applications expose elements and objects; some have names, others require an id number, and other oddness like position of window or applications being brought to front that dissuades me from pursuing automated GUI solutions.

For example, I can see a problem with the delay allowing a user to pick the folder to save the export - what if it takes longer than 5 seconds because of distraction, missing folder, or a slow response of the folder picker, or a slow response of parsing the Quark file for missing fonts and links, or when there is no warning dialog. Whatever the reason, if the “OK” GUI window isn’t ready for the script to click “OK” either because it hasn’t gotten there yet or doesn’t need to be there, then the script will do something it’s not supposed to do.

I see you plan to remove the delay once a default folder is selected the first time because you won’t have to, but you’ll have to stop the script from processing subsequent Quark files in order to change the script, yes? Maybe I’m not understanding the workflow.

Since you have to manually pick a folder, it makes sense to end the automation there and also manually click OK (if needed) and then manually close the Quark document after it’s done with it. Entering the file name into the export dialog could be done with GUI scripting, but only if it happens before a potential warning dialog that requires a click or enter keystroke. There’s the catch: if you script a click of an OK button, are you clicking a button that dismisses a warning dialog or the dialog that starts the export? With GUI scripting, those kinds of conditionals are hard to flush out. You’ll need for Quark to have a unique identifier for the type of OK button dialog it presents so the script can decide whether to dismiss it with OK so it can continue, or first enter the file name and then click OK to start exporting.

Hello,
I see what you are saying…although from the dictionary , I can’t figure it out, which is why I have chosen the GUI options. ;-(
The suppress warning will not work that you mentioned as there will be missing images, so that is not an option.

The workflow all in all is pretty simple…I have a bunch of Quark files that I want to archive in PDF format. The fonts that are critical will be loaded, anything else that pops up as missing is not worth worrying about…

Here is the worklfow: All I want to do, is drop a bunch of quark files (quark 7.0xx) on this applescript and have it make a PDF using the PDF setting I put in the script, bypassing any font or image warnings and save the pdf to the chosen folder closing the original without saving.

my script is probably overcomplicated, as it is also handling InDesign, but it is quark that matters the most…InDesign can be another day :wink:

Hopefully now that you know what I am trying to accomplish, it will make more sense :wink:
thanks for your help…
barbara

Indeed, if pictures are missing there’s no way to automate finding them; unless all pictures are just in a different place and a formula for relinking the new paths can be devised. I did that very thing a long time ago when I had to change the volume and folder name for the location of linked files of all our Quark docs - the script just read the old file path, replaced it with the new path, and relinked the image. If you’re dealing with Quark docs that have missing files, you have to find them. The ‘open picture import yes’ option will avoid the missing pictures dialog and re-link them if they can be found by Quark, such as when they’re in the same folder but both Quark doc and that folder are in a new location, or if the files aren’t missing but are merely modified. But if Quark can’t find them automatically then the user must find them for it.

A lot of the print setup properties can be read-in when opening, and then re-applied when switching the printer description to AdobePS for proper postscript file printing. You can also print to postscript file without changing any print setup properties and leave the printer description alone, tho it will rely on whatever printer description saved in the doc has the driver that will work with downloadable fonts and other things that need to be there in order to distill the postscript properly. Try printing to postscript file without changing any print setup and then set the PDF setting in Distiller with applescript when converting it into PDF. Might work okay, especially if you don’t need Quark to set special PDF properties in the postscript, just in the PDF (which can be done with applescript and Distiller like is done with InDesign sans postscript file).

ah…you might be on to something…I don’t need to put the pictures in, I want it to skip that entirely…They are a slugger image, and is not needed for the PDF…
I tried to put in your line “open picture import yes”
I put it …see below…but it is giving me an error… do you know where that line should go???

on createQuarkPDF(theFile)
	tell application "QuarkXPress"
		open theFile  remap fonts no with Suppress All Warnings
		open picture import yes	
		activate application
	end tell

thanks!
barbara

G’day Barbarapress

You can dismiss that widow with the “OK” button by testing for the button itself, like so…

Regards

Santa


on createQuarkPDF(theFile)
	tell application "QuarkXPress"
		open theFile remap fonts no with Suppress All Warnings
		activate application
	end tell
	tell application "System Events"
		tell process "QuarkXPress"
			click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			delay 5
			click button "Save" of window "Export as PDF"
			delay 5
			--right now the delay allows us enough time to pick a folder...once I get a default folder, I can remove this
			try
				if exists button "OK" of window 1 then
					click button "OK" of window 1
				end if
			end try
			--take this out if it doesn't work
		end tell
	end tell
	tell application "QuarkXPress"
		activate
		close front document saving no
	end tell
end createQuarkPDF

G’day again.

Seeing as you want to save to a particular folder, use this…



on createQuarkPDF(theFile)
	set deskPath to path to desktop as Unicode text
	set PathToFolder to POSIX path of (deskPath & "Barbaras folder:inside folder") -- Set this to path to your folder
	tell application "QuarkXPress"
		--open theFile remap fonts no with Suppress All Warnings
		activate application
	end tell
	tell application "QuarkXPress"
		activate
		tell application "System Events" to tell process "QuarkXPress"
			click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			keystroke "G" using {shift down, command down}
			delay 1
			keystroke PathToFolder
			delay 1
			click button "Go" of sheet 1 of window "Export as PDF"
			click button "Save" of window "Export as PDF"
			delay 1
		end tell
		activate
		tell application "System Events" to tell process "QuarkXPress"
			try
				if exists button "OK" of window 1 then
					click button "OK" of window 1
				end if
			end try
		end tell
		
	end tell
	tell application "QuarkXPress"
		activate
		close front document saving no
	end tell
end createQuarkPDF

Model: 2007 Al. iMac
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

Barbara, if these files are indeed Quark V7 then you will be using Quark 7 or 8 to process them then? If this is the case then you should look at your app dictionary as from V7 there has been a new class to export to PDF including job options location etc. Your handler for this could look very much like the InDesign one and be much more robust. If this is not the case and you are processing files with a version of earlier than this then printing the file to postscript then distilling it to a set location is far more robust.

This is how I suspect your script should look although I can’t test as I don’t have that app version.

on open fileList
	set deskPath to path to desktop as Unicode text
	tell application "Finder"
		repeat with i from 1 to count of items of fileList
			set theFile to item i of fileList
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return
			end if
			--Determine whether to use InDesign subroutines or Quark subroutines
			if (kind of theFile starts with "InDesign") then -- Process as InDesign
				set fileName to name of theFile
				my createInDesignPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			else -- Process as Quark
				my createQuarkPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			end if
		end repeat
	end tell
end open


on createInDesignPDF(theFile, savePath, docName)
	tell application "Adobe InDesign CS2"
		open theFile
		set theProps to properties of PDF export preset "[Press Quality]"
		set newProps to {view PDF:true, crop marks:false, bleed marks:false, color bars:false, registration marks:false} & theProps
		set oldProps to properties of PDF export preferences
		set properties of PDF export preferences to newProps
		export front document format PDF type to (savePath & docName & ".pdf") without showing options
		set properties of PDF export preferences to oldProps
		close front document saving no
	end tell
end createInDesignPDF

on createQuarkPDF(theFile, savePath, docName)
	tell application "QuarkXPress"
		activate
		-- The 1 line below is for my Quark V6.5 so remove it
		open theFile use doc prefs yes remap fonts no do auto picture import no reflow no
		-- Then uncomment these 2 lines below
		(*open theFile use doc prefs yes with Suppress All Warnings
		export front document in (savePath & docName & ".pdf") PDF output style "Print - Medium Quality/Medium Resolution"*)
		close front document saving no
	end tell
end createQuarkPDF

Hi Mark,
thanks for the follow up… I actually did find the export option in the library, but I didn’t see t anything about suppressing warnings ;-(
As far as the script you just sent, I am getting an error that says the “variable fileName has not been defined”???
any thoughts? thanks so much
barbara

When you open Quark’s dictionary (in Script Editor) just key “open” in the search field then click on the blue c circle it should list the options available to you from that command. You could C&P that here. I can’t really help you much as I don’t have that version of the app. “Suppress All Warnings” is not in version 6.5 You should be able to get a much cleaner solution than using GUI scripting now that you have the export command. You will need to know the name string of the options you want to use that are installed on your machine. Replace “Print - Medium Quality/Medium Resolution” with what ever your choice is.

As for your error you can either duplicate “set fileName to name of theFile” to a new line just above your Quark sub call or move the line to after “set theFile to item i of fileList” either or these should work. I overlooked that.

Hi Santa and Mark,

OK-here is what I have… see script below:
Mark, I tried to both duplicate the lane and move as you requested, but I am still getting the variable theFile is not defines ;-(
Until I can get past that, I can try what you sent Santa.
Do either of you have another place I can put that line to get it work?
thanks…
barbara

on open fileList
	set deskPath to path to desktop as Unicode text
	set destinationPath to (choose folder) as Unicode text
	
	tell application "Finder"
		repeat with i from 1 to count of items of fileList
			set fileName to name of theFile
			
			set theFile to item i of fielList
			set fileName to name of theFile
			
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return
			end if
			--Determine whether to use InDesign subroutines or Quark subroutines
			if (kind of theFile starts with "InDesign") then -- Process as InDesign
				my createInDesignPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			else -- Process as Quark
				my createQuarkPDF(theFile, deskPath, (text 1 thru -6 of fileName))
			end if
		end repeat
	end tell
end open


on createInDesignPDF(theFile, savePath, docName)
	tell application "Adobe InDesign CS3"
		open theFile
		set theProps to properties of PDF export preset "[Press Quality]"
		set newProps to {view PDF:true, crop marks:false, bleed marks:false, color bars:false, registration marks:false} & theProps
		set oldProps to properties of PDF export preferences
		set properties of PDF export preferences to newProps
		export front document format PDF type to (savePath & docName & ".pdf") without showing options
		set properties of PDF export preferences to oldProps
		close front document saving no
	end tell
end createInDesignPDF

on createQuarkPDF(theFile)
	set deskPath to path to desktop as Unicode text
	set PathToFolder to POSIX path of (deskPath & "Barbaras folder:inside folder") -- Set this to path to your folder
	tell application "QuarkXPress"
		--open theFile remap fonts no with Suppress All Warnings
		activate application
	end tell
	tell application "QuarkXPress"
		activate
		tell application "System Events" to tell process "QuarkXPress"
			click menu item "Layout as PDF..." of menu 1 of menu item "Export" of menu 1 of menu bar item "File" of menu bar 1
			keystroke "G" using {shift down, command down}
			delay 1
			keystroke PathToFolder
			delay 1
			click button "Go" of sheet 1 of window "Export as PDF"
			click button "Save" of window "Export as PDF"
			delay 1
		end tell
		activate
		tell application "System Events" to tell process "QuarkXPress"
			try
				if exists button "OK" of window 1 then
					click button "OK" of window 1
				end if
			end try
		end tell
		
	end tell
	tell application "QuarkXPress"
		activate
		close front document saving no
	end tell
end createQuarkPDF

Hey Stefen,
I did it that way too…
see below…-still no go… this is the spot…right???

tell application "Finder"
		repeat with i from 1 to count of items of fileList
			
			set theFile to item i of fielList
			set fileName to name of theFile
			
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return

fileList, not fielList

hey Stefen
I changed it, same message ;-(


	tell application "Finder"
		repeat with i from 1 to count of items of fileList
			
			set theFile to item i of filelList
			set fileName to name of theFile
			
			if not ((kind of theFile starts with "Quark") or (kind of theFile starts with "InDesign")) then
				display dialog "This file is not an InDesign or Quark document!" buttons "Skipping" default button "Skipping" with icon 0 giving up after 6
				return

:lol:

fileList (f i l e L i s t), not filelList (f i l e l L i s t)