And no, I'm not trying to shrink the page after the fact to fit its content.
Basically, what I'm doing is making a new PDF and populating it with all sorts
of content (text, tables, images) where I need to dynamically figure out
whether each page should be portrait or landscape (PageSize.LETTER or
PageSize.LETTER.rotate() respectively).
The only case where I am interested in changing a page to landscape is when I'm
about to add a table that has too many columns to be easily displayed on a
portrait-size page.
I suppose I either need a way to:
A.) rotate the current page I'm on (this is while I'm in the center of the
document) and then continue adding content
or
B.) figure out if what I'm about to add will "fit" on the current page
(portrait is default, so if the table is too wide then it would be better
suited on a landscape page).
a. Another example could be a table whose header row is too tall
I plan to work out your suggestion tomorrow, but I'd figure I'd leave some
specifics as to what I'm trying to do in case you or anyone else has any more
ideas.
Thanks,
Phillip
________________________________
From: Mark Storer [mailto:msto...@autonomy.com]
Sent: Tuesday, January 19, 2010 5:13 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Rotate Page After Adding Text to Document
Are you trying to shrink the page after the fact to fit its content?
I had to do that very thing just last week:
Step 1: Find out where the pages end:
Extend PdfPageEventHelper's onEndPage.
Cast the Document parameter to a PdfDocument, and call it's
getVerticalPosition( true ).
Store those "end of the page" values and save out the PDF file (to a
ByteArrayOutputStream in my case, but my files are relatively small)
Step 2:
Open the baos up in a PdfStamper and update the pages' media boxes based on the
information from step one. I suggest allowing for a margin. The position
returned from getVerticalPosition will give you the last *baseline* used, "g",
"j" and so forth (anything with a "decender") hang below that position.
Congratulations, you've turned your PDF into an HTML. Whee. (grumble
grumble... "want an HTML-like page? THEN USE HTML!" grumble grumble)
--Mark Storer
Senior Software Engineer
Cardiff.com
#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;
-----Original Message-----
From: Ponzer, Phillip [mailto:phillip.pon...@garmin.com]
Sent: Tuesday, January 19, 2010 2:58 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Rotate Page After Adding Text to Document
PDF (I'll take help over "looking witty" any day :P )
And the reason why I want to do this is because I don't know how much space the
text (or in my particular case, the table) takes up until it has been added to
the document.
Any thoughts?
Phillip
________________________________
From: Mark Storer [mailto:msto...@autonomy.com]
Sent: Tuesday, January 19, 2010 4:53 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Rotate Page After Adding Text to Document
Are we talking PDF || HTML || RTF here?
(replying "yes", "true", or "1", while witty, won't get you much help... fair
warning) ;)
--Mark Storer
Senior Software Engineer
Cardiff.com
#include <disclaimer>
typedef std::Disclaimer<Cardiff> DisCard;
-----Original Message-----
From: Ponzer, Phillip [mailto:phillip.pon...@garmin.com]
Sent: Tuesday, January 19, 2010 2:41 PM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Rotate Page After Adding Text to Document
Hello everyone, and thanks for your help with my previous question.
Here's another one:
Is it possible to rotate the page you just added text to?
For instance, we have a Document variable called "doc" whose PageSize is set to
PageSize.LETTER, and I add some text. Can I make the page where that text
appears on landscape (after adding the text)?
Thanks,
Phillip
________________________________
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient. If you are not the intended recipient, please be
aware that any disclosure, copying, distribution or use of this e-mail or any
attachment is prohibited. If you have received this e-mail in error, please
contact the sender and delete all copies.
Thank you for your cooperation.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/