Search code examples
macosapplescriptmacos-catalina

Updating to MacOs Catalina make Apple script unable to export Pages Document: "Pages got an error: Invalid key form."


I am trying to update a Pages Apple Script to work on Catalina. This was working before the update but now this line fails:

set the targetExportFileHFSPath to "/Users/me/Desktop/tmp.pdf"
export thisDocument to file targetExportFileHFSPath as PDF <-- FAIL

Any idea why?

enter image description here enter image description here


Solution

  • Honestly, I'm surprised that worked before. The file specifier rarely, if ever, qualifies a posix path (which is what you've got, not an HFS path as your variable name suggests).

    Here are a few variations you can try:

    set filepath to POSIX file "/Users/me/Desktop/tmp.pdf"
    -- set filepath to POSIX file "/Users/me/Desktop/tmp.pdf" as alias
    -- set filepath to "/Users/me/Desktop/tmp.pdf" as «class furl»
    -- set filepath to "/Users/me/Desktop/tmp.pdf" as «class fsrf»
    

    Then the export command in each case is simply:

    export thisDocument to the filepath as PDF