Example usage for com.itextpdf.tool.xml XMLWorkerHelper parseToElementList

List of usage examples for com.itextpdf.tool.xml XMLWorkerHelper parseToElementList

Introduction

In this page you can find the example usage for com.itextpdf.tool.xml XMLWorkerHelper parseToElementList.

Prototype

public static ElementList parseToElementList(String html, String css) throws IOException 

Source Link

Document

Parses an HTML string and a string containing CSS into a list of Element objects.

Usage

From source file:com.centurylink.mdw.pdf.PdfExportHelper.java

License:Apache License

private void printHtmlParagraphs(Section section, String content, int parentLevel) throws Exception {
    if (content == null || content.length() == 0)
        return;/*w  w w.  j  a v a 2 s.  com*/
    Paragraph comb = new Paragraph();
    ElementList list = XMLWorkerHelper.parseToElementList(content, null);
    for (Element element : list) {
        comb.add(element);
    }
    section.add(comb);
    section.add(new Paragraph("\n", normalFont));
}

From source file:memoire.Exercises.java

public void createPdf(ArrayList<String> list, String nameFile) {
    try {/*ww  w  .j  a  va  2  s.c  o m*/
        Document document = new Document();
        PdfWriter.getInstance(document,
                new FileOutputStream(Exam.Name + "_" + Exam.ModuleName + nameFile + ".pdf"));
        document.open();
        //String css = readCSS();
        document.newPage();

        ElementList listelem;
        for (int j = 0; j < NbrPartie + 1; j++) {
            org.jsoup.nodes.Document document1 = Jsoup.parseBodyFragment(list.get(j));
            document1.outputSettings().syntax(xml);
            String st = document1.body().html();
            listelem = XMLWorkerHelper.parseToElementList(st, null);
            for (int i = 0; i < listelem.size(); i++) {
                document.add(listelem.get(i));
            }

            //document.newPage();
        }

        document.close();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}