Kozea / WeasyPrint

The awesome document factory
https://weasyprint.org
BSD 3-Clause "New" or "Revised" License
7.21k stars 683 forks source link

Calculated Fields #1975

Closed braggpeaks closed 1 year ago

braggpeaks commented 1 year ago

As far as I can see, WeasyPrint does not support Calculated Fields. I don't fully understand how the implementation could/would look like, but given the Calculated Fields Examples at the bottom of the above page, if such a string is provided along with the HTML tag, it is potentially not that difficult to implement, what do you think?

<input type="text" calculatedfield="{{shipState_es_:signer1:calc([billingState]):showif(sameAs=unchecked)}}">

Is this maybe worth adding as a feature request? 😃

liZe commented 1 year ago

Hi!

As there’s nothing about this in both the HTML/CSS and the PDF specifications, we will probably never include directly this in WeasyPrint. The best solution to do this is to use a postprocessing PDF library such as pdfrw that will give you access to the PDF internals and change the fields into calculated fields.

To be honest, as it’s a proprietary feature from Adobe, I doubt that there’s any documentation about how to include this in the PDF. The best way to understand how it works and then to add this in your PDF is probably to find a PDF sample and read it to find how it’s done.

And finally, I think that this will only work on multi-license versions of Adobe Reader (not the free downloadable version), as explained at the top of the page you linked.