Re: Re(2): Pages 4.3 and Mavericks - Can't export as PDF
Re: Re(2): Pages 4.3 and Mavericks - Can't export as PDF
- Subject: Re: Re(2): Pages 4.3 and Mavericks - Can't export as PDF
- From: "koenig.yvan" <email@hidden>
- Date: Mon, 04 Nov 2013 21:33:03 +0100
Slightly edited version. It take care of possible inspector windows.
[applescript](*
PagesOld2PDF
Cumbersome code to be sure that we use the old application,
which is "/Applications/iWork '09/Pages.app".
In this script grabbing the process ID wasn't required but the skeleton was grabbed from a script in which it was.
*)
tell application "/Applications/iWork '09/Pages.app"
activate
if not version < "5" then error "You aren't running Pages version 4.x"
end tell
tell application "System Events" to tell (first process whose frontmost is true)
set procID to its id
set dName to name of first window whose subrole is "AXStandardWindow" # take care of possible inspector whose subrole is "AXFloatingWindow"
end tell -- System Events
if dName ends with ".pages" then
set pdfName to (text 1 thru -6 of dName) & "pdf"
else
set pdfName to dName & ".pdf"
end if
tell application "System Events" to tell (first application process whose id is procID)
keystroke "p" using command down
(*
Wait for the availability of the sheet *)
repeat
if exists sheet 1 of window dName then exit repeat
end repeat
#name of menu buttons of sheet 1 of window dName
--> {"PDF"} but I don't know if it's spelled this way worldwide
tell sheet 1 of window dName
set PDFButton to first menu button
end tell
click PDFButton
# name of menu items of menu 1 of PDFButton
--> {"Ouvrir le PDF dans Aperçu", "Enregistrer au format PDF…", "Enregistrer au format PostScript…", "Faxer le document PDF…", missing value, "@ PDF-BAT.qfilter", "@ PDF-prépresse CMJN.qfilter", "@ PDF-web.qfilter", "@ PDFX3-ISO.qfilter", "Add PDF to iTunes", "Envoyer le document PDF par courrier électronique", "Enregistrer le document PDF dans le dossier de reçus web", missing value, "Modifier le menu…"}
click menu item 2 of menu 1 of PDFButton
(*
Wait for the availability of the save in PDF file sheet *)
repeat
if exists sheet 1 of sheet 1 of window dName then exit repeat
end repeat
(*
Set the name of the new PDF *)
set value of text field 1 of sheet 1 of sheet 1 of window dName to pdfName
keystroke "d" using command down # set destination folder to Desktop
keystroke return
end tell[/applescript]
With this script I am able to print the Pages '09 document open at front in a PDF file stored on the Desktop.
I assume that you are able to write the instructions moving it from this location to the wanted one.
As far as I know, Desktop is the unique location which may be defined for sure with no cumbersome trickery when we use Print to PDF.
And now a slightly edited one which pint to PDF frm the new Pages ( the one embedded in iPlay '13 )
[applescript](*
PagesNew2PDF
Cumbersome code to be sure that we use the new application,
not the old one which is "/Applications/iWork '09/Pages.app".
In this script grabbing the process ID wasn't required but the skeleton was grabbed from a script in which it was.
*)
tell application "/Applications/Pages.app"
activate
if version < "5" then error "You aren't running Pages version 5.x"
end tell
tell application "System Events" to tell (first process whose frontmost is true)
set procID to its id
set dName to name of first window whose subrole is "AXStandardWindow" # take care of possible inspector whose subrole is "AXFloatingWindow"
end tell -- System Events
if dName ends with ".pages" then
set pdfName to (text 1 thru -6 of dName) & "pdf"
else
set pdfName to dName & ".pdf"
end if
tell application "System Events" to tell (first application process whose id is procID)
keystroke "p" using command down
(*
Wait for the availability of the print sheet *)
repeat
if exists sheet 1 of window dName then exit repeat
end repeat
#name of menu buttons of sheet 1 of window 1
--> {"PDF"} but I don't know if it's spelled this way worldwide
tell sheet 1 of window dName
set PDFButton to first menu button
end tell
click PDFButton
# name of menu items of menu 1 of PDFButton
--> {"Ouvrir le PDF dans Aperçu", "Enregistrer au format PDF…", "Enregistrer au format PostScript…", "Faxer le document PDF…", missing value, "@ PDF-BAT.qfilter", "@ PDF-prépresse CMJN.qfilter", "@ PDF-web.qfilter", "@ PDFX3-ISO.qfilter", "Add PDF to iTunes", "Envoyer le document PDF par courrier électronique", "Enregistrer le document PDF dans le dossier de reçus web", missing value, "Modifier le menu…"}
click menu item 2 of menu 1 of PDFButton
(*
Wait for the availability of the save in PDF file sheet *)
repeat
if exists sheet 1 of sheet 1 of window dName then exit repeat
end repeat
(*
Set the name of the new PDF *)
set value of text field 1 of sheet 1 of sheet 1 of window dName to pdfName
keystroke "d" using command down # set destination folder to Desktop
# keystroke return
end tell[/applescript]
Yvan KOENIG (VALLAURIS, France) lundi 4 novembre 2013 21:32:58
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden