How to fill out a pdf file programatically? [closed]

。_饼干妹妹 提交于 2019-11-27 05:28:17
duffymo

You can use either xsl-fo (if you like xml and xsl-t) or Lowagie's iText (Java) / iTextSharp (C#).

To elaborate on the answer by duffymo you've approved, allow me to share a chapter of my book with you: manning.com/lowagie2/samplechapter6.pdf

In section 6.3.5, you'll find out how to create a PDF template using Open Office, and listing 6.19 will show you how to fill it out programmatically:

PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();
form.setField(key, value);
stamper.setFormFlattening(true);
stamper.close();
reader.close();

Just like Frank Rem, I need to add that I'm the original developer of iText, the author of the books about iText, and the current CEO of the iText Group, answering this mail straight from the ISO committee that is discussing ISO-32000-2 (aka PDF 2.0) ;-)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!