Closed furstenheim-goodnotes closed 9 months ago
Hi, I have a pdf that contains a shape and some text. I'm trying to render a png on top of the content.
const {PDFDocument, BlendMode} = require('pdf-lib') const fs = require('fs/promises') main() .then(function () { console.log('finished') }, function (err) { console.error('error', err) }) async function main () { const pdfB = await fs.readFile('./input-pdf-with-blank-overlay-2.pdf') const doc = await PDFDocument.load(pdfB) const buffer = await fs.readFile('./merge.png') const pdfImage = await doc.embedPng(buffer) const page = doc.getPage(0) page.drawImage(pdfImage, { x: 0, y: 100, width: page.getWidth(), height: page.getHeight(), }) const exportedPage = await doc.save() await fs.writeFile('example-with-overlay.pdf', exportedPage) }
I've tried with different blend modes
input-pdf-with-blank-overlay-2.pdf
The image was over the text but below the rectangle.
I would expect to have the image over the rectangle, or to have some way of controlling the order
1.17.1
Node
Thanks so much for the project
Example output
example-with-overlay.pdf
By the spec, annotations are rendered on top of images
What were you trying to do?
Hi, I have a pdf that contains a shape and some text. I'm trying to render a png on top of the content.
How did you attempt to do it?
I've tried with different blend modes
input-pdf-with-blank-overlay-2.pdf
What actually happened?
The image was over the text but below the rectangle.
What did you expect to happen?
I would expect to have the image over the rectangle, or to have some way of controlling the order
How can we reproduce the issue?
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
Thanks so much for the project