开发者

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

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

What techniques available to fill a pdf form automatically using external data and save them. I have to use data from a database to fill a template pdf and save a copy of it on disk with that data. Language and platform is not issue but it would be good if it can run on windows and Linux.

Any one can guide me through it or point to an开发者_JS百科y article that might help.


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) ;-)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜