set p2d to path to desktop as text
tell application "Pages"
set file_name to name of document 1
if file_name ends with ".pages" then
set pdfName to (text 1 thru -6 of file_name) & "pdf"
else
set pdfName to file_name & ".pdf"
end if
-- convert it
save document 1 as "SLDocumentTypePDF" in (p2d & pdfName)
end tell
A similar script apply to Numbers.
set p2d to path to desktop as text
tell application "Numbers"
set file_name to name of document 1
if file_name ends with ".pages" then
set pdfName to (text 1 thru -6 of file_name) & "pdf"
else
set pdfName to file_name & ".pdf"
end if
-- convert it
save document 1 as "LSDocumentTypePDF" in (p2d & pdfName)
end tell
Only Keynote requires GUIScripting.
In this case, given what we really want to achieve we must trigger
Export as PDF
or
Print in a PDF
Yvan KOENIG (VALLAURIS, France) vendredi 16 septembre 2011 10:59:02