Can't insert image with its binary data
Arsh1a opened this issue · 1 comments
Arsh1a commented
Bug Report
Can't insert image with its binary data or as buffer.
Description of the problem
When I insert a data like this:
doc.image(attachment, docMargins.left + 40, imageY + imageOffsetY, {
fit: [
doc.page.width - (docMargins.left + 40) - docMargins.right,
doc.page.height - imageY - imageOffsetY - 2 * docMargins.bottom
],
align: 'center'
})
I get following error:
The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '�PNG\r\n' +
'\x1A\n' +
'\x00\x00\x00\rIHDR\x00\x00\x00�\x00\x00\x00�\b\x06\x00\x00\x00�\x16�-\x00\x00\x00\x01sRGB\x00��\x1C...
I've tried converting it to Buffer, but got the following error:
Unknown image format
Code sample
doc.image(attachment, docMargins.left + 40, imageY + imageOffsetY, {
fit: [
doc.page.width - (docMargins.left + 40) - docMargins.right,
doc.page.height - imageY - imageOffsetY - 2 * docMargins.bottom
],
align: 'center'
})
Your environment
- pdfkit version:^0.14.0
- Node version:v21.2.0
- Browser version (if applicable):
- Operating System: Windows 11
blikblum commented
Can't reproduce. How are you loading the image data? Please create a working example using https://replit.com/@blikblum/minimal-pdfkit and reopen it