Java 类com.itextpdf.text.html.simpleparser.HTMLWorker 实例源码

项目:oStorybook    文件:ExportPDF.java   
@SuppressWarnings("deprecation")
public void HtmlToPdf(String source) {
    StyleSheet styles=null;
    try {
        List<Element> elements = (List<Element>) HTMLWorker.parseToList(new FileReader(source), styles);
        for (Element el : elements) {
            outDoc.add(el);
        }
        File wx=new File(source);
        wx.delete();
    } catch (IOException | DocumentException ex) {
        SbApp.error("ExportPDF.HtmlToPdf("+source+")", ex);
    }
}
项目:SE-410-Project    文件:ExportPDF.java   
@SuppressWarnings("deprecation")
public void HtmlToPdf(String source) {
    StyleSheet styles=null;
    try {
        List<Element> elements = (List<Element>) HTMLWorker.parseToList(new FileReader(source), styles);
        for (Element el : elements) {
            outDoc.add(el);
        }
        File wx=new File(source);
        wx.delete();
    } catch (IOException | DocumentException ex) {
        SbApp.error("ExportPDF.HtmlToPdf("+source+")", ex);
    }
}
项目:coj-web    文件:BasePdf.java   
protected File generarPdf(String author, String creator, String subject, String title, String contenido, String ruta, boolean concat) {


        Document document = new Document(PageSize.A4, 35, 30, 70, 50);
        FileOutputStream fileO;
        File file = new File(ruta);
        if (!file.exists()) {
            try {
                if (concat) {
                    fileO = new FileOutputStream(new File(ruta));
                } else {

                    fileO = new FileOutputStream(ruta);
                }
                PdfWriter writer = PdfWriter.getInstance(document, fileO);

                writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));
                HeaderFooter event = new HeaderFooter();
                writer.setPageEvent(event);

                document.open();
                if (!concat) {
                    document.addAuthor(author);
                    document.addCreator(creator);
                    document.addSubject(subject);
                    document.addCreationDate();
                    document.addTitle(title);
                }

                contenido = procesarHtml(contenido);

                HTMLWorker htmlWorker = new HTMLWorker(document);
                if (concat) {
                    htmlWorker.newPage();
                }

                htmlWorker.parse(new StringReader(contenido));
                document.close();

                File file1 = new File(ruta);
                return file1;

            } catch (Exception e) {

                return null;
            }
        }

        return file;
    }