我曾尝试使用飞碟将 html 转换为 pdf。不知何故,它只掩盖了痛苦的文字。我有图像(img 标签),我也想要它们。这就是我所做的。我如何为图像制作这个?
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File("sampleData.htm"));
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, "");
renderer.layout();
OutputStream os = response.getOutputStream();
renderer.createPDF(os);
谢谢!