pbs wrote:
> Thank you - I have had a look at these examples, but they all reference an
> external html file whereas I want to pass just snippits of html.

Yes, but this method is more or less what you need:

public static boolean addText(String s, PdfContentByte canvas,
        float[] f, float size, boolean simulate)
        throws DocumentException, IOException {
        StyleSheet styles = new StyleSheet();
        styles.loadTagStyle("p", "size", size + "px");
        styles.loadTagStyle("p", "align", "justify");
        styles.loadTagStyle("p", "hyphenation", "en_us");
        ArrayList<Element> objects =
          HTMLWorker.parseToList(new StringReader(s), styles, null);
        ColumnText ct = new ColumnText(canvas);
        ct.setAlignment(Element.ALIGN_JUSTIFIED);
        ct.setLeading(size * 1.2f);
        ct.setSimpleColumn(f[1] + 2, f[2] + 2, f[3] - 2, f[4]);
        for (Element element : objects) {
                ct.addElement(element);
        }
        return ColumnText.hasMoreText(ct.go(simulate));
}

It takes a String and used HTMLWorker to create iText objects.
These are added to a ColumnText object, but you can add them
to a Document if that's what you need.

See http://1t3xt.be/?X00d
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to