Replying to my own post, one solution would be:

Document doc = new Document(PageSize.A4, 50, 50, 108, 80);
OutputStream SalidaPdf = new FileOutputStream("C:/test.pdf");

PdfWriter writer = PdfWriter.getInstance(doc, SalidaPdf);
doc.open();
doc.resetPageCount();

try {
   new HTMLWorker(doc).parse(new StringReader("<b>Hello World</b>"));
} catch (Exception e) {
   e.printStackTrace();
   System.out.println("error parse a pdf" + e.toString());
}
doc.close();

That works in case the String is very simple HTML. But in a different case with some
more Tags, the PDF looked strange. The same line was drawn over and over again
at the same position.


Does the Snippet miss something?

Regards,
Ben

Hi,

I am having a String filled with HTML Tags and Text. I wonder if there
is an easy way to pass that String into a Document having all simple
Tags (like Anchor, Bold, Italic, Paragraph, BR) displayed as such.

For example a Method that returns a Paragraph, filled with correctly
styled Chunks for each simple HTML Tag (e.g. Blue / Underline and
Anchor for an A-Tag, or Bold Font-Style for Text surrounded by a B-Tag).

Regards,
Ben


------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions




------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to