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

Getting correct widget ref to be removed #1268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kyle-leitham-aix
Copy link

@kyle-leitham-aix kyle-leitham-aix commented Jul 8, 2022

What?

Gets correct widget ref from the document to remove the corresponding annotation ref from the page

Why?

Trying to fix this issue: #1267

How?

Gets the ref using doc.context.getObjectRef instead of findWidgetAppearanceRef (which seems to get the wrong ref?)

Testing?

Ran the unit tests

New Dependencies?

N/A

Screenshots

N/A

Suggested Reading?

No

Anything Else?

I'm new to this repo and PDF specifications, so I'm not sure this is the correct fix. Hoping it is!

Checklist

  • I read CONTRIBUTING.md.
  • I read MAINTAINERSHIP.md#pull-requests.
  • I added/updated unit tests for my changes.
  • I added/updated integration tests for my changes.
  • I ran the integration tests.
  • I tested my changes in Node, Deno, and the browser.
  • I viewed documents produced with my changes in Adobe Acrobat, Foxit Reader, Firefox, and Chrome.
  • I added/updated doc comments for any new/modified public APIs.
  • My changes work for both new and existing PDF files.
  • I ran the linter on my changes.

@mel-habip
Copy link

@kyle-leitham-aix do you know if there is any progress on this? I'm also running into this issue and marking the fields read-only isn't really an option since they're still editable. Any further info?

@kyle-leitham-aix
Copy link
Author

@mel-habip It seems like this repo has been abandoned, unfortunately. As a workaround, I had to programmatically remove all of the page annotations before flattening.

@mpalmahsf
Copy link

@mel-habip It seems like this repo has been abandoned, unfortunately. As a workaround, I had to programmatically remove all of the page annotations before flattening.

Could you provide an example of how to do this? We tried this but didn't quite work out for us.

@kyle-leitham-aix
Copy link
Author

@mpalmahsf So, if you have the pdf document instance, it would be something like:

pdfDocument.getPages().forEach((page) => {
      const annotations = page.node.Annots()
      const size = annotations?.size()
      if (size) {
        for (let i = 0; i < size; i++) {
          annotations.remove(annotations.get(i))
        }
      }
    })

@satyajitnayk
Copy link

There is an issue with this approach.
After this fix adobe no more throw any error but all fields & texts are missing from the pdf(Just an empty PDF page).

@dasaevc
Copy link

dasaevc commented Apr 24, 2024

@mpalmahsf So, if you have the pdf document instance, it would be something like:

pdfDocument.getPages().forEach((page) => {
      const annotations = page.node.Annots()
      const size = annotations?.size()
      if (size) {
        for (let i = 0; i < size; i++) {
          annotations.remove(annotations.get(i))
        }
      }
    })

I tried this approach and worked but I applied that AFTER flattening the form. In that way the fields and texts appear well.

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

Successfully merging this pull request may close these issues.

5 participants