highkite / pdfAnnotate

Javascript library for creating annotations in PDF documents
MIT License
556 stars 90 forks source link

deleteAnnotation(...) not removing existing annotations in PDF #67

Open melnikovic opened 2 years ago

melnikovic commented 2 years ago

Hi everyone,

I'm trying to delete the existing annotation from the PDF file. I simply call this:

this.pdfFactory.deleteAnnotation(selectedAnnotation.id).then((x) => {
    this.pdfSrc = { data: this.pdfFactory.write() };
 });

If I call this method on annotation, which is not saved in PDF, everything works fine. However, if I call it on annotation which is in PDF it removes annotation from UI but when I call this.pdfFactory.getAnnotations() I can still see annotation in list (is_deleted property is false) and when I save / download PDF I see annotation wasn't deleted from PDF file.

Am I doing something wrong or is this a bug?

pacoMaldonado commented 1 year ago

hi @melnikovic I don't know if it still works for you, but when using the "deleteAnnotation" function, this returns an array with the "TextAnnotationObj" that we are going to delete. If you review the "TextAnnotationObj" object, you can see that there is an "AnnotationFactory" factory value in which there is a "data" attribute which is the pdf document in a format Uint8Array which you load in your pdf viewer and you will notice that it no longer has the delete annotation.

P.D. sorry my bad english