File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
 
 
subject: Create PDF in Landscape using ITextRenderer