Forum News

PDF Forms

The latest build of Prince now supports PDF Forms!

You can generate the form from the attached HTML like this:
prince --pdf-forms simple-form.html

This creates a form that can be filled in with Acrobat or other PDF viewers and saved or printed. You may also wish to specify --pdf-profile=PDF/UA-1 for accessibility.

Most HTML form controls are supported and it is also possible to include submit and reset buttons, although not every PDF viewer supports these yet.

The new --pdf-forms option is a shorthand for applying "prince-pdf-form: enable" to all of the form elements; this new CSS property allows individual form elements to be selectively enabled or disabled. We may enable PDF Forms by default in Prince 15.

Please try the latest build and let us know how you go! :D
  1. form.png34.5 kB
  2. simple-form.html1.9 kB
  3. simple-form.pdf49.3 kB
That's wonderful! Do you have an ETA for the next official release including this feature?
The latest builds are official, the numbered releases are primarily to ensure backwards compatibility.
Thanks Mike!

So, would you recommend a "latest build" in production? Not being backwards compatible means that a feature introduced in a "latest build" might break/behave differently in a future release, is that right?
We try to avoid this, but new features can shift in response to early feedback, yes. There is a bit of a chicken and egg issue if nobody uses it until it's frozen and we can't freeze it until people use it. :D
We know that issue very well :-)
Hi Mike, I don't think there is a clear answer, so I'll attempt to ask this question again. When will this PDF forms feature make its way to the numbered release (official)? I have done some local testing, and it looks like the latest numbered release, 14.3, doesn't have it yet. This is very important to us.
PDF Forms will be included in Prince 15.
Thank you, Mike.

Is there aproximate date for the Prince 15 release?

Edited by avishnya

It should be soon, the last item on our list is preparing a build for Apple Silicon.
Hi Make, I have downloaded an example from this page, simple-form.pdf‎, and when I opened it in the Acrobat Reader application, all the input text showed up as squares. However, it seems to work fine when the same pdf is opened in the browser (Chrome in my case). Please see the screenshots below.

I wonder what causes this and how this issue can be solved.
  1. Screen Shot 2022-08-24 at 3.20.32 PM.png241.3 kB
  2. Screen Shot 2022-08-24 at 3.21.14 PM.png235.6 kB
Hi Mike, I did some digging, and it looks like the font reference attached to the form field have the weird prefix PXAAAA+. Please see the attached screenshot for more details. I'm seeing the same thing when I generate my PDF with forms. In my case, it referencing PXAAAA+Helvetica
  1. Screen Shot 2022-08-24 at 5.32.41 PM.png471.2 kB
We will investigate this issue, in the meantime please try disabling font subsetting with --no-subset-fonts.
Hi Mike, thank you for the quick response "--no-subset-fonts" option worked for us.
We have fixed this issue in the latest builds and font subsetting should work correctly with PDF Forms now.
First off, this is an amazing add and will save us a lot of time.

Quick feature request, could it also read the html "type" attribute and create applicable PDF fields based on that? Such as input type="date" making a "Date" field in the PDF and input type="number" using number formatting by default (Bonus points for reading the min, max and pattern attributes as well for this!). Would also like to replicate the native "Digital Signature" field you can add in Acrobat if possible. Thanks!
I think that's possible but it might need to a wait a while, PDF doesn't seem to have specific field types so dates and numbers are implemented via AcroJS extensions.
Can we set font settings for PDF form fields? Specifically I would like to set the "Auto" font size so text autoscales to fit inside the field in case the content runs long.
Just noticed the documentation page has a typo.
-prince-pdf-form: enabled;
should be
-prince-pdf-form: enable;

Was banging my head for 15 minutes on that one!

Try DocRaptor - PrinceXML web service and official PrinceXML partner

Just noticed the documentation page has a typo.

Uh, apologies - and thank you!

The property itself was documented with the correct value - this typo is now fixed in the docs!