PDF file generation using pdfmake

I have installed ‘pdfmake’ in the npm package installer and tried to generate a sample pdf file (Code snipped is given below). The code gets executed without any error but the pdf does not get generated. Could you please assist on what is that I am missing.

npm - package installation

Sample web page to generate pdf file

Javascript Code

Site log files

I do not know pdfMake, but there are surely also alternatives for that and a lot of content/posts where you can find informations…

And you will surely find much more stuff about this topic, when you use the search-function of the VELO-FORUM! :wink:

@russian-dima thanks for the suggestions, I indeed have gone through the other posts as well; the only difference is that ‘pdfmake’ is fully open source where as others have a premium price for the usage.

If i will find enough of freetime, i will take a closer look onto your problem.

@russian-dima Thank you! Any help into the request is much appreciated.

@vmsivaraj
I will try to reconstruct this on weekend.

@russian-dima Thanks a lot! for your efforts

Hello again, i still didn’t have the time to investigate the “pdfmake”-NPM, but i could find an ALTERNATIVE way for you.

Take alook onto this post here…

There is a way to use the PDF-Generator for your purposes.
PDF-Generator also offers a limited FREE-Account to generate PDFs.

You can do a lot with it! You can generate PDF-Templates and feed them automatical with your own data, directly out of your Wix-Site.
You perhaps should also take a closer look onto that alternative way.

@russian-dima Yup, i implemented the functionality using ‘pdf-generator-api-client’.

‘pdf-generator-api-client’ has as 3 month free trial period, just in-case you happen to find time please explore ‘pdfmake’ ; investing time on the ‘pdfmake’ which is completely open source and free will benefit the community

1 Like

Hi Sivaraj,

Can you send all the code that u used in a code snippit?
Its hard to copy from an image :wink:

Kind regards,
Kristof.

@volkaertskristof
Hi Kristof, requested JS code is below

$w.OnReady(function)({
	$w('#printBn').onclick((events) => {
		console.log ("Clicked...")
		
		var fonts = {
			Roboto: {
				 normal: '/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Regular.ttf',
				 bold: '/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Medium.ttf',
				 italics: '/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Italic.ttf',
				 bolditalics: '/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-MediumItalic. ttf'
			}
		}
		
		var docDefinition = {
			  content: [
				{ text: 'This is a header', style: 'header' },
				'No styling here, this is a standard paragraph',
				{ text: 'Another text', style: 'anotherStyle' },
				{ text: 'Multiple styles applied', style: [ 'header', 'anotherStyle' ] }
			  ],

			  styles: {
				header: {
				  fontSize: 22,
				  bold: true
				},
				anotherStyle: {
				  italics: true,
				  alignment: 'right'
				}
			  }
			};
		
		console.log("==")
		pdfMake.createPdf(docDefinition, fonts).open({}, WindowClient)

	});
});

Note: In ‘var fonts’ please include ‘https //cdnjs.cloudflare com/’ before each line for normal, bold, italics, bolditalics (editor is not allowing me to publish with the full links on

I will keep an eye on progress here :wink:

@vmsivaraj @russian-dima
The pdfmake keeps giving me an error for the fonts.
I do have another option to create PDF’s.
But this only works with a premium website,
Do you have 1?

Kind regards,
kristof

Here is the link to my example that i just posted.

https://www.wix.com/velo/forum/tips-tutorials-examples/example-pdf-generator-premium-only

Kind regards,
Kristof.