SOURCE CODE
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
<!doctype html> <html lang='en'> <head> <meta charset='utf-8'> <title>my example</title> <!-- pdfmake files: --> <script src='https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js'></script> <script src='https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.min.js'></script> <!-- html-to-pdfmake file: --> <script src="https://cdn.jsdelivr.net/npm/html-to-pdfmake/browser.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> </head> <body> </body> <script> var dd = { pageMargins: [40, 40, 40, 100], footer: function (currentPage, pageCount) { return { table: { body: [ [ { text: "Page " + currentPage.toString() + ' of ' + pageCount, alignment: 'right', style: 'normalText', margin: [0, 20, 50, 0] } ], ] }, layout: 'Borders' }; }, content: [ { text: 'Text bcbcvb', pageBreak: 'after' }, { text: 'Text fgdfg', pageBreak: 'after' }, { text: 'Text fgdfgdfg', pageBreak: 'after' }, ] } pdfMake.createPdf(dd).download(); // playground requires you to assign document definition to a variable called dd </script> </body> </html> |
As you can see we have included the cdn of the pdfmake.js
and then inside the javascript we are adding the page
numbers inside the pdf document at the bottom of the pdf document. We have also added the border
to the page numbers as shown below