rotate pdf to Portrait

Hi everyone,

I am stuggling with this question:

I am developing a Filemaker Solution that creates a fax page “Fax.pdf”,
stores it in a temporary folder “Fax_Folder” on Desktop and sends it out.

This page can only be generated in landscape view.
But the fax sending unit of OS X always sends it as horizontal.

So I need a solution to trigger the rotation of the pdf from landscape to portrait,
to be triggered from within Filemaker.

Does anybody know an apple script (or a command line?) that does the job,
using any program that is coming with the standard OS X installation?

I am grateful for any help!!
Jörn

While it’s not part of the standard OS X install, pdftk (PDF ToolKit) is a fabulous command-line utility for manipulating PDF files. I use it extensively in my AppleScript workflows. It can be used to rotate individual pages or an entire PDF.

Ok, looks not easy, but will try my luck.
Thank you very much for the tip!

Hi,

Using ‘sips’ as a shell script may be easier.

use:-

set pdF to choose file with prompt "Select your PDF"
set PDF_path to POSIX path of pdF
do shell script "sips -r 90 " & quoted form of PDF_path

Hope this helps.

EDIT
After just testing this script I noticed that colour and resolution may be compromised after running the sips command on your PDF. (Although, that should not matter if you are faxing the end result)

You may wish to preform the rotation on a copy of the original!!

Actually, thinking about it, you can save the result of the sips command by adding the ‘–out’ option.

Try this:-

set pdF to choose file with prompt "Select your PDF"
set PDF_path to POSIX path of pdF
set new_Path to do shell script "echo " & quoted form of PDF_path & " | rev | cut -d'/' -f2-10 | rev"
set file_Name to do shell script "echo " & quoted form of PDF_path & " | rev | cut -d'/' -f1 | cut -d'.' -f2 | rev"
set new_Name to file_Name & "_rotated.pdf"
do shell script "sips -r 90 " & quoted form of PDF_path & " --out " & new_Path & "/" & new_Name