iTextPDF-无法将HTML转换为PDF

时间:2019-01-06 06:00:57

标签: java itext

我正在构建一个Java Web服务应用程序,我想在其中将HTML文件转换为PDF并向特定的电子邮件地址发送电子邮件。

从XHTML转换为PDF。

                 try {

                    File outputFile = new File("D:\\Files\\Output_Files\\" + System.currentTimeMillis() + ".pdf");
                    OutputStream file = new FileOutputStream(outputFile);
                    Document document = new Document();
                    PdfWriter writer = PdfWriter.getInstance(document, file);
                    document.open();
                    InputStream is = new ByteArrayInputStream(htmlString.getBytes());
                    XMLWorkerHelper.getInstance().parseXHtml(writer, document,is);
                    document.close();
                    file.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

我已验证htmlString,并且其中包含确切的HTML字符串。

请查看我的HTML内容here

问题是我正在接收PDF,但它没有任何内容,但是页面为空。

0 个答案:

没有答案
相关问题