Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.9k stars 657 forks source link

Something Left Behind After Feild Removal #987

Closed Trapfether closed 3 years ago

Trapfether commented 3 years ago

I'm using pdf-lib in the browser. Part of my use case includes adding form fields to the document; as well as, removing fields from the document.

I am using pdf.js https://mozilla.github.io/pdf.js/ to display a single page of the document at a time in the browser

If you add a TextField to the PDF with any background color besides transparent, then remove that field using PDFForm.removeForm(fieldReference), the background box is still displayed by pdf.js after reloading the pdf. I have verified that this background is not visible in adobe acrobat or the Chrome pdf viewer.

It appears that something is not being fully removed from the document.

I have also submitted an Issue on pdf.js as other pdf viewers do apparently handle the deleted fields appropriately.

I currently simply set the field backgroundColor and borderColor to undefined during creation to avoid this issue, so it isn't a pressing concern for me.

If I can provide any additional clarity, please let me know.

ShaheedHaque commented 3 years ago

Are you seeing any errors like the one in #789?

Trapfether commented 3 years ago

I'm not receiving any error when I remove the field, and all of the interactive portions are removed in all contexts.

Only the background and Border are left behind.

I have also discovered that setting the backgroundColor and borderColor on PDFCheckBoxes to undefined does not leave them off, and so the checkbox border & background will appear when the saved pdf (after removing the checkbox with the form.removeField function) is loaded in pdf.js.

Hopding commented 3 years ago

Hello @Trapfether! Thanks for reporting this. Based off your description it does sound like pdf-lib might be leaving something behind. If you wouldn't mind, please fill out the new bug report form in a new issue so we have all the details to investigate this 👍