Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Styles in iText

 
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
 
author
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...
 
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
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.
 
A berm makes a great wind break. And Iwe all like to break wind once in a while. Like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!