I am doing some "pro bono" development for a food pantry near where I live. They are inundated with forms and paperwork, and I would like to develop a system that simply reads data from their MySQL server (which I set up for them on a previous project) and feeds data into PDF versions of all the forms they are required to fill out. This will help them out enormously and save them a lot of time, as well as get rid of a lot of human errors that are made when filling out these forms.
Not knowing anything about the internals of PDF files, I can foresee two avenues here:
Harder Way: It is possible to scan a paper document, turn it into a PDF, and then have software that "fills out" the PDF simply by saying "add text except blah to the following (x,y) coordinates..."; or
Easier Way: PDF specification already allows for the construct of "fields" that can be filled out; this way I just write code that says "add text excerpt blah to the field called *address_value*...", etc.
So my first question is: which of the two avenues am I facing? Does PDF have a concept of "fields" or do I need to "fill out" these documents by telling the PDF library the pixel coordinates of where to place data?
Second, I obviously need an open source (and Java) library to do this. iText seems to be a good start but I've heard it can be difficult to work with. Can anyone lend some ideas or general recommendations here? Thanks in advance!
解决方案
You can easily merge data into PDF's fields using the FDF(Form Data Format) technology.
Also Apache PDFBox can be used to do that.
本文探讨了一种为食品救济站开发自动化系统的方法,该系统从MySQL服务器读取数据并填充PDF表格,以减轻手工填写工作量和减少错误。作者考虑了两种技术途径:一是通过坐标定位在PDF上填写字符,二是利用PDF的内置字段填充。推荐使用支持FDF技术来轻松合并数据到PDF的字段,并提到了Apache PDFBox作为可能的工具选择。
3566

被折叠的 条评论
为什么被折叠?



