Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a PDF fillable form (acrofield) using Apache FOP

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?

like image 950
Kristof Avatar asked Dec 25 '22 15:12

Kristof


1 Answers

(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"/>
like image 193
lfurini Avatar answered Jan 05 '23 23:01

lfurini