Pdfmake: Can't use image other than sampleImage.jpg

Created on 15 Sep 2014  Â·  10Comments  Â·  Source: bpampuch/pdfmake

Hello. Whenever I try to add image to my pdf, the scripts generate the following error:

Uncaught TypeError: Cannot read property 'embed' of undefined

However when I add sampleImage.img as a source everything seems to be working fine.

{ image: 'sampleImage.jpg', width: 100, height: 100, }

Is there some special requirements which need to be met?
Thanks

Most helpful comment

Look at this pdfmake documentation snippet:

{
  // under NodeJS (or in case you use virtual file system provided by pdfmake)
  // you can also pass file names here
  image: 'myImageDictionary/image1.jpg'
}

What do they mean by "virtual file system provided by pdfmake" ? How do I use it?

All 10 comments

Image needs to be in base64

https://github.com/bpampuch/pdfmake#images

Well... thank you. It solved my problem.
I should have read it more carefully.

Does it mean, images need to be converted into base 64 before passing?

yup!

On 11 August 2015 at 13:21, arunsahni [email protected] wrote:

Does it mean, images need to be converted into base 64 before passing?

—
Reply to this email directly or view it on GitHub
https://github.com/bpampuch/pdfmake/issues/90#issuecomment-129843419.

@Wabbala im trying to convert into base64, but doesnt works.
is possible get the image without convert?

Look at this pdfmake documentation snippet:

{
  // under NodeJS (or in case you use virtual file system provided by pdfmake)
  // you can also pass file names here
  image: 'myImageDictionary/image1.jpg'
}

What do they mean by "virtual file system provided by pdfmake" ? How do I use it?

@SergioMacGyver That would be data-uri-encoding images with gulp into the vfs_fonts.js file, as specified in step 1 of https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side.

https://github.com/bpampuch/pdfmake#images
What do they mean by myImageDictionary ?
help plz !
Thanks !

hi @atefBB it means when client side you will load your website then it can be something like 'content/img/image1.jpg'

@sorb999 Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Masber picture Masber  Â·  3Comments

einfallstoll picture einfallstoll  Â·  3Comments

CharlyPoppins picture CharlyPoppins  Â·  3Comments

Christian24 picture Christian24  Â·  3Comments

davidyeiser picture davidyeiser  Â·  3Comments