Sitemap

Amicuk Programming Answers

How to convert Numbers files to pdf

-0001-11-30   Views:0

Advertisement

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)

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!

The replay answer
Advertisement
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

Go to See the other 7 answers

Hot
Dear All, There is a situation, we have configured the static credit check at PGI level . The system throws an error message if the recievebakes have exceeded, somehow there is a requirement for a list of all delivery documents blocked for credit at [More]
Hello, We have an purcharse order with several lines. Only 2 lines remain opened because open quantity is greater than 0. We would like to close one of the lines through Data/Close Row. That line had a initial quantity of 1000 units, and 800 were del [More]
Hello I need to control two values x and y on a GUI. I am using two perpendicular JSliders to do that, but it looks ugly and is hard to use. I dreamed of makeing a 2D Slider(!) which basically would be a square of a circle with a nub in the middle. U [More]
I need to add three additional fields in ESS leave request (HR). I was told i can do that using web dynpro. I like to know how can I do it. Thankshi Jeroen, Can u please help me with my issue....... My issue is to add new fields in ess/leave request [More]
Hi eveyone, I've got a Dual 2Ghz G5 running 10.4.8 with a Sony DW-Q28a Superdrive that is refusing to mount a couple of Verbatim DVD-R 8x data discs from our photo archive. The discs will spin for a bit, then be regarded by OS X as blank discs. Howev [More]
Sorry i am bad in English...In this case, I'm still new.I have this error "TypeError: Error #1009: Cannot access a property or method of a null object reference. at Monster/hurtPlayer() at flash.events::EventDispatcher/dispatchEventFunction() at flas [More]
Has 'rootpre.sh' been run by root? [y/n] (n) y Initializing Java Virtual Machine from ../stage/Components/oracle.swd.jre/1.1.8. 3/1/DataFiles/Expanded/jre/aix/bin/jre. Please wait... Could not load program /u02/cdrom/stage/Components/oracle.swd.jre/1 [More]
hi, The scenario is this : Allocations are maintained at sales organization level. Allocation check is working fine. The requirement is that the check should happen at sales org. group level. e.g. sorg 'a1' and 'a2' belong to sorg group 'A'. Allocati [More]
I just upgraded from the first Apple tv to the new one. I had a large library of purchased movies that I had stored on an external harddrive. I would manually choice movies I wanted to watch and then sycn to the first ATV as to not waste space on the [More]
What permissions does a package owner need to execute immediate 'alter system kill session' within a package?Are you sure? It works for me on 10.2.0.1 (32 bit Windows) SYS @ jcave102 Local> drop user bob cascade; User dropped. Elapsed: 00:00:11.25 SY [More]