Getting Quark script to work in OSX

Hi all, i know it’s getting a little anoying, but i really can’t get this to work in OSX. I searched the forum for hours and tried several solutions you came up with, but no success… :cry:

I have this script, i think lots of people are using this one, from Edward Misiuk http://homepage.mac.com/e_s_m/index_en.html. It works fabolous in OS 8.6 and Quark 4.11, but as you can guess, it doesn’t do a thing on my new G5, OS 10.3.2, Quark6.0.



property newName : ""
property DocumentPath : "Kiss:Dox:postscript_test::"

on run
	display dialog "Drag QuarkXPress documents" & return & "on me for creating PostScript from each page of them�" with icon stop
end run

on open _selection
	tell application "Finder" to �
		set _files to files of selection
	display dialog "Give a name to the postscriptfiles?" default answer "PS file"
	set newName to the text returned of result
	repeat with j from 1 to length of _files
		process_document(item j of _files)
	end repeat
end open

on process_document(processing_doc)
	tell application "QuarkXPress Passport"
		open processing_doc use doc prefs yes
		tell document 1
			set processing_pages to name of pages
			if class of processing_pages is not list then �
				set processing_pages to coerce processing_pages to list
			set doc_name to name
			set page_width to (page width as real) + 6 -- bleed*2 value
			tell print setup
				ignoring white space and case
					set adjust horizontal tile to false
					set back to front to false
					set bleed to 3.175
					set collate to false
					set data format to binary data
					set fit in area to false
					set flip horizontal to false
					set flip vertical to false
					set halftone screen to "175"
					set include blank pages to true
					set invert image to false
					set orientation to portrait
					set page gap to "0�mm"
					set page position to center horizontal
					set page sequence to all pages
					set paper offset to "0�mm"
					set paper width to "153 mm"
					set print colors as grays to true
					set print quality to rotate
					set print spreads to false
					set print thumbnails to false
					set printer type to "Generic B&W"
					set reduce or enlarge to 100
					set registration marks to centered
					set registration marks offset to "14,173�pt"
					set resolution to 2400
					set separation to false
					set tiling to off
				end ignoring
			end tell
			repeat with i from 1 to length of processing_pages
				set processing_page to item i of processing_pages
				show page processing_page
				set PS_file_path to coerce (DocumentPath & newName & processing_page) to string
				print page processing_page �
					copies 1 cover page no OPI include images �
					PostScript file PS_file_path
			end repeat
			close saving no
		end tell
	end tell
end process_document



Am i doing something wrong? Well I know i am, but i want to know WHAT :lol: Any help is more than welcome!

Thnx in advance!

Fuut

I don’t have QXP 6 to test this but right off the bat, this seems like a mistake:

There should probably only be one colon at the end of that path. Also, try adding some try blocks to the script returning the error and report back where the script encounters problems.

Jon

Thnx Jon, the double colon was a typing error, in my script the path is correct. I tried it with several try-blocks. Returning no errors…

When i drop my quark-file on it, it asks me to give a filename as it is supposed to do, and when i did that and click yes it just stops, no error is given, nothing. It looks like it just stops after this line:


tell application "Finder" to ¬
		set _files to files of selection
	display dialog "How should the new files be named?" default answer "PS file"

The rest of the code isn’t executed, it doesn’t even open Quark…I hope you can help me with this… :lol:

Grtz Fuut

What happens when you run this:

property newName : ""
property DocumentPath : "Kiss:Dox:postscript_test:"
property QXP_file_type : "XDOC"

on run
    open {choose file of type QXP_file_type with prompt "Locate a QXP document to make into PS files:"}
end run

on open the_files
    set newName to text returned of (display dialog "Give a name to the PostScript files?" default answer newName buttons {"Cancel", "OK"} default button 2 with icon 1)
    repeat with j from 1 to (count the_files)
        set the_file to item j of the_files
        if file type of (get info for the_file) = QXP_file_type then my process_document(the_file)
    end repeat
end open

on process_document(processing_doc)
    tell application "QuarkXPress"
        try
            open processing_doc use doc prefs yes
            tell document 1
                set doc_name to name
                set page_width to (page width as real) + 6 -- bleed*2 value 
                tell print setup
                    ignoring white space and case
                        set adjust horizontal tile to false
                        set back to front to false
                        set bleed to 3.175
                        set collate to false
                        set data format to binary data
                        set fit in area to false
                        set flip horizontal to false
                        set flip vertical to false
                        set halftone screen to "175"
                        set include blank pages to true
                        set invert image to false
                        set orientation to portrait
                        set page gap to "0?mm"
                        set page position to center horizontal
                        set page sequence to all pages
                        set paper offset to "0?mm"
                        set paper width to "153 mm"
                        set print colors as grays to true
                        --set print quality to rotate --this is not a constant on my machine
                        set print spreads to false
                        set print thumbnails to false
                        set printer type to "Generic B&W"
                        set reduce or enlarge to 100
                        set registration marks to centered
                        set registration marks offset to "14,173?pt"
                        set resolution to 2400
                        set separation to false
                        set tiling to off
                    end ignoring
                end tell
                set page_count to (count pages)
                repeat with i from 1 to (page_count)
                    show page i
                    set PS_file_path to (DocumentPath & newName & (my add_leading_zeros(i, page_count)) & ".ps") as string
                    print page i copies 1 cover page no OPI include images PostScript file PS_file_path
                end repeat
                close saving no
            end tell
        on error the_error
            try
                close document 1 saving no
            end try
            beep
            activate
            display dialog the_error buttons {"OK"} default button 1 with icon 0
            return
        end try
    end tell
end process_document

on add_leading_zeros(the_number, total_number)
    set {i, j, z} to {(count (total_number as string)), (count (the_number as string)), ""}
    repeat while j < i
        set {z, j} to {(z & "0"), (j + 1)}
    end repeat
    return {z, the_number} as string
end add_leading_zeros

Jon

I apologize if this isn’t what you’re looking for, but there might be something you can glean from the script I finally got to work last night.
i put the finished code in the “something missing from move command” thread.
I’m also creating Postscript files in Quark 6.0.

i’m at work right now, but i’ll take a look later if there is anything in your code that jumps out.
JA

Thnx guys…

Jon, there are strange things happening here…Your code does a little bit more than mine: it asks for the new filename, ok, than it begins to process in quark: than it throws an error that i can’t set the paperwidth to “153 mm”, so i commented that printproperty out; tried it again, and it begins to save the file as postscript, and once you think it should be finished Quark suddenly quits, starts up again with this error: " Quark Xpress got an error: Connection is invalid". And now the very strange part: when i drop a Quark 6.0- doc on the droplet it only asks for the filename and then just stops(like my script), and with a quark 4.11-doc(made on OS8.6 or OS9.2) it plays the scenario as explained above. :rolleyes: :frowning: I really don’t understand it…Can you please help me with this?!

Jageo, i’ll take a look at your script now, thnx!

Grtz, Fuut

Have you tried specifying the printer type. I have found that different PPDs allow different parameters to be set and will fail if you try to set a parameter that they don’t like. For example, the following script works find if the selceed PPD is “Generic PDF” but not if it’s “Acrobat Distiller” or “Adobe PDF.”

-- This droplet processes both files or folders of files dropped onto the applet
on open these_items
    
    
    set The_Path to choose folder with prompt "Please select the Distiller In folder."
    
    repeat with i from 1 to the count of these_items
        set this_item to (item i of these_items)
        set the item_info to info for this_item
        
        if folder of the item_info is true then
            process_folder(this_item, The_Path)
        else if (alias of the item_info is false) then
            my process_item(this_item, The_Path)
        end if
    end repeat
end open

-- this sub-routine processes folders
on process_folder(this_folder, The_Path)
    set these_items to list folder this_folder without invisibles
    repeat with i from 1 to the count of these_items
        set this_item to alias ((this_folder as text) & (item i of these_items))
        set the item_info to info for this_item
        if folder of the item_info is true then
            process_folder(this_item, The_Path)
        else if (alias of the item_info is false) then
            my process_item(this_item, The_Path)
        end if
    end repeat
end process_folder

-- this sub-routine prints the files
on process_item(this_item, The_Path)
    tell application "Finder"
        open item this_item
        try
            set File_Name to name of file this_item as text
        on error
            display dialog "Problem getting file name."
        end try
    end tell
    tell application "QuarkXPress Passport"
        activate
        tell print setup of document 1
            set printer type to "Generic PDF"
            set paper size to "Custom"
            set paper width to "4.27""
            set orientation to portrait
            set page position to center horizontal
            set print spreads to false
            set reduce or enlarge to "100%"
            set registration marks to centered
        end tell
        print document 1 PostScript file {(The_Path as string) & File_Name & ".ps"}
        close document 1 saving no
    end tell
end process_item

[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Gentlemen, thnx for your helpl so far!

Harges, you’re right about the selected PPD, the y are critical. If i select “Acrobat Distiller” i get this error: Can’t set <> of <> of document 1 of applicatioin “Quark Xpress” to “Acrobat Distiller” :cry: I get the same error with all other selected PPD’s, except for “Generic PDF”(like you said)…but when i DO select the “Generic PDF”, quark starts processing the postscripts but quark suddenly stops, returning 2 errors: one popup with “Connection is Invalid” and at the same time this one : “The program Quark Xpress suddenly stopped” with the question if i want to send a report to Apple. Pretty heavy error each time…quarks just quits and i’m getting the feeling i’m the only one with this particular problem.

More suggestions are more than welcome!!!

Thnx FUUT!!!

Hi:
I’ve tested both Fuut’s and Jonn8’s scripts with Quark Passport 6.1 in OS 10.3.2 with both Quark 4.1 and Quark 6 documents. Here’s what I found. This should come as no surprise.

Fuut Script
Both 6 and 4.1 files – script only gets as far as the “name PS file” and then nothing

Jonn8 Script
Q 6 file–same as with Fuut script
Q4.1–works fine with commenting out of page width, otherwise you get an error telling you you can’t set that (that’s the PPD problem).

I’ve altered my script to output each page of the document as a separate PS file. It seems to work fine with either Q4.1 or Q6 files. You can change the print setup settings according to your needs. I am using teh “Generic PDF” PPD in order to be able to set the page width. My script will ask you to find the Distiller “IN” folder and use that as the save-to path. That should be easy to change as well if you don’t want to be prompted to select a destination folder.

Let me know if this helps.

-- This droplet processes both files or folders of files dropped onto the applet 
on open these_items
    
    
    set The_Path to choose folder with prompt "Please select the Distiller In folder."
    
    repeat with i from 1 to the count of these_items
        set this_item to (item i of these_items)
        set the item_info to info for this_item
        
        if folder of the item_info is true then
            process_folder(this_item, The_Path)
        else if (alias of the item_info is false) then
            my process_item(this_item, The_Path)
        end if
    end repeat
end open

-- this sub-routine processes folders 
on process_folder(this_folder, The_Path)
    set these_items to list folder this_folder without invisibles
    repeat with i from 1 to the count of these_items
        set this_item to alias ((this_folder as text) & (item i of these_items))
        set the item_info to info for this_item
        if folder of the item_info is true then
            process_folder(this_item, The_Path)
        else if (alias of the item_info is false) then
            my process_item(this_item, The_Path)
        end if
    end repeat
end process_folder

-- this sub-routine prints the files 
on process_item(this_item, The_Path)
    tell application "Finder"
        open item this_item
        try
            set File_Name to name of file this_item as text
        on error
            display dialog "Problem getting file name."
        end try
    end tell
    tell application "QuarkXPress Passport"
        activate
        tell print setup of document 1
            set printer type to "Generic PDF"
            set paper size to "Custom"
            set paper width to "4.27""
            set orientation to portrait
            set page position to center horizontal
            set print spreads to false
            set reduce or enlarge to "100%"
            set registration marks to centered
        end tell
        repeat with i from 1 to count of pages of document 1
            set PS_file_path to ((The_Path as string) & File_Name & "_" & i & ".ps") as string
            print page i of document 1 PostScript file PS_file_path
        end repeat
        close document 1 saving no
    end tell
end process_item

Thnx! :lol:

But unfortunately Quark still doesn’t like what i’m doing…

I used your code, using a quarkdoc with 4 pages, so the output should be 4 postscripts. Well I get one, with a very light doc(no color), maybe two(only the first pages), and then quark sudddenly stops, giving me the same errors as before. If I use a quarkdoc with only one page, quark just stops before it is able to print/save the postscript.

I tried the script on another machine, but with OS10.3.2 and QXP6.0, and i get the same errors. Both machines have the same copy of Quark, can it be a printer(driver)problem?! If that is the case, then why does it print one or two pages and then quits…if it’s a printerproblem it shouldn’t make a postscriipt-file at all, right?

And what the %*# means “Connection is invalid”…WHAT connection, connection WITH what?!

I’m getting desperate, i tried everything…you’re my only hope! I appreciate your help very much, thank you for that!

ps. you’re using the “Generic PDF” PPD, i can’t choose that one, and i can’t find that driver on inet, i used every driver i have(Acrobat Distiller, Brisque 22 DF, Adobe PDF, Generic B&W, Generic Imagesetter etc etc), with all the other printerconfiguration-options commented out(so only the "set printer type to “…” is set), always the same stupid error :cry:

ps2. when i run the script and i get the error, and click “Edit”, the script pops up, but it doesn’t select a line, so i know where the problem occurs…is this normal?

hmm…look what i found here:

The error i’m getting all the time is as prompted above, not a syntax-problem…maybe interesting…BUT, that doesn’t solves my problem…

ps. is it possible to run QXP 4.11 on OS10.3.2?

Man that’s weird. Couple of things come to mind.

You won’t find the “Generic PDF” PPD by using the pull-down menu in the Print Set-up window in Quark. You’ll see “Generic Color,” “Generic B&W,” and “Generic Imagesetter” but not “Generic PDF.” I don’t know why. You can, however, see it by getting the Print Setup Properties. Then you’ll see a list like this:

printer type list: {“Generic B&W”, “Generic Color”, “Generic Imagesetter”, “Generic PDF”, “Acrobat Distiller”, “Adobe PDF”, “GCC Elite XL 20/600”, “HP Color LaserJet 8550”, “HP LaserJet 6P/6MP”}

The actual file is called “GPDFPPD.” It’s probably in your /Users/username/Library/Preferences/Quark/QuarkXPress 6.0/PPD folder and it automatically installs when you install Quark (I think).

However, I still have no idea if that has anything to do with this. You can run Quark 4.1 in classic. In fact, you could jsut start up in OS 9.2 and use Q 4.1 and the classic version of the applescript that worked in the past. That sounds a little like giving up though, huh?

By the way, how can you run the same copy of Quark 6 on two different machines? Don’t you have to go through that stupid activation nonsense with the 800 digit activation key. I thought that system wouln’t let you install a copy on two different Macs.

One final thing that IO don’t know if someone mentioned before. Quark has posted both a 6.1 updater and a patch that fixes some sort of PDF making problem. Maybe one or both of these will help. Good luck.