1
我用下面的方法来创建一个PDF文件中显示:的Apache PDFBox的2.0文本不中创建PDF文件
private void createPdf() throws IOException {
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage(new PDPage());
PDPageContentStream content = new PDPageContentStream(doc, page);
content.beginText();
content.setFont(PDType1Font.HELVETICA, 26);
content.showText("Example Text");
content.endText();
content.close();
doc.save("report.pdf");
doc.close();
}
它创建一个具有白页的新文件,但没有文字显示。怎么了?
我使用Apache PDFBox 2.0.7。
你看过页面的底部吗? –
维加,@蒂尔曼暗示的是,你没有指出任何文字的位置。因此,它在(0,0)处绘制,如果代码位于页面的左下角。 – mkl
我仔细检查过,但页面上没有任何内容。感谢提示。任何其他想法? – Vega180