【发布时间】:2018-05-01 12:03:30
【问题描述】:
我一直在尝试使用 Itext 库创建 PDF 文件,
这是我的方法:
private void printPDF() 抛出 FileNotFoundException、DocumentException、IOException {
OutputStream file = new FileOutputStream(new File("D:\\test.pdf"));
Document document = new Document();
PdfWriter.getInstance(document, file);
document.open();
document.add(new Paragraph("Your name is "+ l1.getText()));
document.add(new Paragraph("****************************"));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph("Your surname is "+ l2.getText()));
document.add(new Paragraph("****************************"));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph("Your Appointment Date is "+ l3.getText()));
document.add(new Paragraph("****************************"));
document.add(new Paragraph(" "));
document.add(new Paragraph(" "));
document.add(new Paragraph(new Date().toString()));
document.close();
file.close();
}
但是,当我运行时,我遇到了多个与 io 相关的错误; “找不到标志 import java.io.File;"/找不到符号 import java.io.FileNotFoundException;/找不到符号 导入 java.io.FileOutputStream;代号一的io有问题吗!!??
请澄清!
【问题讨论】:
-
Ps:我在一个java项目中使用过类似的方法,效果很好!
-
我已经看到以前的答案推荐使用“FileSystemStorage”,我已经这样做了,它想通了所有..现在我只是很困惑在哪里存储我的文件以便在本地检查它我的笔记本电脑!!??
标签: codenameone