Skip to content

Commit

Permalink
Fix error when using the mat method with NumPy version >= 2.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Dec 17, 2024
1 parent d2d36bd commit 872e2da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pdf2zh/pdfinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ def do_Do(self, xobjid_arg: PDFStackT) -> None:
self.device.fontmap = interpreter.fontmap
ops_new = self.device.end_figure(xobjid)
ctm_inv = np.linalg.inv(np.array(ctm[:4]).reshape(2, 2))
pos_inv = -np.mat(ctm[4:]) * ctm_inv
np_version = np.__version__
if np_version.split(".")[0] >= "2":
pos_inv = -np.asmatrix(ctm[4:]) * ctm_inv
else:
pos_inv = -np.mat(ctm[4:]) * ctm_inv
a, b, c, d = ctm_inv.reshape(4).tolist()
e, f = pos_inv.tolist()[0]
self.obj_patch[self.xobjmap[xobjid].objid] = (
Expand Down

0 comments on commit 872e2da

Please sign in to comment.