How do you rotate a PDF?

Searching the internet for information on how to manually rotate a PDF finds lots of frustration. The reason I have done is this that my scanner produces pages rotated 90 degrees, and the times I have searched the internet over previous decade the answers have depressed me:

  1. Buy Adobe Acrobat Pro,
  2. Send your document off to an online service – dodgy if you value the information on that PDF,
  3. Download a program to do it, again suspect as you cannot examine the source code or understand the provenance of some programs,
  4. Buy a Mac, as the Preview preview on a Mac can do permanent rotation, and save the rotated document.

A lot of those ideas are bad for different reasons. Acrobat Pro is expensive for simply rotating a PDF; online services, even those that promise not to peek at your document, do have control of it; running strange programs isn’t recommended at all; and the world of Macs are wonderful and expensive.

There is a simpler way.

Some of the raw material in a PDF is in a format which describes the document in plain text, while some is in a binary format. The binary bits are best left alone, but the plain text parts are easy to edit in a good editor. I used Notepad++ but there are others such as Sublime Text or Atom. I realise that this is “download a program from the internet…” dressed up in different words, but these well-known editors main job is to faithfully edit things and save them without collateral damage. I also use them frequently for playing with programs that I write, so I trust them.

Within the first few lines of a PDF you will likely find a line like this:

/Rotate 0

Save a copy of the document first, then edit this line to some other multiple of 90 such as ‘180’ or ‘270’ then save the document. Multiple pages will have their own rotate declarative, so find those as well and change. On viewing the document now the page(s) will be rotated clockwise that amount of degrees. Job done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s