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/

Reply via email to