aspose file tools*
The moose likes Other Open Source Projects and the fly likes Styles in iText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Styles in iText" Watch "Styles in iText" New topic
Author

Styles in iText

bill Papadopoulos
Greenhorn

Joined: Dec 21, 2009
Posts: 7
I also welcome Bruno in this forum and hope (i am sure actually...) a sucess to his new book.
It is an honor to have you here.

I do not know if this disussion has the meaning of posting questions to Bruno.
If this is not the meaning, please forgive me and ignore my question.

So, my question is the bellow:

I use iText 2.1.5 to generate automatically pdfs with servlets, in Java 1.5 and Tomcat Servlet container, by converting my html code.
My main concern is how to apply the style of my html code into generated pds.
Till now I use (example) bellow code to apply style of html:



...and with this way i try to apply in each html tag the style i wish.

My question is this:
Is there an easiest way where (for example) i will provide the style of my html in text, as bellow:



and iText will generate automatically these styles into my pdf?

Thank you in advance for your answer,
Papadopoulos Vasileios
Bruno Lowagie
author
Ranch Hand

Joined: Oct 23, 2006
Posts: 88
bill Papadopoulos wrote:My question is this:
Is there an easiest way where (for example) i will provide the style of my html in text, as bellow:



and iText will generate automatically these styles into my pdf?


I've discussed about writing a StyleSheet parser with different developers.
I did an attempt myself to write one, and I failed.
As it turns out: parsing a (complex) StyleSheet correctly is difficult,
and currently, we don't have such functionality in iText...
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
If your HTML can be made into XHTML that is styled with CSS, then the best way to convert that into PDF is the FlyingSaucer library (on dev.java.net). FlyingSaucer actually uses iText underneath (as do many of the other PDF-generating Java projects like FOP and JasperReport).
bill Papadopoulos
Greenhorn

Joined: Dec 21, 2009
Posts: 7
Thank you both for your answers.
Bruno Lowagie
author
Ranch Hand

Joined: Oct 23, 2006
Posts: 88
Lester Burnham wrote:If your HTML can be made into XHTML that is styled with CSS, then the best way to convert that into PDF is the FlyingSaucer library (on dev.java.net). FlyingSaucer actually uses iText underneath (as do many of the other PDF-generating Java projects like FOP and JasperReport).


Yes, I mentioned Flying Saucer (aka xhtmlrenderer) in another thread.
iText is used in JasperReports and some Formatting Objects processors
(e.g. the one sold by Inventive Designers), but I don't think it's used in
Apache FOP; the Apache FOP mentions iText for post-processing, but
as far as I know Apache FOP has its own PDF engine.
 
wood burning stoves
 
subject: Styles in iText