Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how do I batch-convert pages 6 to pdf

Hi


I am a new mac-convert and am still finding my feet with applications, scripts, automaters, etc. I find it all very overwhelming currently. In windows I had an icon on my desktop to which I could drag a batch of .doc files, which would then immediately be converted to PDF.


On mac, I am yet to find such a program, app, utility which converts .pages into pdf.


I have read about running scripts in Automator to achive the aforesaid, but I have failed consistently to get this right.


May someone out there kindly explain step-by-step (FOR DUMMIES) how to create an app or workflow to convert batch .pages files into pdf, as I am tired of individually exporting pages files into pdf.


Kindly assist

MacBook Air, macOS Sierra (10.12.2)

Posted on Apr 7, 2017 6:35 AM

Reply
Question marked as Best reply

Posted on Apr 9, 2017 11:06 PM

Here is an AppleScript drag & drop utility that you can put on your Desktop. Individual Pages documents, or folder(s) of documents can be dropped on this (application), and it will export each document to the original filesystem location with the PDF extension. Since you are using Pages v6.1, this will be PDF Best quality.


  1. Launchpad : Other : Script Editor
  2. Copy/paste the following script into your Script Editor

    Click the compile button

  3. Save as AppleScript source
    1. File menu : Save...
      1. Name: pages2PDF
      2. Documents folder
      3. File Format: Text
      4. Save
    2. Option key + File menu : Save As...
      1. Name: pages2PDF
      2. Desktop
      3. File Format: Application
      4. √ Hide extension
      5. Save
  4. Drag & Drop Pages documents on the pages2PDF Desktop application


AppleScript


-- pages2PDF.applescript

--

-- Drag and drop solution where you can drop a file(s), and/or folder(s) of Pages documents

-- and they will all export as PDF in their present filesystem location. If the Pages version

-- is 5.6 or later, export the documents as Best quality.

-- Restriction: Pages v5 or later only

-- Version 1.0, Tested: macOS Sierra 10.12.4, Pages v6.1

-- VikingOSX, 2017-04-07, Apple Support Communities


property pages_kind : {"Pages Publication"}



on opendropped_items


repeat with anItem in dropped_items


try

tell application "Finder" to set akind to kind of anItem

if akind contains "Folder" then

tell application "Finder"

set docList to (every item in entire contents of folder anItem whose kind is in pages_kind) as alias list

end tell

repeat with afile in docList

export_file(afile)

end repeat

else if akind is in pages_kind then

export_file(anItem)

end if

on error errmsg number errnbr

my error_handler(errnbr, errmsg)

tell application "Pages" to if it is running then quit

return

end try

end repeat

end open

return


on export_file(theFile)

tell application "Finder" to set name_ext to name extension of theFile

set exportDocument to text 1 thru ((offset of name_ext in (theFile as text)) - 1) of (theFile as text) & "pdf"

-- Permissions error fix for Sierra < 10.12.4, and Pages v6, v6.0.5

close access (open for accessexportDocument)


tell application "Pages"

try

set mydoc to open theFile

with timeout of 1200 seconds

if (version of it) ≥ "5.6" then

set export_quality to (Best as constant)

exportmydoctofileexportDocumentasPDFwith properties {image quality:export_quality}

else

exportmydoctofileexportDocumentasPDF

end if

end timeout

closemydocsavingno

on error errmsg number errnbr

my error_handler(errnbr, errmsg)

tell application "Pages" to if it is running then quit

return

end try

end tell


tell application "Finder"

if exists (file exportDocument as alias) is true then

set extension hidden of (file exportDocument as alias) to false

end if

end tell

return

end export_file


on error_handler(nbr, msg)

return display alert "[ " & nbr & " ] " & msg as critical giving up after 10

end error_handler

6 replies
Question marked as Best reply

Apr 9, 2017 11:06 PM in response to MariusVanWyk

Here is an AppleScript drag & drop utility that you can put on your Desktop. Individual Pages documents, or folder(s) of documents can be dropped on this (application), and it will export each document to the original filesystem location with the PDF extension. Since you are using Pages v6.1, this will be PDF Best quality.


  1. Launchpad : Other : Script Editor
  2. Copy/paste the following script into your Script Editor

    Click the compile button

  3. Save as AppleScript source
    1. File menu : Save...
      1. Name: pages2PDF
      2. Documents folder
      3. File Format: Text
      4. Save
    2. Option key + File menu : Save As...
      1. Name: pages2PDF
      2. Desktop
      3. File Format: Application
      4. √ Hide extension
      5. Save
  4. Drag & Drop Pages documents on the pages2PDF Desktop application


AppleScript


-- pages2PDF.applescript

--

-- Drag and drop solution where you can drop a file(s), and/or folder(s) of Pages documents

-- and they will all export as PDF in their present filesystem location. If the Pages version

-- is 5.6 or later, export the documents as Best quality.

-- Restriction: Pages v5 or later only

-- Version 1.0, Tested: macOS Sierra 10.12.4, Pages v6.1

-- VikingOSX, 2017-04-07, Apple Support Communities


property pages_kind : {"Pages Publication"}



on opendropped_items


repeat with anItem in dropped_items


try

tell application "Finder" to set akind to kind of anItem

if akind contains "Folder" then

tell application "Finder"

set docList to (every item in entire contents of folder anItem whose kind is in pages_kind) as alias list

end tell

repeat with afile in docList

export_file(afile)

end repeat

else if akind is in pages_kind then

export_file(anItem)

end if

on error errmsg number errnbr

my error_handler(errnbr, errmsg)

tell application "Pages" to if it is running then quit

return

end try

end repeat

end open

return


on export_file(theFile)

tell application "Finder" to set name_ext to name extension of theFile

set exportDocument to text 1 thru ((offset of name_ext in (theFile as text)) - 1) of (theFile as text) & "pdf"

-- Permissions error fix for Sierra < 10.12.4, and Pages v6, v6.0.5

close access (open for accessexportDocument)


tell application "Pages"

try

set mydoc to open theFile

with timeout of 1200 seconds

if (version of it) ≥ "5.6" then

set export_quality to (Best as constant)

exportmydoctofileexportDocumentasPDFwith properties {image quality:export_quality}

else

exportmydoctofileexportDocumentasPDF

end if

end timeout

closemydocsavingno

on error errmsg number errnbr

my error_handler(errnbr, errmsg)

tell application "Pages" to if it is running then quit

return

end try

end tell


tell application "Finder"

if exists (file exportDocument as alias) is true then

set extension hidden of (file exportDocument as alias) to false

end if

end tell

return

end export_file


on error_handler(nbr, msg)

return display alert "[ " & nbr & " ] " & msg as critical giving up after 10

end error_handler

Apr 10, 2017 5:29 AM in response to MariusVanWyk

Continue to ask questions in the communities for time efficient solutions, while you commence the learning process for Automator, AppleScript, and Bash (Terminal) shell scripting. The best support community for asking questions about these three, tool building ingredients is Mac OS X Technologies. Of course, if it is Pages related, ask here, and if it is Numbers related, ask next door. Since Barry doesn't sleep, he'll see it.


There are two categories of Apple, and commercial Mac applications: 1) Those that support AppleScript via their scripting additions support, and 2). those that don't. When you select: Launchpad : Other : Script Editor, its file menu has an Open Dictionary... menu item. You will see entries for Finder, Pages, etc., and each have reserved words that one can specify in AppleScript to coerce these applications to do things. The scripting dictionaries can and do change between releases of the operating system, as do the individual applications — so nothing is cast in stone.


I have never purchased a book on AppleScript, nor have I taken an online programming course in it. Apple publishes an Introduction to AppleScript Language Guide, that is simply invaluable to the learning process. The MacScripter site is a treasure trove of “how do I…” questions and solutions involving AppleScript, and has an (older) AppleScript training compendium. I actually use MacScripter in a Google search, such as MacScripter drag and drop handler. You can also preface a search question with “AppleScript.” There is also the macosxautomation site. Most importantly, it is eyes on examples of code, and adapting to your goal. Much of AppleScript is blocks of familiar code to achieve specific tasks.


As for Bash scripting, perform a Google search on Bash Scripting, and the top four hits will serve you well. When you choose Launchpad : Other : Terminal, the shell is by default Bash. Just understand that some online Bash programming examples will be done on Linux, with a newer Bash shell, and may not work on OS X.

Apr 9, 2017 11:06 PM in response to VikingOSX

VikingOSX,


Thank you ever so much! This works like a charm.


Wow, I think I need to do an online course or something to learn to program like you. Could you recommend anything- just so that I can barely help myself....?


Or should I rather leave it to the pros and enquire from communities in future also?


I'll follow your recommendation!


Thanks again! 🙂

how do I batch-convert pages 6 to pdf

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.