Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: deleteAnnotations will not return if passing object_id as parameter and either the obj or generation is zero. #86

Open
programus opened this issue Jun 12, 2024 · 1 comment

Comments

@programus
Copy link

} else if (id.obj && annot.object_id && id.obj === annot.object_id.obj && id.generation && id.generation === annot.object_id.generation) {

In this line, there is a id.generation, which I guess to check whether there is a property called generation in id, but there is a case that generation == 0, and in this case the promise will never finish since the resolve() is not invoked.

The details of my case is:
I have a PDF with 4 annotations, and I confirmed the annotations by getAnnotations() and the identities of the 4 annotations are:

[
  {
    "id": "fitz-A0",
    "object_id": {
      "obj": 191,
      "generation": 0
    }
  },
  {
    "id": "fitz-A1",
    "object_id": {
      "obj": 193,
      "generation": 0
    }
  },
  {
    "id": "fitz-A0",
    "object_id": {
      "obj": 195,
      "generation": 0
    }
  },
  {
    "id": "fitz-A1",
    "object_id": {
      "obj": 197,
      "generation": 0
    }
  }
]

The string type ids are shared by multiple annotations and there would be an error while AnnotationFactory.write() is called. So I tried the object_id and the promise does not return. I did some investigation and found the reason is the id.generation.

I don't want to fork my own version of this lib, is there any other ways to delete the annotations in my PDF before the new release with the fix?

@programus
Copy link
Author

Found this fork has fixed this problem: https://github.com/iwater/pdfAnnotate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant