Embed a Image in a PDF
Embed a Image in a PDF
Hi,
I'm using the pdfHtml buttons, and trying to embed an image into the output, using the following:
customize: function (doc)
{
doc.content.splice( 1, 0,
{
margin: [ 0, 0, 0, 12],
alignment: 'center',
image: '../Content/img/home_logo.jpg'
});
}
this is throwing up a Cannot read property 'embed' of undefined, meaning it cant find the image. this image is there, and the path is correct.
Replies
You'd need to check the PDFMake documentation, but you might need to convert the image to be a base 64 string for it to work.
Allan
hi Allan,
all looks good from there:
Are you using NodeJS or the virtual file system provided by pdfmake as the comment about using file names directly states?
Allan
Converted the image to Base64 and it worked a treat. Thanks.