dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
121 stars 32 forks source link

A "reason" can be entered when placing the digital signature #64

Closed gabrieltosh closed 7 months ago

gabrieltosh commented 9 months ago

I need to enter the signature detail, but I see that the set_signature_certificate function is only for the certificate, is there any other function?

dealfonso commented 9 months ago

hi, do you mean a visible text for the signature?

gabrieltosh commented 9 months ago

Hello Alfonso, if reviewing the code I saw that there is a function for the metadata for the signature, is this function available?

dealfonso commented 9 months ago

hi,

there is a "reason" value in the metadata, which appears as metadata for the signature but has no visual effect (i.e. it is not rendered). If you use the PDFSignatureObject class, you can add the metadata and it would be added to the resulting PDF.

But the thing is that the library does not implement adding a reason at this moment at an upper level. It is easy to implement (e.g. adding a new parameter to the set_signature_appearance or creating a new method). Please try it and if you manage to include it, please pull it to the library.

aphoe commented 7 months ago

Hi @dealfonso,

Please give me a pointer on adding info to the signature.

I want to add Reason, Name, Location, and ContactInfo to the signature. I want to do this by adding the extra parameter to set_signature_certificate() since it will be invisible.

I have tried tweaking _generate_signature_in_document() by setting the metadata of the PDFSignatureObject created in __generate_signature_in_document() on Line 400

This doesn't work. The document doesn't come out with a signature instead.

I have also tried to add a "Reason" element to the $annotation_object on Line 403 But it doesn't work.

Hopefully, I can get this right and do a PR.

This is what the fields are supposed to look like if it works properly. Screenshot 2024-03-26 163942

Thanks for all the work and your response.

aphoe commented 7 months ago

@dealfonso Hi, I have figured this out. And I have created a PR. Please review it as soon as you can. Thank you!

dealfonso commented 7 months ago

I find that PR #68 solves this problem