SOURCE CODE
First of all we need to make an index.html
file and copy paste the following code which is shown below
index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PDFMake</title> </head> <body> </body> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.70/pdfmake.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.70/vfs_fonts.js"></script> <script> // playground requires you to assign document definition to a variable called dd var docDefinition = { content: [ { text: 'google', link: 'http://google.com' }, { text: 'Go to page 2', linkToPage: 2 }, { text: 'Go to Header', linkToDestination: 'header' }, { text: 'Header content', id: 'header' }, ] } pdfMake.createPdf(docDefinition).download(); </script> </html> |
As you can see we are defining the defination
of the pdf document and inside it we are inserting the links
and the text inside the pdf document. And then we are downloading the pdf document using the pdfmake.js
cdn library.