try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("Report.pdf"));
document.open();
document.add(new Paragraph("Hello World"));
document.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
Run Code Online (Sandbox Code Playgroud)
这是我在NetBeans中编写的代码,但我在第一行收到错误:
error 1 in 1st line: Document is abstract; cannot be instantiated
error 2 in 2nd line cannot find symbol ,symbol: variable PdfWriter
Run Code Online (Sandbox Code Playgroud)
您显然是导入了错误的Document类,正确的导入是com.itextpdf.text.Document,更新您的import语句,这将被修复.
| 归档时间: |
|
| 查看次数: |
5476 次 |
| 最近记录: |