Skip to content

overlaying more than one pixmap breaks embedded pdf #814

@cbm755

Description

@cbm755

This seems to be a regression between 1.18.0 and 1.18.1.

I have an input pdf file which itself contains an embedded pdf "figure".

I overlay 1 pixmap on top. No problem. Overlay two or more and my embedded pdf figure is missing in the output.

Screenshot from 2021-01-08 20-02-14

  • left-most is input.pdf. Note the "ID Box" with student number, name etc: this is the embedded PDF graphic.
  • overlay "9" pixmap (called little.png in my example code):
    little
  • middle screenshot has "9" pixmap overlaid
  • right screenshot has four "9"'s overlaid: note the "ID Box" is missing.

Your configuration (mandatory)

  • Fedora 33
  • Python 3.9
  • PyMuPDF 1.18.1--1.18.6 all show this. 1.18.0 does not. All installed from pip.

Example code

import fitz

# note this input has "idBox2.pdf" embedded inside (generated with pdflatex)
input = fitz.open('input.pdf')

# new doc with first page of input
doc = fitz.open()
doc.insertPDF(input, from_page=0, to_page=0, start_at=-1)

# just boxes for 4 corners, probably not hugely relevant
page_width = doc[0].bound().width
page_height = doc[0].bound().height
rTL = fitz.Rect(15, 20, 85, 90)
rTR = fitz.Rect(page_width - 85, 20, page_width - 15, 90)
rBL = fitz.Rect(15, page_height - 90, 85, page_height - 20)
rBR = fitz.Rect(page_width - 85, page_height - 90, page_width - 15, page_height - 20)

im = fitz.Pixmap('little.png')

# As soon as we overlay 2 or more images, the idBox2.pdf graphic disappears!
doc[0].insertImage(rTL, pixmap=im, overlay=True)
doc[0].insertImage(rTR, pixmap=im, overlay=True)
doc[0].insertImage(rBR, pixmap=im, overlay=True)
doc[0].insertImage(rBL, pixmap=im, overlay=True)

doc.save('output.pdf')


Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions