Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Other Open Source Projects and the fly likes Create PDF in Landscape using ITextRenderer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Create PDF in Landscape using ITextRenderer" Watch "Create PDF in Landscape using ITextRenderer" New topic
Author

Create PDF in Landscape using ITextRenderer

Emanuel Borsoi
Greenhorn

Joined: Mar 27, 2012
Posts: 15
Hi, i'm using iText to create the PDF from Strings (HTML code). Here my code:



As you can see, i'm using org.w3c.dom.Document in order to ba able to parse a HTML code including all internal style attributes. My problem is that in this way i'm not able to create a landscape PDF. The solution would be to use com.itextpdf.text.Document and create a object using new Document(PageSize.A4.rotate()); but then it's not possible to use iTextRenderer and parse my HTML-String.

Any hints?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I'm confused. ITextRenderer is part of FlyingSaucer, but Document is part of iText. While FlyingSaucer does use iText underneath, I don't think you can mix and match classes like that.
Emanuel Borsoi
Greenhorn

Joined: Mar 27, 2012
Posts: 15
Tim Moores wrote:I'm confused. ITextRenderer is part of FlyingSaucer, but Document is part of iText. While FlyingSaucer does use iText underneath, I don't think you can mix and match classes like that.


well...then i did a little bit of confusion.
But my problem remains. I need to create a landscape PDF parsing HTML code. Is it possible? The code you see above works, but i can't find the way to set the document format before writing to it.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Does this help: http://stackoverflow.com/questions/613971/both-landscape-and-portrait-for-pdf-with-flying-saucer-itext

First result in creating landscape pdf using flyingsaucer.
Emanuel Borsoi
Greenhorn

Joined: Mar 27, 2012
Posts: 15


Not really, i don't know where to put "@page land { size:landscape; }". I've tried in my css but it doesn't work.

Tim Moores wrote:First result in creating landscape pdf using flyingsaucer.


Sorry, but i thought that iTextRenderer is part iText.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
but i thought that iTextRenderer is part iText.

Nope, part of FlyingSaucer.
Emanuel Borsoi
Greenhorn

Joined: Mar 27, 2012
Posts: 15
Tim Moores wrote:
but i thought that iTextRenderer is part iText.

Nope, part of FlyingSaucer.


now, i've seen...

EDIT:

Once read this it became clear
 
jQuery in Action, 2nd edition
 
subject: Create PDF in Landscape using ITextRenderer
 
Similar Threads
PDF creation using iTEXT
Rendering html PDF Itext weird character Â
Flying Saucer and Itext
Rendering PDF in browser using Flying Saucer
How to save a webpage as PDF ?