Modifying quark export PDF script

Discuss AppleScripting for QuarkXPress 10, 9 & 8 (and before)
Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 19 Sep 2013, 22:53

Hi I have used the script below created by Jean-Marie Schwartz, great script. I have modified it by using my own print style in place of the original but I am experincing some issue when I run it the final pdf which is making a single pdf from a spread which is correct. But it is taking the spread size instead of just the page size so I end up with a pdf with an a5 page sitting left of a spread size document.
Also is it possible to point it to a folder on the desktop called: Final print pdf
As well as the above is it possible to instead having it as a drag and drop application can I have it as an application you run with quark page open? I have ascript listed bottom that does that but i am unable to get the bits I want to work into the Jean-Marie Schwartz script.

Any help with this is much appriciated as I have little to no knowledge on applescripts and am trying to learn.

Jean-Marie Schwartz script

-----------------------------------------------------------------------------------------------------------------------

on open fileList
set NumberOfFiles to (number of items in fileList) as integer
repeat with oneFile in fileList
tell application "QuarkXPress"
activate
set FileAlias to ((oneFile as text) & ".pdf") as text
open oneFile use doc prefs "yes" with Suppress All Warnings
export document 1 in FileAlias PDF output style "Polstar pdf/X-1a new style"
close document 1 saving "no"
--beep 1
end tell
end repeat
activate
beep 2
if NumberOfFiles = 1 then
display dialog "1 file has been processed." buttons "OK" default button 1 giving up after 2
else
display dialog (NumberOfFiles as text) & " files have been processed." buttons "OK" default button 1 giving up after 2
end if
end open
-----------------------------------------------------------------------------------------------------------------------
Run with quark doc open script

-----------------------------------------------------------------------------------------------------------------------

tell application "QuarkXPress"
activate
end tell
try
tell application "System Events"
tell process "QuarkXPress"
tell menu bar 1
tell menu bar item "File"
tell menu "File"
tell menu item "Export"
tell menu "Export"
click menu item "Layout as PDF..."
end tell
end tell
end tell
end tell
end tell
delay 1
tell window "Export as PDF"
click button "Save"

end tell
end tell
end tell
on error
display dialog "UI not working"
end try

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

Modifying quark export PDF script

Post by Jean-Marie Schwartz » 20 Sep 2013, 00:39

Backbone22 wrote: it is taking the spread size instead of just the page size so I end up with a pdf with an a5 page sitting left of a spread size document.
Hi! COuld you send me the settings for the PDF Output? Is the PDF correctly output outside of any script? I mean is everything OK when outputting a doc straight from within Quark>Export as PDF? Also what version are you on (both QuarkXPress and OS)?
Also is it possible to point it to a folder on the desktop called: Final print pdf
Sure it is. We'd have to create that folder if not existing and direct the PDFs into there (that means editing FileAlias variable).
As well as the above is it possible to instead having it as a drag and drop application can I have it as an application you run with quark page open? I have ascript listed bottom that does that but i am unable to get the bits I want to work into the Jean-Marie Schwartz script.
Oh! forget about the second code! You should be OK with sth like this:
tell application "QuarkXPress"
activate
my CreateFolderOnDesktop("Tests PDF")
set FilePath to file path of document 1 as string
set {FolderPath, DocName} to my SortFilePath(FilePath)
[b]set FileAlias [b]to (([b]path to desktop as string) & "Tests PDF:" & DocName & ".pdf") [b]as string
[b]try
[b]export document 1 as "PDF" in FileAlias PDF output style "Polstar pdf/X-1a new style"
[b]on [b]error
[b]my Bip(3)
[b]return
[b]end [b]try
[b]my Bip(2)
--close document 1 saving "no"
[b]end [b]tell


[b]on Bip(x)
beep xend Bipon SortFilePath(ThePath)set TheFolderPath to (do shell script "dirname " & quoted form of POSIX path of ThePath)set TheDocName to (do shell script "basename " & quoted form of POSIX path of ThePath)return {TheFolderPath, TheDocName}end SortFilePathon CreateFolderOnDesktop(WithThisName)trydo shell script ("cd ~/Desktop ; mkdir " & quoted form of WithThisName)end tryend CreateFolderOnDesktop

Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 20 Sep 2013, 01:04

Thanks Jean-Marie for your help. The pdf is output correctly using the print style outside of any script.
I am running quark 7.5 on OSX 10.8.4
I want o send you the print style from quark. but how do i send this through this forum there is no atatchment button?
Also I think there is text missing from your post as after (You should be OK withsth like this:) there is nothing.

Thanks for your help[:D]

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

Modifying quark export PDF script

Post by Jean-Marie Schwartz » 20 Sep 2013, 01:32

Previous post edited with the code added.
You can send me the print style by private message or by e-mail. (Clicking my name aside would allow you to do so.)

Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 20 Sep 2013, 01:42

Thank you i'll have a little play with this. One thing i have noticed is that quark is actually loosing any imported print styles. There just dropping out completely so if script is looking for printsyle and not finding it maybe its resourting to a default. Quark 7.5 is very unstable on OSX 10.8it crashes all the time on printing. I shall persevere.

Thanks again for your help

Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 20 Sep 2013, 02:26

I have copied this and run as it is but it is erroring (message below)
error "Cant make data fss 98FFA2E425000B504147455F4339325F3430FFBFB2ACC895704EFB18704EFB1848EAFFBFA893140028EAFFBF34EAFFBF714EFB18A549C7950000000020B7F618205F8A0DF3A9 into type string." number -1700 from data fss 98FFA2E425000B504147455F4339325F3430FFBFB2ACC895704EFB18704EFB1848EAFFBFA893140028EAFFBF34EAFFBF714EFB18A549C7950000000020B7F618205F8A0DF3A9 to string.
Do I need to change any elements of the script?


Rather than have the script create the folder can i have the Tests PDF folder already sitting there and have the pdf's save to that folder. Other wise will this not want to create a new folder everytime I run it?

Thanks Tony

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

Modifying quark export PDF script

Post by Jean-Marie Schwartz » 20 Sep 2013, 03:28

Backbone22 wrote:Thank you i'll have a little play with this. One thing i have noticed is that quark is actually loosing any imported print styles. There just dropping out completely so if script is looking for printsyle and not finding it maybe its resourting to a default. Quark 7.5 is very unstable on OSX 10.8it crashes all the time on printing. I shall persevere.
Or not. I'm not convinced Quark 7.5 and OS 10.8 were made to work together.
This said, can you try again with set FilePath to (file path of document 1) as string -- so adding parenthesis around file path of document 1
There might be differences in AS Quark's dictionaries v7 and v9 too. Not sure here.
As to PDF directly to the existing folder of your Desktop, just change on line 6 "Tests PDF:" into "Final print pdf:" and also comment line 3 (by adding a double hyphen at the beginning of the line) OR change ("Tests PDF") into ("Final print pdf"). Hope all this is clear enough.

Jean-Marie Schwartz
Posts: 1168
Joined: 23 Nov 2004, 04:30

Modifying quark export PDF script

Post by Jean-Marie Schwartz » 20 Sep 2013, 03:31

Backbone22 wrote:Other wise will this not want to create a new folder everytime I run it?
Oh no! no fear for it's in a try block meaning that if it errors (so if the folder already exists on the Desktop), it will simply go on and since the alias where to save the PDF is correct, the PDF shall be output (hopefully) correctly in that destination. Does it make sense?

Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 20 Sep 2013, 03:45

Thanks I'll have a play

Backbone22
Posts: 0
Joined: 19 Sep 2013, 10:10

Modifying quark export PDF script

Post by Backbone22 » 20 Sep 2013, 03:47

Oh and yes definatley should not be working together. Unfortunately we have to use quark 7.5 for our catalogue managent system and we had to update our macs so did not have a choice.[:(]

Post Reply

Return to “QuarkXPress 8, 9 & 10: AppleScript”