Batch convert Pages 5 files to PDF.
Is there a way or an app to batch convert Pages 5 files to PDFs ?
I need to convert about 200 files and doing them individually is
a long project.
Thanks in advance,
Lenny.
Is there a way or an app to batch convert Pages 5 files to PDFs ?
I need to convert about 200 files and doing them individually is
a long project.
Thanks in advance,
Lenny.
Do you have any idea why i get message that says: Pages got an error: The document “2.9 Hvad slag leder vil du gerne være? copy.pages” could not be exported as “2.9 Hvad slag leder vil du gerne være? copy”. You don’t have permission. (6). There than that this is just the solution i was looking for!
All export and save functionality from Pages v5/v6 AppleScripts is broken in macOS 10.12.2. That is the cause of the export permissions issue if you are using this release of Sierra.
Probaby won't see a fix for this until 10.12.3 is released in the future.
I'm sure you've either solved your problem or given up by now. However, just in case anyone else stumbles across this one, you could always use something like this:
https://www.ghostotter.com/pages-automator-actions/
...to create an Automator based droplet to do the conversion.
Hope you got there in the end!
Here is a drag & drop AppleScript that exports Pages documents to PDF. That PDF will be “Best” quality if you are running Pages v5.6 or later. You may drag & drop file(s), and/or folder(s) on this tool, and the PDF is written to the original file location. When finished, it will slide in a notification with the processed file count.
Launchpad : Other : Script Editor.
Copy/paste the entire contents of the following AppleScript source window to the Script Editor, click the Compile button, and then save the AppleScript source to a text file named pages2pdf.applescript. Next, press the option key, and choose Save As..., and save the script as an Application with the extension hidden — to your Desktop as pages2pdf. Quit the Script Editor. Your Drag & Drop Pages to PDF converter is ready to use.
-- pages2pdf.applescript -- -- Drag & Drop Pages documents, or folder(s) of Pages documents onto this application. -- PDF will be exported, retaining full path and name of original Pages document. -- Finder will unhide the exported PDF extension, and a final Notification -- with processed file count will be shown. -- Version: 1.0 -- Requirement: OS X 10.10.0 or later, Pages v5.5 or later. -- Tested: Pages v5.6.2 on OS X 10.11.6, Pages v6.1.1 on macOS Sierra 10.12.5 -- VikingOSX, 2017-06-06, Apple Support Communities property ca : current application property valid_kind : {"Pages Publication"} use framework "Foundation" use AppleScript version "2.4" -- Yosemite 10.10.0 or later use scripting additions on open dropped_items global fileCnt set fileCnt to 0 as integer repeat with anItem in dropped_items try tell application "Finder" set akind to kind of (anItem as alias) if akind contains "Folder" then set docList to (every item in entire contents of folder anItem whose kind is in valid_kind) as alias list repeat with afile in docList my export_file(afile) end repeat else if akind is in valid_kind then my export_file(anItem as alias) end if end tell on error errmsg number errnbr my error_handler(errnbr, errmsg) tell application "Pages" to if it is running then quit quit end try end repeat display notification "Files exported to PDF: " & fileCnt ¬ with title "Pages PDF File Export Facility" subtitle "Processing Complete" tell application "Pages" to if it is running then quit return end open on export_file(theFile) global fileCnt -- keep full path to theFile and only change its extension set exportDocument to new_extension(theFile, "pdf") as POSIX file -- necessary to avoid export write permissions issues close access (open for access exportDocument) tell application "Pages" try set myDoc to open theFile with timeout of 1200 seconds if its version ≥ "5.6" then export myDoc to file exportDocument as PDF with properties {image quality:Best} else export myDoc to file exportDocument as PDF end if end timeout close myDoc saving no on error errmsg number errnbr my error_handler(errnbr, errmsg) tell application "Pages" to if it is running then quit quit end try end tell tell application "Finder" if exists (file exportDocument as alias) then set extension hidden of (file exportDocument as alias) to false set fileCnt to (fileCnt + 1) as integer end if end tell return end export_file on new_extension(afile, ext) -- strip extension from file path and replace with new extension set fullPath to ca's NSString's alloc()'s initWithString:(POSIX path of afile) set newPathExt to (fullPath's stringByDeletingPathExtension)'s stringByAppendingPathExtension:ext return newPathExt as text end new_extension on error_handler(nbr, msg) return display alert "[ " & nbr & " ] " & msg as critical giving up after 10 end error_handler
Use Automator which comes with your System.
Peter
Hi Peter,
I'm trying to do the same thing, but when I load Automator there doesn't seem to be an action that converts a pages file to PDF. Maybe I'm being really dense as I've not done anything with automator or apple script before.
Any help would be appreciated.
Keith
I am not in the position to do the workflow for you but the action would open a series of Pages files and print them, choosing PDF as the print.
There is a separate Automator forum here and also websites dedicated to Automator. Google them.
Peter
I am working on a modernized double-click/drag drop script — but it could take a few days to write and debug.
It would evaluate what version(s) of Pages are installed, and what version(s) of Pages documents were selected/dropped on the application. Export to PDF would be attempted in the original application that created the given Pages document. The export syntax is different in older Pages versions than in Pages v5+.
The principal reason for the second paragraph is that Pages 08 documents cannot be opened in Pages v5+, and that Pages '09 documents — if opened in Pages v5+ would be subject to content filtering — before the export to PDF. This could omit expected document content in the exported PDF.
Thanks Peter, at least it gives me something to get started on.
Here comes a long evening of google searches! 😁
That sounds exactly the sort of thing I'm looking for Viking. If you have any luck with it I'd love to see a copy of the script. Thanks
Having spent some time searching the internet on how to do this with Automator I ended up trying to write my own in Applescript. More searching on how to do this and I stumbled onto this beautiful script from kenhotto, who has already done exactly what I was trying to do.
--Select from where you will pick up the pages files
set theFolder to choose folder with prompt "Select folder with original pages files :"
--Do it
tell application "Finder"
set theNames to name of files of theFolder ¬
whose name extension is "pages"
end tell
--Select where the PDF files will go
set pdf_Folder to choose folder with prompt "Select folder where PDF files will go :"
-- How many files to export
set item_count to (get count of items in theNames)
--Get files and export them
repeat with i from 1 to item_count
set current_file to itemi of theNames-- get a file
set lean_file to text 1 thru -7 of current_file & ".pdf" -- change the originalfile (.pages) to a .pdf name
set out_file to (pdf_Folder as Unicode text) & (lean_file) -- get the fully qualified output name
set in_file to (theFolder as Unicode text) & (current_file) -- get the fully qualified input file name
tell application "Pages"
set mydoc to openfilein_file-- open input file in Pages
exportmydoctofileout_fileasPDF--do the exporting
closemydocsavingno-- close the original file without saving
end tell
end repeat
display dialog "done" -- Job done
We are constantly adding new pages documents to the folder I wanted to convert to PDF and so I tried re-running the programme on the already processed folders with the result that it simply adds the unconverted pages files to the existing folder of PDF's. It takes a bit of time and I'm sure there's a clever 'if clause' that will mean the programme doesn't even look at the already converted files, but this works for me. Problem solved. Thanks to kenhotto and everyone else for their input.
Hey onions,
Did you get your Script running with Pages 5 on Yosemite? If I try to to run, it quits after the first pages document opened.
Hi TIm,
Yeah I'm running OS X Yosemite 10.10.1 with Pages 5.5.1
I copied the script into applescript then saved as an application. I then ran it and selected each folder in turn. I'm pretty sure there was a mixture of pages 09 and pages 5 files in the input folder but can't guarantee that, as they've now all been converted to pages 5. I'd try saving a couple of test files to a test folder and maybe include an 09 file to see if that causes any problems.
To my amazement this all worked first time with no problems. I'm new to scripting so I'm probably not the nest person to ask.
If all else fails it might be worth starting a new thread and asking someone to debug the script for you.
Best of luck.
Hi guys,
just wondered if I could have a bit of help getting this to work. I seem to be the only person on earth who has never managed to get automator to work properly, so constantly find the 'watch me do' action just doesn't produce consistent results and needs a lot of resetting (often quicker to just do it manually).
The script keeps telling me "pages does not understand the 'export' message". Has anyone else come across this error message?
I'm on yosemite 10.10.1 and pages 5.5.1
Any tips are much appreciated.
Thanks,
-G
Hi Erko,
although you should be able to run this in Automator theres no need, unless you want to more things with it. I simply copied the script into Applescript (found in your launch pad, I believe in utilities) and saved it as an application. You then just double click on the icon to run it and follow the instructions.
easy peasy!
Batch convert Pages 5 files to PDF.