新版本的PyMuPdf(1.16.1)似乎有问题 下面的代码(灵感来自pymupdf文档,用于收集配方零件注释)生成的pdf是正确的,生成的图像是错误的:不透明度的注释!= 1. 图像中缺少
from __future__ import print_function
import sys
print("Python", sys.version, "on", sys.platform, "\n")
import fitz
print(fitz.__doc__, "\n")
import os
print (os.getcwd())
def print_descr(rect, annot):
"""Print a short description to the right of an annot rect."""
annot.parent.insertText(rect.br + (10, 0),
"'%s' annotation" % annot.type[1], color = red)
red = (1, 0, 0)
blue = (0, 0, 1)
gold = (1, 1, 0)
colors = {"stroke": blue, "fill": gold}
colors2 = {"fill": blue, "stroke": gold}
border = {"width": 0.3, "dashes": [2]}
displ = fitz.Rect(0, 50, 0, 50)
r = fitz.Rect(50, 100, 220, 135)
doc = fitz.open()
page1 = doc.newPage()
annot = page1.addPolygonAnnot([r.bl, r.tr, r.br, r.tl])
annot.setOpacity(0.5)
annot.setBorder(border)
annot.setColors(colors2)
annot.update()
print_descr(annot.rect, annot)
print("added 'Polygon'")
pix=page1.getPixmap(alpha=True,annots=True)
doc.save("test-annots.pdf")
pix.writePNG("test-annots.png")
pix.writeImage("test-annots.psd","psd")
doc.close()
预期结果是1.13.20 pymupdf版本的图像
目前没有回答
相关问题 更多 >
编程相关推荐