Command line: How to rotate a PDF file 90 degrees

command linepdfpdftkpoppler

When I scan documents that are landscape-oriented, the output PDF files are portrait and so all the PDF viewers display the scanned documents in portrait.

From the command line, how do you rotate a PDF file 90 degrees?

I tried searching and found a bunch of solutions but I had trouble finding what looked like an authoritative solution[1] that uses a stable and robust Linux/Unix tool.


footnote [1]

For example, here is a sampling of some of the haphazard solutions I found:

  • "just use Adobe Acrobat Pro to rotate the file and then save the file"
  • "use pdfjam"
  • "use PDFtk"
  • "use ${PROGRAM_NAME} from Poppler"
  • "use ImageMagick's convert"
    — but then all the comments were very negative and stating "the image quality is ruined"
  • "open the file in a PDF viewer, then rotate, then print using a PDF printer like cutePDF or PDF printer or etc"
  • "use ${PROGRAM_NAME}", then I searched for "${PROGRAM_NAME}" and there is something about "Fedora removed ${PROGRAM_NAME} because of licensing issues"

Best Answer

Just use PDFtk.

  1. For rotating clockwise:

     pdftk input.pdf cat 1-endeast output output.pdf
    
  2. For rotating anti-clockwise:

     pdftk input.pdf cat 1-endwest output output.pdf
    

Regarding the installation of PDFtk on Fedora, I found these links:

Related Question