10

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

Can I do that interactively?

4
  • 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. Commented Oct 5, 2013 at 14:39
  • 1
    @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
    Commented Oct 5, 2013 at 14:48
  • @Gilles It certainly is, see my answer.
    – Marco
    Commented Oct 7, 2013 at 8:48
  • This has also been asked on stackoverflow.com. I posted a LaTeX solution there.
    – Phimor
    Commented Oct 22, 2018 at 13:27

4 Answers 4

7

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.

   ss of pdf

10
  • 4
    Imagemagick or Gimp rotate by first rasterizing, which is often not desirable. Commented Oct 5, 2013 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
    Commented Oct 5, 2013 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
    Commented Oct 5, 2013 at 14:49
  • @Tim - yeah since they're scans they've already been rasterized. Yes it does every page.
    – slm
    Commented Oct 5, 2013 at 14:54
  • @Tim - yes, that's what the example shows, it converted a multi-page document.
    – slm
    Commented Oct 28, 2013 at 17:06
7

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:

screenshot

3

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.

1

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

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .