Forum News

PDF Forms

mikeday
The latest build of Prince now supports PDF Forms!
form.png

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
afrisch
That's wonderful! Do you have an ETA for the next official release including this feature?
mikeday
The latest builds are official, the numbered releases are primarily to ensure backwards compatibility.
afrisch
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?
mikeday
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
afrisch
We know that issue very well :-)
avishnya
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.
mikeday
PDF Forms will be included in Prince 15.
avishnya
Thank you, Mike.

Is there aproximate date for the Prince 15 release?

Edited by avishnya

mikeday
It should be soon, the last item on our list is preparing a build for Apple Silicon.
avishnya
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
avishnya
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
mikeday
We will investigate this issue, in the meantime please try disabling font subsetting with --no-subset-fonts.
avishnya
Hi Mike, thank you for the quick response "--no-subset-fonts" option worked for us.
mikeday
We have fixed this issue in the latest builds and font subsetting should work correctly with PDF Forms now.
r_moss
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!
mikeday
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.
r_moss
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.
jamespaden
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

csant
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!
twantzen
Would someone be so nice and post a simple example with -prince-pdf-form: enable;, which doesn’t require the CLI option? I couldn’t get it working:
<style>
    form,
    form textarea {
        -prince-pdf-form: enable;
    }
</style>
<div class="formtest">
    <div class="headline">Formtest</div>
    <form name="formtest">
        <textarea name="textareaTest" rows="8" cols="80" title="textareaFormTest">Prefilled text goes here ...</textarea>
    </form>
</div>


It is not editable in the PDF.

Thanks,
Tobias

Edited by twantzen

howcome
Could you post your PDF?
twantzen
@howcome,
uh – my fault: We’re still on Prince 14.3. I’ll tell the IT to upgrade ...

@mikeday I have a proposal for your announcements of newly integrated features in this forum: Would you mind writing the PrinceXML version number into your post?
So please write better
We have fixed this issue in the latest builds (v15.2) and font subsetting should work correctly with PDF Forms now.

since then I don’t have to check the post’s date and compare it to the release date in the release notes to determine the correct release for the feature, when I search the forum and find an older post with the announcement.

Edited by twantzen

mikeday
Good point! Although I suppose I will need to write "(to be included in Prince 16)" or something like that, hmm.