Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Styles in iText

 
bill Papadopoulos
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for your answers.
 
Bruno Lowagie
author
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic