tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.13k stars 1.51k forks source link

Automatically lock document after signing signature field #313

Open ajtik opened 3 years ago

ajtik commented 3 years ago

Hello,

could you please forward me, how to make auto document lock (all fields or just some) after signing signature? After investigation I assume this library doesn't support this. I tried to add this functionality with my dumb way(i do not really understand the specification) by adding to

https://github.com/tecnickcom/TCPDF/blob/main/tcpdf.php#L9991-L10008

$actionObj = $this->_getobj(); $out .= ' /FT /Sig /Lock 55 0'; 55 0 is id of $actionObj lower - just for testing purposes

and new object after that:

$out = $actionObj . "\n"; $out .= '<</Action/All/Type/SigFieldLock>>'; $out .= "\n".'endobj'; $this->_out($out);

result in PDF is:

20 0 obj << /Type /Annot /Subtype /Widget /Rect [300.473000 283.888026 552.756465 354.754168] /P 24 0 R /F 4 /FT /Sig /Lock 55 0 /T (vlozpodpis) /Ff 0 >> endobj 55 0 obj <</Action/All/Type/SigFieldLock>> endobj

But that signature dissapears and cannot be signed. I have some other PDF(not generated by this library, just pdf - do not know how it's done there), when it's working like this:

231 0 obj <</AP<</N 253 0 R>>/DA(/TrebuchetMS 0 Tf 0 g)/F 4/FT/Sig/Lock 254 0 R/MK<<>>/P 20 0 R/Rect[277.856 89.9239 523.966 173.706]/Subtype/Widget/T(Podpis_Zadavatel)/Type/Annot>> endobj 254 0 obj <</Action/All/Type/SigFieldLock>> endobj

I think I'm close, but i do not really understand that specification to make it finished. I tried also Javascript, but I think thats not exactly the way I want it, because there are some permissions for functions.

I'm trying to do it by following specification:

https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdf_reference_archive/pdf_reference_1-7.pdf

Page 695 and lower

ajtik commented 3 years ago

Finally after 3 days I've found, how can I do it.. I will make pull request with that feature soon. I think it might be useful for more people..

galihlasahido commented 3 years ago

hi @misfit98 have you made the PR? can you share the solution with us?