public class GeneratePDF {
public static void main(String[] args) {
try {
String k = "<html><body> This is my Project </body></html>";
OutputStream file = new FileOutputStream(new File("E:\\Test11.pdf"));
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, file);
document.open();
InputStream is = new ByteArrayInputStream(k.getBytes());
XMLWorkerHelper.getInstance().parseXHtml(writer, document, is);
document.close();
file.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
这是我将 HTML 转换为 Pdf 以用于静态和小内容 Html 的代码,它工作正常但是对于动态和长 Html 内容,它 com.itextpdf.tool.xml.exceptions.RuntimeWorkerException 这个 Excpetion 请帮助我在哪里做错了。