AppleScript – How to Print Only First 3 Pages of a PDF

automatormacospdf

I'd like to automate printing the first 3 pages of a PDF. It's fine if the document has to be split.

I have Adobe Acrobat Pro installed as well.

Best Answer

This will prompt you to select the PDF file, then print the first 3 pages of it(change the sourceFile variable if you want to choose the PDF in another way):

set sourceFile to (choose file with prompt "Choose a PDF file:" of type {"PDF"})
do shell script "lpr " & quoted form of POSIX path of sourceFile & " -o page-ranges=1-3"

If you want to have a drag-and-drop application:

on open droppedItem set sourceFile to POSIX path of droppedItem
do shell script "lpr " & quoted form of POSIX path of sourceFile & " -o page-ranges=1-3" end open