plangrid / pdf-annotate

Pure-python library for adding annotations to PDFs
MIT License
195 stars 45 forks source link

All Digital Signature info goes missing after adding annotations #76

Open aashishvanand opened 3 years ago

aashishvanand commented 3 years ago

Hi, I have an existing PDF that is digitally signed. I wanted to add some basic annotations. Let's say I have added a simple square as per the code below and then I save the PDF all the signature info is lost. Probably the best way to do it by supporting incremental updates to the pdf. I am not sure if pdf-annotate supports that

from pdf_annotate import PdfAnnotator, Location, Appearance a = PdfAnnotator('input_signed.pdf') a.add_annotation( 'square', Location(x1=50, y1=50, x2=100, y2=100, page=0), Appearance(stroke_color=(1, 0, 0), stroke_width=5), ) a.write('output.pdf')

pulse-mind commented 1 year ago

Hi, it is because you modify the file and the part of the file that contains the signature when you are doing the write(...). You need to do an "incremental save" but I'm not sure "pdf-annotate" has this feature. @aashishvanand did you find another solution ?

santi2491 commented 1 year ago

Does anyone have a solution to this problem?