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

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

Introduction

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

Prototype

public void parseXHtml(final PdfWriter writer, final Document doc, final InputStream in,
            final InputStream inCssFile) throws IOException 

Source Link

Usage

From source file:com.verbox.PrintHtml.java

public static void RenderPDF_img_too(String inpHtml) throws FileNotFoundException, ParserConfigurationException,
        SAXException, IOException, DocumentException, PrinterException {
    try {//from w  w w . j  av a  2s. c  om
        fullhtml = inpHtml;
        String replaceAll = fullhtml.replaceAll("../../image/", "");
        Document document = new Document();
        // step 2
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("pdf.pdf"));
        // step 3
        document.open();
        // step 4
        XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
        InputStream is = new ByteArrayInputStream(replaceAll.getBytes(StandardCharsets.UTF_8));
        worker.parseXHtml(writer, document, is, Charset.forName("UTF-8"));
        // step 5
        document.close();
        PreImgPrint();

    } catch (DocumentException | IOException E) {
        JOptionPane.showMessageDialog(null, "Exeption on print or prepare image " + E);
    }
}