ralpha / pdf_signing

Rust library for adding signatures and digitally sign PDF documents.
Apache License 2.0
20 stars 8 forks source link

add_image_to_form #1

Open 0xfourzerofour opened 2 years ago

0xfourzerofour commented 2 years ago

Hi @ralpha

Thanks for this project its great. I am just trying it out now but not sure what data I am meant to be referencing with the form_id field.

 doc_new
      .add_signature_to_form(img.as_bytes(), "image", page_id, form_id)
      .unwrap();

I assume its a reference to a dictionary with the width, height etc values but not too sure.

Cheers, Josh

ralpha commented 2 years ago

Hey, the form_id is an ObjectID to the signature form object. Signatures are form objects in pdf. It uses the shape of the field to find out where to place the signature image.

I also saw your message on https://github.com/J-F-Liu/lopdf/issues/166 The current version of this project just adds the signature image. But I have a working prototype for digitally signing the pdf (using a cert). (Not yet committed because it still needs some cleanup). But it only works for 1 signature in a pdf because lopdf does not currently support incremental pdfs.

I would have to add this support in order to add multiple signings. I currently do not have the time to make the current lopdf compatible with incremental pdfs (with all its current features). So I was thinking of just creating a fork to get it working in there (not with the intention to be able to merge it upstream). But if you are willing to help we can add this support to lopdf (in main repo)?

If you want to help further develop it with me, let me know :)

0xfourzerofour commented 2 years ago

Yeh that would be awesome. I am still pretty new to rust and work mainly in go but its something that I really want to get more accustomed to.

let me know when you make a fork and id be happy to help.

ralpha commented 2 years ago

Quick response to let you know there is a significant update to the signing of PDFs in the last commit. It is not perfect yet, but quite a lot is there already. (including an example)

0xfourzerofour commented 2 years ago

@ralpha this is great stuff, just had a look at some of the changes. Good job!