-
Notifications
You must be signed in to change notification settings - Fork 662
Closed
Labels
Description
with the new version (1.16.10) polyAnnots are placed in strange places!
import fitz
print(fitz.__doc__)
red = (1, 0, 0)
blue = (0, 0, 1)
displ = (0, 50, 0, 50)
r = fitz.Rect(50, 100, 220, 135)
doc = fitz.open()
page = doc.newPage()
for i in range(7):
page.insertText(r.br + (10, 0), "texte_"+ str(i), color=red)
r += displ
words = page.getTextWords()
for (x0,y0,x1,y1,w,blocknum ,line,wordnum) in words:
annot = page.addPolygonAnnot([[x0,y0],[x1,y0],[x1,y1],[x0,y1],[x0,y0]])
annot2=page.addRectAnnot(fitz.Rect(x0,y0,x1,y1))
#annot.setOpacity(0.3)
annot.setBorder(width=1.3)
dgreen=fitz.utils.getColor('DARKGREEN')
annot.setColors(stroke=dgreen, fill=dgreen)
annot.update()
page = doc.reload_page(page) # refresh the page before taking pictures
pix=page.getPixmap(matrix=fitz.Matrix(fitz.Identity).preScale(3,3),alpha=True,colorspace="RGBA")
from PIL import Image, ImageTk
mode = "RGBA"
img = Image.frombytes(mode, [pix.width, pix.height], pix.samples)
from matplotlib import pyplot as plt
import matplotlib as mpl
mpl.rc("savefig", dpi=300)
plt.figure(figsize = (20,20))
fig, ax = plt.subplots(figsize=(18, 20))
ax.imshow(np.asarray(img))p.s setOpacity have a strange behavior also !
