I’m trying to call pdfcrop from an applescript using “do shell script.” This is part of a larger routine that makes a call to an existing bash script, but I will shorten the example for the purposes of exposition. It displays the same errors either way.
PDCcrop is a nice, efficient perl script for cropping pdf files to a more useful size (http://pdfcrop.sourceforge.net/). I can call the script seamlessly from the terminal window and it behaves just as it should:
However, whenever I call the script from applescript:
do shell script "/usr/local/bin/pdfcrop " & docPath as string
I get the following error:
I’ve tried it several ways, and I keep getting what appears to be a permission problem, but I don’t know enough about how the permissions work to figure it out
Hi.
It’s difficult to tell what you’re really doing here. The syntax shown on the page to which you’ve linked is: “pdfcrop” followed by the original PDF file followed by the desired output size followed by the output file. The instructions say to cd to the folder containing the original file and to use just the file names. (The output file should then appear in the same folder as the original.) But presumably it’s possible to supply complete paths instead without cd-ing.
The terminal syntax you say works doesn’t contain an output size parameter.
The ‘do shell script’ command you’ve posted only contains one path and doesn’t show how that path is derived, so it’s impossible for us to know if it’s constructed correctly.
However, the error message you’ve posted suggests you may have used a path for the input file but just a name for the output file.
If the output size parameter isn’t compulsory, I’d guess that one of these two lines may be correct (with variables instead of the quoted files as required):
do shell script "/usr/local/bin/pdfcrop '/Users/me/Documents/in.pdf' '/Users/me/Documents/out.pdf'"
Or:
-- If cd's used, it must be in the same 'do shell script' command as the stuff which relies on it.
do shell script "cd '/Users/me/Documents' ; /usr/local/bin/pdfcrop 'in.pdf' 'out.pdf'"