24eme / signaturepdf

Free open-source web software for signing PDFs (alone or with others) and also organize pages, edit medata and compress pdf
https://pdf.24eme.fr
GNU Affero General Public License v3.0
399 stars 52 forks source link

Acroform and/or Signature Object #28

Open Kyoku57 opened 2 years ago

Kyoku57 commented 2 years ago

Hi, the result PDF doesn't seem to include a Signature Field / Acroform associated to the rendered signature.

Do you plan to implement this kind of functionality ? Perhaps with the inclusion of calls to a backend based on https://pyhanko.readthedocs.io/en/latest/lib-guide/sig-fields.html

In any case, good job ;-)

teymour commented 2 years ago

Good idea ! If you can share a PDF with this kind of feature, it whould help :)

Kyoku57 commented 2 years ago

Hi,

You'll find 3 versions of the PDF.

The script in Quick'n'Dirty mode :

from pyhanko.sign.fields import SigFieldSpec, append_signature_field
from pyhanko.pdf_utils.incremental_writer import IncrementalPdfFileWriter

with open('document_prepared_with_signatureField.pdf', 'rb+') as doc:
    w = IncrementalPdfFileWriter(doc)
    signature_field = SigFieldSpec(sig_field_name="Sig1", on_page=0, box=(50,50,300,80))
    append_signature_field(w, signature_field)
    w.write_in_place()

Your file is updated with a empty Signature Field named Sig1 image

In Acrobat, if you click on it, you can sign with a qualified device, or with a "Visual Signature" qualified by Adobe (no legal value but it's works here). With an API, you can sign the signature field (with a linked device, or a keystore .. that contains the private key and certificate needed to sign ;-))

For this kind of stuff, you need to use a private key somewhere to "sign" you signature Field, so ... you need to realize this signature with a backend service or a YubiKey/Browser capability.

I'm not sure is the principale aim of your cool tool, but if you are interesting in go deeper with electronic signature ....

image

:D

teymour commented 2 years ago

Thanks you !

The signature field is detected as a data fields by pdftk :

$ pdftk document_prepared_with_signatureField.pdf dump_data_fields output /dev/stdout 
---
FieldType: Signature
FieldName: Sig1
FieldFlags: 0
FieldJustification: Left

With data fields pdf, the action menu could be transform in field menu : the user could enter the different fields of the pdf.