1
0
Fork 0
forked from josch/plakativ

use new snake_case naming for pymupdf 1.23.0 and later

closes: #6
This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-10-27 11:29:12 +02:00
parent d0e5c1e48d
commit fab6925674
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -712,7 +712,11 @@ class Plakativ:
shape = page.new_shape() shape = page.new_shape()
else: else:
shape = page.newShape() shape = page.newShape()
shape.drawRect( if hasattr(shape, "draw_rect"):
dr = shape.draw_rect
else:
dr = shape.drawRect
dr(
fitz.Rect( fitz.Rect(
x0, x0,
y0, y0,
@ -722,7 +726,7 @@ class Plakativ:
) )
shape.finish(color=(0, 0, 1)) shape.finish(color=(0, 0, 1))
# outer rectangle # outer rectangle
shape.drawRect( dr(
fitz.Rect( fitz.Rect(
x0 - left, x0 - left,
y0 - top, y0 - top,
@ -816,9 +820,13 @@ class Plakativ:
shape = page.new_shape() shape = page.new_shape()
else: else:
shape = page.newShape() shape = page.newShape()
if hasattr(shape, "draw_rect"):
dr = shape.draw_rect
else:
dr = shape.drawRect
if guides: if guides:
if portrait: if portrait:
shape.drawRect( dr(
fitz.Rect( fitz.Rect(
mm_to_pt(self.layout["border_left"]), mm_to_pt(self.layout["border_left"]),
mm_to_pt(self.layout["border_top"]), mm_to_pt(self.layout["border_top"]),
@ -827,7 +835,7 @@ class Plakativ:
) )
) )
else: else:
shape.drawRect( dr(
fitz.Rect( fitz.Rect(
mm_to_pt(self.layout["border_bottom"]), mm_to_pt(self.layout["border_bottom"]),
mm_to_pt(self.layout["border_left"]), mm_to_pt(self.layout["border_left"]),
@ -863,7 +871,7 @@ class Plakativ:
) )
if border: if border:
if portrait: if portrait:
shape.drawRect( dr(
fitz.Rect( fitz.Rect(
mm_to_pt(self.layout["border_left"] - x), mm_to_pt(self.layout["border_left"] - x),
mm_to_pt(self.layout["border_top"] - y), mm_to_pt(self.layout["border_top"] - y),
@ -880,7 +888,7 @@ class Plakativ:
) )
) )
else: else:
shape.drawRect( dr(
fitz.Rect( fitz.Rect(
mm_to_pt(self.layout["border_bottom"] - x), mm_to_pt(self.layout["border_bottom"] - x),
mm_to_pt(self.layout["border_left"] - y), mm_to_pt(self.layout["border_left"] - y),