|
|
#1 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
Creating a PDF workflow that saves a PDF file.
I have recently discovered that Apple no longer supplies a "Save As PDF-X" workflow with Lion, and that copying the workflow from 10.6 to Lion doesn't work.
So, I want to produce a PDF workflow ("print plug-in") that applies the OS Quartz Filter "Create Generic PDFX-3 Document" and then prompts the user for a save location and saves the file. Now in Automator, it is easy enough to apply the filter, with the automator "Apple Quartz Filter" action, but it seems harder to bring up a file dialog and save the PDF. No such action exists. So I need an AppleScript that prompts for a filename and the saves the PDF. I've tried using: Code:
set myFile to choose file name with prompt "Save file as:" save input in myFile Any help gratefully received. |
|
|
|
|
|
#2 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
As ever, it's a bit more complicated than that. Here's a suitable script I found in another print plug-in here:
Code:
on run {input, parameters}
-- parse output folder and file names
set outfile to (choose file name default name "untitled" default location path to desktop) as string
set len to length of outfile
tell application "Finder"
repeat with i from 0 to len
if text (len - i) of outfile is ":" then
exit repeat
end if
end repeat
set i to len - i
set outfp to text 1 thru (i - 1) of outfile
set outfn to text (i + 1) thru len of outfile
if outfn does not end with ".pdf" then
set outfn to outfn & ".pdf"
end if
-- parse input folder and file names
set parm to (item 1 of input) as string
set len to length of parm
repeat with i from 0 to len
if text (len - i) of parm is ":" then
exit repeat
end if
end repeat
set i to len - i
set infp to text 1 thru (i - 1) of parm
set infn to text (i + 1) thru len of parm
-- rename the file and move it to the output folder
set name of file parm to outfn
set tmp to infp & ":" & outfn
move file tmp to folder outfp with replacing
end tell
return true
end run
|
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
No, that doesn't work on Lion either.
First I get an error saying "Couldn't Create a PDF/X-3 document", then I get the save dialog, and then "The action encountered an error". However, I have had success with an action just to move the file to the Desktop. |
|
|
|
|
|
#4 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
I've tried this, too:
Code:
tell save panel
set title to "Save file"
set prompt to "Save"
set required file type to "pdf"
set treat packages as directories to false
end tell
set theResult to display save panel with file name "Untitled"
Anyone.....? There are usually some real AppleScript geniuses here, and surely saving a file in an Automator workflow must be easier than this...!!! |
|
|
|
|
|
#5 |
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,649
|
This isn't scripting guidance, and I'm not even certain if this will help you, but I'll share it and let you decide. You can easily make a Create Generic PDFX-3 Document Quartz filter so that it appears in a Print dialog under the PDF button.
But the PDF Service/Quartz Filter you created with ColorSync is available to Automator. Open a new window in Automator and choose Print Plugin. When building your plugin, at some point you'll want to use the Apply Quartz Filter To PDF Documents action. That includes a pop-up menu from which you can choose the Quartz Filter you created. |
|
|
|
|
|
#6 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
Are you using Lion? Because I've already reported that user-created Quartz Filters don't always work in Lion -- even if they are duplicates of the system ones.
However, you may have hit something, as the default system filters do not have their "Domains" set to include printing or Print plug-ins. (How stupid is that?) Anyway, I've tried your suggestion and I still get a "Could not create PDF-X document" error message, and no PDF in the Desktop. On 2 Macs. |
|
|
|
|
|
#7 |
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,649
|
Yes, I'm running Lion, and now that you mention it I do recall your other thread regarding issues with this Quartz filter.
What setup did you use with your duplicate Quartz filter? Was that through an Automator Workflow and/or Print Plugin? When I created the duplicate Quartz filter, it automatically appeared in the Print dialog under the PDF button, and using that placed the PDF on the Desktop. |
|
|
|
|
|
#8 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
Ahhhhh!!
Ticking the "Pdf Workflows" domain in ColorSync Utility MOVES the user filter from ~/Library/Filters to ~/Library/PDF Services!!!! And then, if you select the Filter in the PDF menu (and not the Print Workflow/plug-in created in Automator), you get a PDF file on the Desktop. However, according to Acrobat, it's not PDF-X3 compliant so the filter hasn't actually been applied. Arrgh. EDIT: I've tried editing the xml of the System Quartz Filter to allow PDF workflow and Printing. It still produces the "can't produce PDF X document" error. I suspect it's some sandboxing thing preventing the saving of the file. Last edited by benwiggy; 12-03-2011 at 10:57 AM. |
|
|
|
|
|
#9 |
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,649
|
Two tips from the end of this post (technically about 10.6 but I figure worth a try on your end under 10.7): 1) set your Quartz filter to use 300 DPI and 2) avoid the flattened transparency option.
|
|
|
|
|
|
#10 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
I've cracked it.
When ColorSync Utility dupes the filter, it's only 1K, whereas the filter in /System/Library/Filters in 79K. Copying it in the Finder to ~/Library/PDF Services (and adding the XML: Code:
<key>PDF Workflow</key> <true/> <key>Printing</key> means you can use the PDF-X3 filter in the PDF button of the print menu, and a PDF-X3 document is saved to the Desktop. However, there still seems to be no way of including filters within print workflows in Automator, nor of setting the location for where to save the file. Interesting about the dpi thing in that thread. Most of what I do is vector, but still more grist to the PDF mill. |
|
|
|
|
|
#11 |
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,649
|
In case it's of any use, I saw an article on an Automator-based Service for shrinking PDFs and it reminded me of this thread.
http://www.leancrew.com/all-this/201...omator-service |
|
|
|
|
|
#12 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,071
|
Thanks. I've posted there about the bugs I've found in Lion relating to Quartz Filters and Preview.
I reported the bugs to Apple in November. If Mountain Lion is coming out soon, then I don't know what that means for Lion development and support. |
|
|
|
|
|
#13 | |||||||||||||||||||||||
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,649
|
This gets at an implication I have with the yearly OS release schedule Apple has announced. If Apple holds to its previous actions, this means the prior OS will get some security updates but fewer bug fixes will be issued since the OS will be current for less time. I realize that moving to the next OS will only cost US $30, but I never install a point-zero release. From that angle, it sounds like the best I'll get is about 11 months of an OS being completely supported. It's certainly possible that I've oversimplified how this will play out. Or that there's something I've missed (or don't yet know). But it's looking like bug fixes will largely be coming from major OS releases. Can't say I like the looks of that. |
|||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|