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

AttributeError: 'Annot' object has no attribute '__del__' #3216

Closed
karenli6 opened this issue Feb 29, 2024 · 1 comment
Closed

AttributeError: 'Annot' object has no attribute '__del__' #3216

karenli6 opened this issue Feb 29, 2024 · 1 comment
Labels
bug fix developed release schedule to be determined Fixed in next release

Comments

@karenli6
Copy link

Description of the bug

We are trying to detect any type of widget and delete it. When we perform the operation page.delete_widget(w) it throws AttributeError: 'Annot' object has no attribute '__del__'

Sample Pdf:

How to reproduce the bug

To Reproduce

PyMuPDF 1.23.25: Python bindings for the MuPDF 1.23.10 library (rebased implementation).
Python 3.11 running on darwin (64-bit).

import fitz
class ModifyPDF:
    def __init__(self, input_path, outputFilePath):
        self.pdfFilePath = input_path
        self.outputFilePath = outputFilePath

    def remove_input_fields(self):
        docs = fitz.open(self.pdfFilePath)
        for page in docs:
            w = page.first_widget
            while w:
                w = page.delete_widget(w)

        docs.save(self.outputFilePath, garbage=3, deflate=True, pretty=True)
        docs.close()


if __name__ == "__main__":
    filePath = "example_form.pdf"
    outputPath = "output.pdf"
    PdfFunction = ModifyPDF(filePath, outputPath)
    PdfFunction.remove_input_fields()

Expected behavior

Widgets should be deleted.

Error output trace:

Screenshot 2024-02-29 at 3 56 54 PM

PyMuPDF version

1.23.25

Operating system

MacOS

Python version

3.11

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix developed release schedule to be determined Fixed in next release
Projects
None yet
Development

No branches or pull requests

2 participants