# Rotate pdf file less than 90 degree?

How can I rotate a PDF file less than 90 degree under Ubuntu?

Can I do that interactively?

• Is this even possible without rasterizing? I know you can do it with Postscript, but I don't know if PDF supports rotating everything at arbitrary angles. – Gilles Oct 5 '13 at 14:39
• @Gilles - I don't think you can rotate in degree increments. There's a flag in the PDF file that is being manipulated, but it's only in 90 degree increments from what I've found thus far. – slm Oct 5 '13 at 14:48
• @Gilles It certainly is, see my answer. – Marco Oct 7 '13 at 8:48
• This has also been asked on stackoverflow.com. I posted a LaTeX solution there. – Phimor Oct 22 '18 at 13:27

I looked hard and long and could find no tool that allowed you to do this interactively that is a native PDF viewer type of tool. I did not try this but you might be able to use Inkscape or Gimp to do this. I think the only issue you'll likely run into with using them is the ability to batch rotate a multi-page document.

Even the command line tools such as PdfTk couldn't do rotation by degrees, which really surprised me.

However using ImageMagick you can rotate PDF files in 1 degree increments.

### Examples

$convert original.pdf -rotate 45 rot45.pdf  You can put any value you want in for the rotate argument. It will also take negative numbers so this is possible: $ convert original.pdf -rotate -45 rot-45.pdf


The quality of the output will drop off dramatically using the default options so you'll likely need to include the -density switch to increase the quality of the resulting PDF file.

\$ convert -density 300x300 original.pdf -rotate 45 rot45.pdf


### Resulting PDF

Here's a screenshot of Evince with the resulting PDF file.

• Imagemagick or Gimp rotate by first rasterizing, which is often not desirable. – Gilles Oct 5 '13 at 14:35
• @Gilles - yeah I know, I've been searching for another method, but coming up empty. There is an SU Q&A that shows using programmatic methods, but that seems a bit beyond what would be appropriate here. Have you found any other methods. There was a page I came across that said Acrobat Pro can do rotates by 1 degree increments but I couldn't tell if it was doing rasterizing too or not. – slm Oct 5 '13 at 14:47
• Thanks,slm! Can the method by convert rotate every page in a single multiple-page pdf file? @Gilles: in my case, the pdf files are created by scanning. So I think rasterizing first doesn't matter? – Tim Oct 5 '13 at 14:49
• @Tim - yeah since they're scans they've already been rasterized. Yes it does every page. – slm Oct 5 '13 at 14:54
• @Tim - yes, that's what the example shows, it converted a multi-page document. – slm Oct 28 '13 at 17:06

You can do that with ConTeXt.

• does not rasterize
• allows for individual angles for individual pages
• allows for varying page sizes

Versions before 2013.10.07 09:47 had a bug which cropped the pages, so make sure you use a version including the fix.

First create a file (e.g. rotatepdf.tex) with the following content

\getfiguredimensions [\getdocumentargument{input}]
\starttext
\dorecurse{\noffigurepages}
{\startTEXpage
\externalfigure
[\getdocumentargument{input}]
[page=\recurselevel,
orientation=\getdocumentargument{rotation}]
\stopTEXpage}
\stoptext


Then you can rotate a PDF using the following command line:

context --input=somefile.pdf --rotation=10 rotatepdf.tex


Here is an example output:

You could import it with GIMP, which includes a rotate tool and can export back to pdf.

• Gimp rasterizes first, which is often not desirable. – Gilles Oct 5 '13 at 14:38

This has also been asked on stackoverflow.com.

Another option is using LaTeX:

\documentclass{standalone}
\usepackage{graphicx}

\begin{document}
\includegraphics[angle=-1.5]{odd-scan}
\end{document}


In this case, I have the file odd-scan.pdf (a slightly rotated one page scan) in the same folder as the LaTeX file rotated.tex with the content above and then I run pdflatex rotated.tex. The output is a file rotated.pdf with the PDF rotated by 1.5 degrees clockwise.