Adding a PDF fillable form (acrofield) using Apache FOP

拈花ヽ惹草 提交于 2020-01-01 15:34:04

问题


I am trying to add a fillable form (so the end-user can insert information into it using acrobat reader and then save it) to a PDF I generate using Apache FOP. I can't seem to find any information on how this is done, if it is possible.

Google doesn't give much relevant information, mostly on the fact that it's not possible, but most of that information dates from the early 2000's.

Is there a way to add acrofields using FOP?


回答1:


(disclosure: I'm a FOP developer, though not very active nowadays)

The XSL-FO language, which is FOP's input language, does not have formatting objects defining form fields, so FOP cannot create AcroForms from scratch (you would need to develop an extension to achieve that).

However, as user @mkl told in a comment, the PDF images plugin allows to include pages from an existing PDF file in the final PDF created by FOP, as if they were images; according to the release notes, the plugin provides "limited support for AcroForms (PDF forms)".

So, if you already have a PDF form you can either use it like a normal image:

<fo:block>
    <fo:external-graphic src="my-doc.pdf#page=1"/>
</fo:block>

or insert all of its pages with an extension element at the fo:page-sequence level:

<fo:page-sequence>
    <!-- ... -->
</fo:page-sequence>

<fox:external-document src="my-doc.pdf" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"/>


来源:https://stackoverflow.com/questions/32008430/adding-a-pdf-fillable-form-acrofield-using-apache-fop

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