Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.76k stars 647 forks source link

How to put text or image in signature #834

Closed espositovitor closed 2 years ago

espositovitor commented 3 years ago

I need put text or image in my signature without change the file structure. If I change, all my oldest signatures will be invalid. It's possible??

Type: Annot Subtype: Widget FT: Sig

Example in file:

18 0 obj
<<
/Type /Annot
/Subtype /Widget
/FT /Sig
/Rect [ 30 30 100 50 ]
/V 17 0 R
/T (Signature1)
/F 4
/P 4 0 R
>>
endobj

Object with signature hash:

17 0 obj
<<
/Type /Sig
/Filter /Adobe.PPKLite
/SubFilter /adbe.pkcs7.detached
/ByteRange [ 0 4045 20431 980 ]
/Contents <{signature}>
/Reason (Sign generated)
/M (D:20210323145244Z)
/ContactInfo (email@emailcom)
/Name (Name from p12)
/Location (Sign with p12)
>>
endobj
btecu commented 3 years ago

You could create a TextField on top of the SignatureField and add the text.

espositovitor commented 3 years ago

Great @btecu you can bring me a example please?

Hopding commented 2 years ago

pdf-lib doesn't support incremental updates right now (it's on the roadmap though: https://github.com/Hopding/pdf-lib/discussions/998), so I don't believe this can be done.