Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating PDF's less than 90 degrees

Tags:

pdf

I'm working with a bunch of PDF files, some of which have been scanned at a bit of an angle. Adobe Acrobat allows me to rotate PDF files by 90 or 180 degrees. But is there a way to rotate a PDF just a few degrees - just enough to make it straighter?

I could perhaps take a screenshot, open it in Photoshop and rotate it, then somehow convert the Photoshop file to a PDF. However, that seems like a really clumsy process.


1 Answers

PDF supports for complete pages only /Rotate values of 90 degrees, because that is (of course) simple. What you need to do is rotate the contents, not the page. So you need to use something which can remake the PDF file for you.

You could use either Ghostscript or MuPDF to do this. Either will require some coding:

  • MuPDF will require coding in C,
  • Ghostscript will require you to do some PostScript programming.

Using Ghostscript you would need to define a BeginPage procedure which rotates the content by a small amount and moves the origin of the content slightly as well (because the rotation rotates around the origin, which is at the bottom left, not the centre).

like image 140
KenS Avatar answered Dec 11 '25 15:12

KenS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!