pdfmake


pdfmake - can make export on client and server side. For sever side needs node.js


Need to copy pdfmake.min.js (or pdfmake.js), vfs_fonts.js


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<html>
<head>
	<title>Test</title>
	<meta charset="UTF-8">

    <script src="pdfmake.js"></script>
    <script src="vfs_fonts.js"></script>
    <script src="script.js"></script>

</head>
<body>
	<h1>Hello!</h1>

    <input id="clickMe" type="button" value="Download PDF" onclick="myFunc();" />

</body>
</html>


script.js


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
var docInfo = {

    info: {
        title: 'PDF Doc',
        author: 'Marley',
        subject: 'Theme',
        keywords: 'My keywords'
    },

    pageSize: 'A4',
    pageOrientation: 'landscape',
    pageMargins: [50,50,30,60],

    header: function(currentPage, pageCount){
        return {
            text: currentPage.toString() + ' of ' + pageCount,
            alignment: 'right',
            margin: [0, 30, 10, 50]
        }
    },


    footer: [
        {
            text:'Some Footer',
            alignment: 'center'
        }
    ],

    content: [
        {
            text: 'Paragraph Text',
            fontSize: 20
        }
    ]

}

var myFunc = function(){
pdfMake.createPdf(docInfo).download('PdfFileName.pdf');
}