尝试使用pdfstamper来操作pdf我不知道代码中有什么错误,它不会在输出文件中打印文本字段。提前致谢
PdfReader reader = new PdfReader("Players.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(Result));
AcroFields form = stamper.getAcroFields(); // using acro fields to fill out the pdf
form.setGenerateAppearances(true);
rs = statement.executeQuery("SELECT * from Players");
while ( rs.next() ) {
String Country = null;
Country = rs.getString("CName");
System.out.println(Country);
if (rs != null)
Country = rs.getString("CName");
form.setField("Country",Country);
}
stamper.setFormFlattening(true);
stamper.close();
connection.close();