Benches macOS

2

Using Applescript to tell Acrobat Pro 9 t…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I'm trying to extract a specified page from a pdf file, insert it into a new file, and save the new file.

I have a script that will do the first two steps (i.e. open a specified pdf file and insert a range of pages into a new file) but I can't save the new file.

The save step should be trivial but the basic save command doesn't seem to work. Does anyone have a version that they have used that actually works? I am using Acrobat Pro 9 v9.3.2.

Here is my AppleScript:

set theFile1 to "xxx:sourcefile.pdf" -- the source file from which to extract pages

tell application "Adobe Acrobat Pro"

launch

activate

set doc1 to open theFile1

set mydoc to make new document -- this is where the extracted pages will go

insert pages mydoc after 1 from document 1 starting with <page number of first page to insert> number of pages <number of pages to insert> without insert bookmarks

delete pages mydoc first 1 last 1

-- using insert and delete because replace command gives error.

bring to front mydoc -- can see the new doc on the screen

save mydoc to "path:name.pdf" --- doesn't work!

end tell

2 replies

Sign in or join Beachball Help to reply.

  1. 0

    Budgie

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi neal_B

    Try these suggestions

    set Default_Path to (path to desktop as Unicode text)

    tell application "Adobe Acrobat Pro"

    activate

    tell active doc

    set _Name to name

    if modified is true then

    save to file (Default_Path & _Name) -- Save as required… For Certified Document

    close

    end if

    end tell

    end tell

    another way

    -- close front document saving yes

    Budgie

  2. 0

    neal_B

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Budgie,

    Worked like a charm. I used this part:

    tell active doc

    set _Name to name

    if modified is true then

    save to file (Default_Path & _Name) -- Save as required… For Certified Document

    close

    end if

    end tell

    Thanks