Skip to content

pymupdf integration is broken #949

Description

@planted-sam

Describe the bug
When following the example for PDF generation with the drawing addon (specifically the example for PDF creation), I keep running into an error where PDF generation fails.

Specifically, the get_pdf_bytes method call is where the function breaks down, with the trace going back to PyMuPdfRenderBackend.set_background in ezdxf/addons/drawing/pymupdf.py. That method fails because when it tries to run shape.drawRect it throws AttributeError: 'Shape' object has no attribute 'drawRect'.

Tracing where the shape object comes from, it looks like it uses the fitz module from pymupdf, and looking at the most recent pymupdf docs, it seems like the Shape class doesn't have a drawRect method, but rather a draw_rect method. It makes me think that maybe that function name changed in pymupdf and the change hasn't been reflected in this codebase.

Could this code be updated to match the new class definition in pymupdf? Or is there a old version of pymupdf that I should install specifically instead of the latest one to get this to work?

To Reproduce
Run the example at https://github.com/mozman/ezdxf/blob/stable/examples/addons/drawing/pdf_export.py with the latest version of pymupdf installed (1.23.5), and see the error that pops up when get_pdf_bytes is called.

Expected behavior
The set_background method of the PyMuPDFRenderBackend should complete without error.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions