Forum Discussion
Storyline 2 Example - Generating a PDF Certificate for users who successfully complete a quiz
Hi Ryan,
My question to you is: How do you customize the background?
Specifically, can an existing PDF be imported into the background?
I would like to avoid using the online conversion tool, referred to in your previous posting.
This does not seem to work?
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: 'myImageDictionary/image1.jpg'
Ideally with a vector based image would be great!
Thanks,
Kevin
- RyanLowry9 years agoCommunity Member
Hi Kevin,
As I mentioned in my previous post images must be converted to base64 strings and included as data uri's. You don't need to use an online converter, you can do this locally. I'm not going to go into how to do this, a quick google should point you in the right direction.
The following example demonstrates how you can use filenames when using pdfmake with NodeJS locally / on a server.
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: 'myImageDictionary/image1.jpg'There's no way to directly import a PDF, it would need to be converted to an image.
Unfortunately pdfmake doesn't support vector based images.
If you want to do something more advanced I think you'll have to do it server side. We use TCPDF to generate certificate PDF's server side with PHP in our VLE. This PHP class is much more advanced than pdfmake and the other javascript pdf libraries. Another benefit of generating server side is that you can keep a record of all issued certificate pdfs,
Cheers,
Ryan
- KevinBrake19 years agoCommunity Member
Thank you Ryan.
All the best,
Kevin
- LisaSpirko-39767 years agoCommunity Member
Hi Ryan, I need clarification on this comment of yours from over 2 years ago...
As I mentioned in my previous post images must be converted to base64 strings and included as data uri's. You don't need to use an online converter, you can do this locally. I'm not going to go into how to do this, a quick google should point you in the right direction.
The following example demonstrates how you can use filenames when using pdfmake with NodeJS locally / on a server.
// under NodeJS (or in case you use virtual file system provided by pdfmake)
// you can also pass file names here
image: 'myImageDictionary/image1.jpg'Are you saying here that there is no way to point to a jpg or png (pdfmake now supports them) that resides in the certificate folder? I tried just pointing to my image in an image folder like this, but it didn't work:
image: 'image/certificate.png'
I need to be able to easily swap out the background image in the output folder, so base64 and data uri's are not going to work for me (I tested with my image encoded and I still couldn't get it to work). I'm also not sure what NodeJS is.
Thank you in advance for any advice you can give.
Lisa