PdfMake in JavaScript

How to put the content in center of the page when exporting div content in pdf file (PdfMake)? Vertical align:center and horizontal align:center?

My code is below:

<script type="text/javascript">
	var name="FIRST TERM RANKS.pdf"; 
        $("body").on("click", "#btnExport", function () {
            html2canvas($( #tblCustomers )[0], {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
             pdfMake.createPdf(docDefinition).download(name);
                }
            });
        });
    </script>

This code is running well but the content is not in the center of the page. How to do it? Again how to add page number in the page footer? Help!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.

markdown_Forums

I am able to export div content to pdf file but this is done when the content fit on one page. When there are more than one pages in the exported pdf file, all pages are empty. I am wondering how to export div content when pages many. My code is below:

<script type="text/javascript">
	var name="END OF YEAR RANKS.pdf"; 
        $("body").on("click", "#btnExport", function () {
            html2canvas($('#tblCustomers')[0], {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download(name);
                }
            });
        });
    </script>

This code is working for a div content that will be exported to only one page. When div content will be exported to many pages, how to do it? Help!

Please do not create duplicate topics for the same challenge/project question(s). This duplicate topic has been merged with this topic.

Thank you.