thst
thst

Reputation: 4602

Rotate a PDF without changing orientation

while the topic of my question seems to be a well supported feature of many PDF manipulation packages and tools out there, I need to make clear that I don't want to rotate the PDF.

I have a PDF that exposes a portrait orientation (A4) with dimensions WxH 297x210 (A4 rotated).

Now, what I need to achieve, is that this PDF has landscape orientation while preserving the dimensions.

I am not sure what this requires me to do.

If I use Adobe Illustrator to change document format to the desired position, I also need to rotate the contents. If I put this page into the badly designed PDF, the formfields and all annotations on this page are still in the portrait orientation.

How can I rotate them to match the new page orientation? There seems to be no tool support for this kind of task.

Thanks for your support!

Thomas

Upvotes: 0

Views: 7851

Answers (3)

thst
thst

Reputation: 4602

First I fixed the PDF.

It seems, that cpdf -upright will also fix this. If you cannot use cpdf, because of commercial use, you can use a manual approach as shown with Adobe Illustrator.

cpdf did not correct the Acrofields orientation and not the annotations in the pdf. I had to recreate the annotations. The Acrofields can be fixed using JavaScript as shown below.

  1. open the PDF in Adobe Illustrator
  2. Repeat for each page 1..n of your document, the current page is "x" in the following steps:
  3. Create a new document in A4, landscape mode, make sure the size is exactly 297x210 (WxH)!
    1. Open the PDF page x in Illustrator
    2. Copy all Elements of page x onto the new document using copy / paste functions
    3. Use Object/Transform/Rotate to rotate to the right angle, usually you need -90° or +90°
    4. Place the rotated objects on the page to match your expectations
    5. Save the document as "page-x.pdf"
    6. Close the PDF page x
    7. Repeat with next page until done...
  4. Open Acrobat X to merge the single page-....pdf into one large PDF. Check the online documentation if you are unsure about this. Don't mess the order of pages!
  5. Open the broken PDF
  6. Save with a new name
  7. Open the pages tool, choose "replace pages" function.
  8. Select the merged PDF as page source and replace all pages in the broken PDF with the fixed pages from the merged PDF.
  9. You should see the fields, standing in a 90° angle from the position where they are supposed to be

Then I fixed the Acrofields using the PDF JavaScript in Acrobat Pro.

  1. Open the Javascript console.
  2. Enter the following script:

    var box = getPageBox();
    var  w = box[2] - box[0];
    var  h = box[1] - box[3]; 
    // left,top         right,bottom
    // bottom, h-left     top, h-right
    for(i=0; i<numFields; i++) {
        var f = getField(getNthFieldName(i));
        var orig = f.rect;
        f.rect = [orig[3], h-orig[0], orig[1], h-orig[2]];
        f.rotation = 0;
    }
    

    To execute, highlight the script and press the ENTER Key, NOT RETURN. The ENTER Key is the enter-key on the keypad. This will execute the highlighted JavaScript. The formfields will be rotated by +90° and should be placed almost correct, but at least near the position, where they are supposed to be.

  3. Go through all pages, select all fields on the page, and move all fields together to the right position.

Upvotes: 0

johnwhitington
johnwhitington

Reputation: 2763

It's not completely clear what you want, but I think it might be that you want to change the viewing rotation, counter-rotating the content and page dimensions to compensate.

In which case, the CPDF command line tools can do this:

cpdf -upright in.pdf -o out.pdf

which will make the viewing rotation 0, rotating the contents and changing the page dimensions to compensate. You can then change the viewing rotation as you like with

cpdf -rotate <angle> in.pdf -o out.pdf

(absolute) or

cpdf -rotate-by <angle> in.pdf -o out.pdf

(relative) where <angle> is 0, 90, 180, 270, 360.

If this doesn't suffice, you also have

cpdf -rotate-contents <angle> in.pdf -o out.pdf

where is a number of degrees to rotate clockwise, and

cpdf -mediabox "minx miny width height" in.pdf -o out.pdf

Upvotes: 3

Huy TRAN
Huy TRAN

Reputation: 496

You can use FoxitReader. Is it free and it has a function HOME -> ROTATE VIEW, which does what you want.

Upvotes: 0

Related Questions