About us | News | Contact
iText ® Licenses Support   
You are here: Home > Forums > iText in Action — Second Edition > Part 4: Under the hood > Chapter 13: PDFs Inside-out
User login
  • Request new password

Rotate Page and Trimbox

Submitted by philikran on Thu, 07/26/2012 - 13:32

In my implementation i use iTextSharp, but i think that is not the problem :)

I rotate the pages of an pdf-file with the following functions:

pdfreader.GetPageN(pageNumber).Put(PdfName.ROTATE,
new PdfNumber(currentDegree + rotateDegree));

This works fine. When i view the file with the acrobat reader, the pages are rotated. But when i read the boxes, i see, that all boxes are the 'old' boxes and only the Rotation-property is set. Only the 'view' is rotated, but not the Trimbox itself (so like all boxes).

How can i rotate the boxes too? How can i rotate the page include all boxes?

Thank you.

Philipp

Does iText support Linearization? ›
  • Login to post comments

Maybe you're asking the wrong question

Submitted by Bruno Lowagie on Thu, 07/26/2012 - 18:20.

The best way to rotate a page, is to change the rotate value.

You could change the rectangles defining the MediaBox, TrimBox, etc by using

pdfreader.GetPageN(pageNumber).Put(PdfName.MEDIABOX, rect);

where rect is a Rectangle with coordinates different from the original value, BUT this will NOT rotate the content, NOR restructure it!

If you expect to be able to change the page boundaries without changing the rotation value, you'll have to change the coordinate system in the content stream of the page.

That's bound to fail if you're not a PDF specialist. Also: suppose you have a page where the content is in portrait, surely you can't expect the content to "reflow" to landscape after you've read and understood what's written in the book.

  • Login to post comments

Maybe it is the wrong question. What is the right?

Submitted by philikran on Thu, 07/26/2012 - 20:39.

Is there no other way to rotate a page 'real' (with iText)? For me it is not enough to rotate it via the rotate-proberty only.
When i rotate the page how explained in my first post, and then change the Trimbox, will i have only for example a half page, couse the trimbox is not rotated. Isnt it?

How can i solve the rotation, so that, for example when the page is rotated to landscape, the trimbox are landscape too and the rotation is 0?

Thank you for the fast answer.

Philipp

  • Login to post comments

I honestly don't understand your question

Submitted by Bruno Lowagie on Fri, 07/27/2012 - 09:15.

Most important counter-question: do you want to repurpose the content on the page?

If so, you should read more about the nature of PDF (for example the intro of chapter 6).
If not, you can change the coordinate system of the existing content and rotate the content like that.

I have no idea why you would need to 'rotate the trimbox' or any other page boundary. We're talking about 2 coordinates: a lower-left corner and an upper-right corner.

Why do you want to 'rotate' those coordinates? I don't understand the sense of doing that.

  • Login to post comments
Content © 2010 1T3XT BVBA