Skip to content

page.draw_rect method of Pymupdf is not working on certain pages of pdf #1331

@NayanaMadhu

Description

@NayanaMadhu

I'm using draw_rect method of Pymupdf to draw a rectangle box on the pdf. It's not working on certain pages of the pdf. Following is the code for drawing rectangles. I tried the same rect values to plot on other pages and it plotted correctly.

[doc = fitz.open(filepath )
x0,y0,x2,y2 = 39.13108444213867, 125.68994140625,  259.4792175292969, 149.265869140625
rect = fitz.Rect(x0-5,y0-5,x2+5,y2+5)
page = doc[9]
page.draw_rect(rect, color=[0,1,1,0], overlay=False,width=0.5,fill_opacity=1,fill=fill_color)]

I also tried the below code before drawing. page._isWrapped gave False and after page.wrap_contets it became True. But still, I'm not able to plot the rectangle.

if not(page._isWrapped):
    page.wrap_contents()

Please find the following configuration:

  • Operating system - Linux,
  • Python version - 3.8
  • PyMuPDF version: 1.18.15, fitz version : 0.0.1.dev2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions