Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
hellofinch committed Jan 8, 2025
1 parent b26117b commit 4b5b492
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pdf2zh/pdfinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ def do_Do(self, xobjid_arg: PDFStackT) -> None:
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
] = f"q {ops_base}Q {a} {b} {c} {d} {e} {f} cm {ops_new}"
self.obj_patch[self.xobjmap[xobjid].objid] = (
f"q {ops_base}Q {a} {b} {c} {d} {e} {f} cm {ops_new}"
)
except Exception:
pass
elif subtype is LITERAL_IMAGE and "Width" in xobj and "Height" in xobj:
Expand Down Expand Up @@ -269,9 +269,9 @@ def process_page(self, page: PDFPage) -> None:
self.device.fontmap = self.fontmap
ops_new = self.device.end_page(page)
# 上面渲染的时候会根据 cropbox 减掉页面偏移得到真实坐标,这里输出的时候需要用 cm 把页面偏移加回来
self.obj_patch[
page.page_xref
] = f"q {ops_base}Q 1 0 0 1 {x0} {y0} cm {ops_new}" # ops_base 里可能有图,需要让 ops_new 里的文字覆盖在上面,使用 q/Q 重置位置矩阵
self.obj_patch[page.page_xref] = (
f"q {ops_base}Q 1 0 0 1 {x0} {y0} cm {ops_new}" # ops_base 里可能有图,需要让 ops_new 里的文字覆盖在上面,使用 q/Q 重置位置矩阵
)
for obj in page.contents:
self.obj_patch[obj.objid] = ""

Expand Down Expand Up @@ -361,4 +361,4 @@ def execute(self, streams: Sequence[object]) -> None:
else:
self.push(obj)
# print('REV DATA',ops)
return ops
return ops

0 comments on commit 4b5b492

Please sign in to comment.