So, I have this script that’s pretty well worn “ been using it for a few years:
on open theFiles
tell application "Pages"
repeat with aFile in theFiles
open aFile
set docName to name of front document
-- Remove .pages extension.
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ".pages"
-- Add .pdf extension.
set docName to first text item of docName & ".pdf"
set AppleScript's text item delimiters to prevTIDs
-- Get folder that dropped file exists in.
tell application "Finder"
set sourceFolder to (container of aFile) as Unicode text
end tell -- Finder
-- Save file to folder that dropped file exists in.
set docPathAndName to sourceFolder & docName
save front document as "SLDocumentTypePDF" in docPathAndName
close front document
tell application "Finder"
-- Set a highlight colour for the file so it pops out visually
set label index of file docPathAndName to 1
end tell
end repeat
end tell
end open
Basically, you drag and drop one (or more) Pages file(s) on the script application icon, and you get a PDF version of the Pages document(s), in the same folder as the original(s).
What I see when using this script (after a Mavericks upgrade and upgrade to Pages 5) is the following error:
“Can’t make ‘SLDocumentTypePDF’ into type constant.”
Can anyone with more experience than myself translate?
Clearly either the Mavericks change or the Pages upgrade has modified the plumbing such that the script doesn’t work… ideally I’d like to figure this one out “ this is a workhorse use-it-everyday script for me.
I didn’t installed Mavericks but you may try to replace :
save front document as “SLDocumentTypePDF” in docPathAndName
by
save front document in docPathAndName
With Pages '09 the type specifier was not required if the path gave the correct extension.
Not too surprised if Pages 5 use a new specifier for its generated PDFs.
Yvan KOENIG (VALLAURIS, France) mercredi 23 octobre 2013 18:30:42
I was said that driving the export feature is available in Pages 5.
Dropping Applescript support is classical practice when Apple rewrite an application from scratch.
If my memory is OK it was the case when Final Cut was replaced by Final Cut Pro X.
I just hope that we will not have to wait during one year.
If like me your job rely upon AppleScript driving iWork components, better stay with iWork '09.
Yvan KOENIG (VALLAURIS, France) mercredi 23 octobre 2013 19:36:33
Filed Radar bug report 15307980 with Apple. Details below.
Summary:
As a teacher, I use the script below daily. Daily. So do many other teachers at my school. It doesn’t work with Pages 5. This is a huge productivity problem for us. The script also no longer works with Pages 4.3 after an upgrade to Mavericks, which I am now regretting. The script works perfectly with Pages 4.3 on Mountain Lion
on open theFiles
tell application “Pages”
repeat with aFile in theFiles
open aFile
set docName to name of front document
– Remove .pages extension.
set prevTIDs to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to “.pages”
– Add .pdf extension.
set docName to first text item of docName & “.pdf”
set AppleScript’s text item delimiters to prevTIDs
– Get folder that dropped file exists in.
tell application “Finder”
set sourceFolder to (container of aFile) as Unicode text
end tell – Finder
– Save file to folder that dropped file exists in.
set docPathAndName to sourceFolder & docName
save front document as “SLDocumentTypePDF” in docPathAndName
close front document
tell application “Finder”
– Set a highlight colour for the file so it pops out visually
set label index of file docPathAndName to 1
end tell
end repeat
end tell
end open
Steps to Reproduce:
Install Mavericks.
Install new version of Pages.
Drag and drop a Pages file on the Application icon for the script above.
Despair.
Expected Results:
Observe that a PDF file is created with the same name as the Pages original, in the same folder as the pages original, and is highlighted/tagged Orange.
Actual Results:
The following error is presented:
Can’t make “SLDocumentTypePDF” into type constant.
Version:
Pages 5.0
OS X 10.9.0
Notes:
None.
Configuration:
Hardware Overview:
Model Name: MacBook Air
Model Identifier: MacBookAir5,2
Processor Name: Intel Core i5
Processor Speed: 1.8 GHz
Number of Processors: 1
Total Number of Cores: 2
L2 Cache (per Core): 256 KB
L3 Cache: 3 MB
Memory: 4 GB
Boot ROM Version: MBA51.00EF.B02
SMC Version (system): 2.5f9
Serial Number (system): redacted
Hardware UUID: redacted
Attachments:
‘Pages to PDF.zip’ was successfully uploaded.
I don’t know about Pages, Yvan, but once you let Numbers 3.0 touch a document, you can’t open the document any more in Numbers 2.3. This really has me torqued off.
I only have 2 options:
Retrieve Time Machine backups of my documents prior to installing Numbers 3.0, and re-load those using Numbers 2.3
Switch back to Excel, which I just switched away from when the 2004 version (PPC, natch) would not run on ML.