Adding a PDF fillable form (acrofield) using Apache FOP
Asked Answered
R

1

5

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?

Royo answered 14/8, 2015 at 10:57 Comment(3)
As you also want the end-user to be able to save the PDF from Adobe Reader... in which Adobe Reader versions shall that be possible? Older Reader versions require the PDF to be specially signed to allow saving.Organometallic
Specifying newer versions is okay.Royo
github apache/fop-pdf-images claims limited support for AcroForms (PDF forms). Might be worth looking into.Organometallic
S
11

(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"/>
Subak answered 17/8, 2015 at 16:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.