Mass convert Pages documents to PDF?

Does anybody have a good idea how I could convert hundreds of Pages documents to PDF? I know how to do one, but we have way to many, The friend who needs it, is absolutely not an idiot, but would really like an idiotproof solution.

Conversion to PDF is effectively printing the document to a file.

Pages, like most Apple apps, has an AppleScript interface. So someone should be able to write a script to accept a collection of files (maybe via drag/drop onto the script) and tell Pages to open each one, print it to a file, and then close it.

Looking at the AppleScript dictionary for Pages, I see it can respond to commands to do this:

  • open: Open a file or list of files
  • close: Close a document or window
  • print: Print a document. I’m not sure exactly about the settings/properties needed to print to a PDF file, but I’m sure there are settings for this. I’d be very surprised if there were not.
  • save: Save a document in a specified format. Again, I don’t know, from a quick look, what formats are supported, but it would not surprise me if PDF was among the options.

So, if you or someone you know, is comfortable writing AppleScript, you should be able to write a script to get the job done. You may also be able to use Automator to help write up a script.

Perhaps someone else here has more experience with AppleScript and can help flesh-out the above into a usable script.

Automator could do this. Point it to a folder of Pages documents and ask it to PDF them to a destination folder.

Applescript is also an option. I don’t have time to do it right now but ask ChatGPT to write an Applescript to do it and see how it goes. It’s typically returns fairly decent results.

1 Like

I use this, compile in script editor as an app and drop files on it


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

on open (fileList)
	convertFiles(fileList)
end open

--choose keynote and/or pages files to convert
set fileList to choose file with multiple selections allowed
convertFiles(fileList)

on convertFiles(fileList)
	repeat with i from 1 to length of fileList
		set theFile to item i of fileList
		tell application "Finder"
			--get the name of the file from the path
			set fileName to name of theFile
			--get the containing folder path as text
			set fFolder to container of theFile as text
			--get the extension of the file
			set oldExtension to name extension of theFile
			--strip the old extension from the file name
			set oldStripped to text 1 thru (-((length of oldExtension) + 2)) of fileName
		end tell
		
		if oldExtension is "pages" then
			set newExtension to ".pdf"
			tell application "Pages"
				set myDoc to open file theFile
				export myDoc to file (fFolder & oldStripped & newExtension) as PDF
				close myDoc saving no
			end tell
		else if oldExtension is "key" then
			set newExtension to ".pdf"
			tell application "Keynote"
				set myDoc to open file theFile
				export myDoc to file (fFolder & oldStripped & newExtension) as PDF
				close myDoc saving no
			end tell
		else
			display dialog "file is neither pages nor keynote"
		end if
	end repeat
	display dialog "Finished"
end convertFiles
2 Likes

Thanks @ramonrempel. I have also asked ChatGPT, it offered “macOS Automator workflow or application”, then wrote AppleScript to be used in Automator. When I asked about possible compatibility with other versions of macOS it offered alternatives “such as a Shortcuts app workflow or a Shell Script for better long-term compatibility”
Funnily, it offered “to package these into ready-to-use files” but could only do this for the shell script.
I have more funny details, but let’s stay on topic. I now need to learn a bit about AppleScript, Automator and Shortcuts, I always thought that Mac users don’t ever need that.