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

How to convert Numbers files to pdf

Hi. I have a large number of Numbers documents I want to give to my book-keeper. She doesn't use a Mac, so she can't use Numbers files. I want to convert them to PDF so she can view them.


I've been converting them manually. This is what I do:


1) Open the Numbers file.

2) Choose Print.

3) Select "All Sheets". This is important because I have 5 sheets in each document.

4) Choose "Save as PDF".

5) The default name is fine, so press OK.

6) Close the Numbers file.


I have hundreds of these files. Is there a way I can automate the process of converting them?


Thanks for the help!

MacBook Air, Mac OS X (10.7.4)

Posted on Jun 13, 2013 10:44 AM

Reply
8 replies

Jun 17, 2013 5:59 PM in response to Tammy Siu

Hello


You may try the following script. It will ask you to choose folder where Numbers files reside and then export every Numbers file in the chosen folder as PDF. Export destination folder will be the last folder you used for export. So you'd better export one file in advance and select the export destination folder you want to use. It will replace existing pdf file in destination folder.


Menu text are assumed in English and hard coded in script. For languages other than English, please edit the following three properties in export_as_pdf() handler:


property export_menu : "Export…"
property image_quality : "Good" -- Good | Better | Best
property layout : "Sheet View" -- Sheet View | Page View


The first one is menu item name of File > Export… (note … is U+2026 HORIZONTAL ELLIPSIS, which can be inputted by option ; in English keyboard for instance) and the rest are for options in Export sheet.


Tested with Numbers 2.0.5 under OSX 10.6.5.


Hope this may help,

H



_main()
on _main()
    script o
        property ff : {}
        property xx : {}
        property yy : {}
        
        set f to choose folder with prompt "Choose folder of Numbers files"
        tell application "Finder"
            set ff to (files of f whose name ends with ".numbers") as alias list
        end tell
        tell application "Numbers" to launch
        repeat with f in my ff
            tell application "Numbers"
                tell (open f)
                    if my export_as_pdf("", {_replace:true}) then
                        set end of my xx to f
                    else
                        set end of my yy to f
                    end if
                    close
                end tell
            end tell
        end repeat
        tell application "Numbers"
            display dialog "Exported " & (count my xx) & " of " & (count my ff) & " files." giving up after 20
        end tell
    end script
    tell o to run
end _main

on export_as_pdf(pdfname, {_replace:_replace})
    (*
        string pdfname : output pdf file name (pdfname = "" denotes the current name whose extension is replaced with "pdf")
        boolean _replace : true to replace existing pdfname, false otherwise
        return boolean : true if operation is not canceled, false otherwise (in case _replace = false and pdfname already exists)
    *)
    script o
        property export_menu : "Export…"
        property image_quality : "Good" -- Good | Better | Best
        property layout : "Sheet View" -- Sheet View | Page View
        property _canceled : false
        
        tell application "Numbers"
            activate
            if pdfname ≠ "" then set the clipboard to pdfname
        end tell
        tell application "System Events"
            tell process "Numbers"
                tell menu bar 1's menu bar item 3 -- File
                    tell menu 1's menu item export_menu -- Export…
                        click
                    end tell
                end tell
                tell (window 1 whose subrole = "AXStandardWindow")
                    tell sheet 1
                        tell radio group 1
                            tell radio button 1 -- PDF
                                if value ≠ 1 then click
                            end tell
                        end tell
                        tell pop up button 2 -- Image Quality
                            if value ≠ image_quality then
                                click
                                tell menu 1's menu item image_quality
                                    click
                                end tell
                            end if
                        end tell
                        tell pop up button 1 -- Layout
                            if value ≠ layout then
                                click
                                tell menu 1's menu item layout
                                    click
                                end tell
                            end if
                        end tell
                        tell button 1 -- Next…
                            click
                        end tell
                    end tell
                end tell
                --keystroke "d" using {command down} -- desktop
                if pdfname ≠ "" then keystroke "av" using {command down} -- select all and paste in file name
                keystroke return
                tell (window 1 whose subrole = "AXStandardWindow")
                    tell sheet 1 -- save sheet
                        repeat while exists
                            delay 0.1
                            tell sheet 1 -- alert sheet (already exists)
                                if exists then
                                    if _replace then
                                        click button 1 -- Replace
                                    else
                                        click button 2 -- Cancel
                                        set _canceled to true
                                    end if
                                end if
                            end tell
                            if _canceled then click button 3 -- Cancel
                        end repeat
                    end tell
                end tell
            end tell
        end tell
        return not _canceled
    end script
    tell o to run
end export_as_pdf

Oct 14, 2016 9:31 PM in response to Tammy Siu

I would highly recommend looking into Automator as well. Automator is essentially a platform in OS X that allows the user to create workflows through actions. These actions are pre-built and make it easier for a novice to build powerful automations for repetitive or multi-step tasks.


The benefit here is that if you're on a deadline and need help you don't need advanced knowledge to build a worfow. Though AppleScript is a mature language, unless you've had exposure to coding of some kind, you are at the mercy of kind souls writing out a long scripts on Apple Communities that you have no idea how to fix if they break.


You can even automate a folder through folder actions, so all you would have to do is drag and drop your Numbers docs im the specified folder and voila! Pdfs of all your numbers doc! (And yes, there is a "convert to pdf" action in Automator) Best part: Now you're curious and empowered to create solutions on your own that cater to your day-to-day habits on your Mac. And if you ever need to run an AppleScript, don't worry. Automator has a "run AppleScript" action for those strictly non-linear workflows.

How to convert Numbers files to pdf

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