diff --git a/plakativ.py b/plakativ.py index b63568f..67332c4 100755 --- a/plakativ.py +++ b/plakativ.py @@ -338,12 +338,18 @@ class Plakativ: mat_0 = fitz.Matrix(zoom, zoom) # since pymupdf 1.19.0 a warning will be issued if the deprecated names are used if hasattr(self.doc[self.pagenr], "get_displaylist"): - gdl = self.doc[self.pagenr].get_displaylist + gdl = self.doc[self.pagenr].get_displaylist() else: - gdl = self.doc[self.pagenr].getDisplayList - pix = gdl().getPixmap(matrix=mat_0, alpha=False) - # the getImageData() function was only introduced in pymupdf 1.14.5 + gdl = self.doc[self.pagenr].getDisplayList() + if hasattr(gdl, "get_pixmap"): + pix = gdl.get_pixmap(matrix=mat_0, alpha=False) + else: + pix = gdl.getPixmap(matrix=mat_0, alpha=False) + if hasattr(pix, "tobytes"): + # getImageData was deprecated in pymupdf 1.19.0 + return pix.tobytes("ppm") if hasattr(pix, "getImageData"): + # the getImageData() function was only introduced in pymupdf 1.14.5 return pix.getImageData("ppm") else: # this is essentially the same thing that the getImageData()