我有一个要求,用户将在pdf表单上填写许多字段(文本字段、复选框、单选按钮),然后将其发送给我们。我需要读取pdf表单上的每个字段并插入到Oracle表中。
Edit1:我正在尝试以下代码,它生成了pdf文件,但当我双击它时显示“无效格式”。出了什么问题?
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfWriter;
public class pdfGentest{
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("c:\\HelloWorld.pdf"));
document.open();
document.add(new Paragraph("Hello World"));
}
catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
}
}
修复:由于我没有关闭文档,添加document.close();解决了问题。