Ask TUAW Video Edition: PDF and Scripting
Andrew asked us about how to have a folder convert documents to PDF format so that he can sync them to his Dropbox.
Today's show goes into how to use Automator and AppleScript to do some scripting, and we're going to demonstrate an iPad app that will convert documents for you on your iPad.
Some resources for you:
- Automator - Mac OS X Automation Automator
- AppleScript - Mac OS X Automation AppleScript
- Save2PDF - Main Company Page
Any questions, please leave them in the comments or email us! Read on for the video.
Share
Categories
Andrew asked us about how to have a folder convert documents to PDF format so that he can sync them to his Dropbox. Today's show goes...
Add a Comment
If you're into shell scripting and the Unix sublayer of OS X, you could try using Doc2pdf or any of the other myriad of command line tools.
Personally, I use Quickoffice to view Word docs downloaded from the Internet and just use Word's save as PDF or print to PDF for conversion. Roundabout way and not good for multiple files, but I don't do it often, only when using the school's printer that only supports PDF via USB storage.
JHam - isn't Doc2PDF a web service? Is there a way to run it local on a specific folder?
Thanks
Justin
How supremely disappointing. I was excited by the title but, as others have mentioned, Automator's "Convert Format of Word Documents" doesn't work when saving to PDF. Unless I've missed something (other than the past hour of my life searching Google) this doesn't work.
Thanks for the idea anyway, Justin--did this work for you?
Andrew - I was able to make it work with Applescript, I was just showing the Automator piece as an example. I believe that Applescript is not as "scary" as some people make it out to be. I'm sure if you google something like "Applescript, PDF convert" there are plenty of examples out there that will work for you.
Thanks
Justin
Tom, I used the Convert Word to PDF function in Automator with good results. (I did have to use the option to locate my initial Word files, which were already in my selected folder, in order to test my workflow within Automator.) All the files were readable PDFs and, sure enough, new Word documents added to that folder are converted to PDFs.
I'm really grateful for this tip as it will save me a significant amount of time when I receive 40 student Word documents which I then convert to PDFs for grading and for my course records. I just wish I would take the time to set up other scripting workflows. (I do use the scripting functions in Adobe Bridge to convert and process image files.)
Having done my share if automator and apple script hackery I've actually found using the accessibility layer of OSX can sometimes be easier to understand. For my scripting needs I found UI Browser by PreFab http://pfiddlesoft.com/uibrowser/ to be indispensable. As long as the App uses resources accessibility understands you can script it.
What I'd do is make an Apple Script that invokes the Print command and then the "Save as PDF" function in OSX itself. That Apple Script can be placed in automator with variables for file name and saving location passed into the Apple Script. Granted that ties up the UI while it runs, although on the plus side it's a bit easier to understand how the OS is doing what you want it to.
Something like :
activate application "Firefox"
tell application "System Events"
tell process "Firefix"
click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1
delay 1
click menu button "PDF of window "Print"
try
tell menu item 1 of menu 1 of menu button "PDF of window "Print"
set {xPosition, yPosition} to position
set {xSize, ySize} to size end tell
end tell
click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
end try
end tell
end tell
You can add more to that by calling fields in the "Save" window such as "Save As:" and "Where:" but I'm going to stop there. Replace Firefox with a variable that stores the current running App and it should be valid for just about any Cocoa App.
No offense to Automator as I use it enough, but Apple has really let it degrade in a shameful way. At least Apple Script stays current with system commands if you know how to invoke them.
Droje - nice script. Glad you were able to share it with us.
Applescript obviously has it's benefits over Automator - but some people are so scared of it!
Again thanks for sharing
Justin
I tried this using the automator method however preview won't allow me to open the PDF at the end. It says 'The file cannot be opened...It may be damaged or use a file format that Preview doesnât recognize.'
Anybody got any ideas what might be going on with this?
Deals of the Day
more deals- Apple Wireless Bluetooth Keyboard for $40 + $8 s&h
- Refurb Mac Pro Xeon Quad-Core 2.8GHz Workstation for $1,150 + $38 s&h, more
- Used Apple iPad 32GB Wi-Fi Tablet for $200 + free shipping
- Apple iPod nano Multi-Touch 8GB MP3 Player for $100 + $8 s&h
- Cases for New iPad at HandHeldItems: Extra 20% off, $2 credit, from $3 + $3 s&h
- $15 Apple iTunes Gift Card for $8 for new Saveology customers
11 Comments