Closed pindamonhangaba closed 4 years ago
Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/
@pindamonhangaba In that case it might sense to mark the fields as read-only. That is apply the models. FieldFlagReadOnly flag to the fields. Does that make sense?
For example you could use https://github.com/unidoc/unipdf-examples/blob/c13fc5b8555c55cbddd76eed00daa6e3680b3943/forms/pdf_form_fill_json.go#L118. and instead of flattening the form, you can iterate through all the fields and apply the read only flag.
Example for iterating through fields: https://github.com/unidoc/unipdf-examples/blob/c13fc5b8555c55cbddd76eed00daa6e3680b3943/forms/pdf_form_list_fields.go#L71
NOTE: In the future we might add to our JSON schema to support flags so that they can be read and applied just through the JSON which would make it very easy to use.
It does work, however Microsoft Edge renders the multiline field I set as readonly as a single line with huge font size. Can a field have more than one flag? To set the field as both readonly and multiline?
I'll see if I can just flatten the multiline field
The flags are bitwise, so you can set multiple flags, can use https://github.com/unidoc/unipdf/blob/22e282c10605a4a10097c972fb3c1dd52327275c/model/fields.go#L68
Description
There is no way to prevent a pdf's forms to be filled after signing, if you don't flatten the fields. Currently pdf editors like Adobe & Foxit can sign a pdf file and immediately lock the form from further editing. Seems like the only way to do that with unipdf is to flatten the fields, but then I lose all reference to those fields, unlike both Adobe and Foxit (if you hover the fields, the name appears). I need to create signed pdf that are validated with both the signature and the fields by name, so the form can't be destroyed.
Expected Behavior
I expect to be able to lock the fields while/after signing the pdf, just like in Adobe/Foxit. I'm not sure if those editors lock or encrypt the form, but I need to achieve the same behavior with unipdf
Actual Behavior
Currently if I sign a pdf, save it, then open and encrypt it without
security.PermFillForms
, when I open the pdf in an editor the form fields are still active.I'm using the code from the examples to fill, sign, append & write. Form is still open and can be edited even if I run the encrypt example over the signed pdf.
Attachments
The original template: template.pdf
After signing: template-signed-adobe.pdf