init: 博特维采购订单系统 v1.0 源码
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""把 PDF 指定页渲染成 PNG,用于版式校验。"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pymupdf
|
||||
|
||||
OUT = r"D:\2026-09-09-task-18\tools\out"
|
||||
|
||||
|
||||
def render(pdf, pages=(0,), dpi=110, prefix=None):
|
||||
doc = pymupdf.open(pdf)
|
||||
prefix = prefix or os.path.splitext(os.path.basename(pdf))[0]
|
||||
for p in pages:
|
||||
if p >= len(doc):
|
||||
continue
|
||||
page = doc[p]
|
||||
pix = page.get_pixmap(dpi=dpi)
|
||||
path = os.path.join(OUT, "%s_p%d.png" % (prefix, p + 1))
|
||||
pix.save(path)
|
||||
print(path)
|
||||
print("pages:", len(doc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
name = sys.argv[1]
|
||||
pages = [int(x) for x in sys.argv[2].split(",")] if len(sys.argv) > 2 else [0]
|
||||
render(os.path.join(OUT, name), pages)
|
||||
Reference in New Issue
Block a user