How to rotate a page in pdf file without using the `Rotate` key value?

-2

1

It seems that pdf file has some internal mechanism in handling the page rotation, that when you rotate a page in your software (adobe reader, mac os preview, etc), the software will only add a rotation marker to the page instead of changing the orientation of the page in storage. (I think this is the same mechanism as the way mpeg handles video rotation.)

My question is, is there any command line tool that I can rotate a page in pdf file solidly? That instead off simply applying a marker, I want the actual page in storage to be rotated, like any virtual pdf printer will do.

===================

Update:

On page 78 of the PDF Specification 2008, it mentions that the PDF's page object has an integer key value Rotate that you can set to tell the software how the page should be displayed. This value shall be multiple of 90 degrees. enter image description here

So what I am trying to achieve here is:

Rotate the page (say) 90 degrees physically instead of simply setting the Rotate key value to 90. (That's to say the value of Rotate should remain 0 after rotation.)

huangzonghao

Posted 2018-09-15T23:51:41.790

Reputation: 149

Question was closed 2018-09-16T07:45:40.863

Answers

1

You should use a software that can write PDF files, as opposed to just displaying them. Adobe Reader and Mac OS preview were never intended to edit PDF files, as their names clearly suggest.

You have three types of solution:

  1. online services
  2. GUI desktop software
  3. command line tools

You seem specifically interested in the third category, but you'll find examples of all three mentioned in the answers to this same question on UnixLinux.

PDFtk:

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

pdfjam:

pdf90 input.pdf

Ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/All -sOutputFile="$outputFile" "$file"

simlev

Posted 2018-09-15T23:51:41.790

Reputation: 3 184

No not quite. Both pdftk and pdfjam use markers to rotate the pages. I'll take a look at ghostscript – huangzonghao – 2018-09-16T01:14:59.347

And please note the difference between this question and the one you mentioned on UnixLinux and restrain from simple copy and paste – huangzonghao – 2018-09-16T01:18:03.150

How do you infer they use markers? What's your definition of marker? Please highlight the differences between the linked question and yours because they are not obvious. – simlev – 2018-09-16T01:26:02.970

Hey look, you don't seem to understand the way pdf works at the first place. If that's the case, what's the point of forcing yourself to make an answer, especially in this copy and paste manner? – huangzonghao – 2018-09-16T01:30:06.660

If you want, you may take a look at the pdf specification and get some insight of how it actually works. And hopefully you would then be able to understand what we are talking about here

– huangzonghao – 2018-09-16T01:36:54.313