Question / Comment: Intended behavior? Annotation.getPixmap with alpha=True returns with background from the page (original) (raw)

Annotation.getPixmap with alpha=True still returns the background from page (and other annotations if its in the area).

I'm not sure whether this is a bug, or have I misunderstood the purpose of alpha=True. I would have thought that it returns the annotation rendered in isolation with a transparent background.

Furthermore, if this is intended, is there a way to render the annotation by itself?

PS: Thanks for the work on pymupdf. It's quite pleasant to work with.

A script to reproduce:

import fitz import sys

doc = fitz.Document(sys.argv[1]) page = doc.loadPage(0) page.addInkAnnot([[ (200, 200), (300, 300), (250, 400) ]]) pixmap_page = page.getPixmap(annots=True) pixmap_page.writeImage("page.png")

annot = next(page.annots()) pixmap_annot = annot.getPixmap(alpha=False) pixmap_annot.writeImage("annot.png")

page.png

page

annot.png

photo_2020-07-20_12-47-37