简体   繁体   中英

Export html into pdf landscape mode

Here is my javascript code for export to pdf.How can i make it in landscape mode.How to change the paper format into A3

function Export() {
            html2canvas(document.getElementById('order-listing'), {
                onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 1000
                        }]
                    };
                    pdfMake.createPdf(docDefinition).download("detailedattendance.pdf");
                }
            });
        }

Add pageOrientation to the docDefinition array. Found in documentation here .

function Export() {
    html2canvas(document.getElementById('order-listing'), {
        onrendered: function (canvas) {
            var data = canvas.toDataURL();
            var docDefinition = {
                content: [{
                    image: data,
                    width: 1000
                }],
                pageSize: 'A3',
                pageOrientation: 'landscape'
            };
            pdfMake.createPdf(docDefinition).download("detailedattendance.pdf");
        }
    });
}

您可以使用dompdf尝试相同的操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM