Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aureliee123's avatar

print invoice to pdf

Hello i have an invoice made with html5 template is there a way to download it as pdf

i used mpdf dompdf nothing worked

now i'm using window.print()

but i want it as pdf

thank you

0 likes
2 replies
vandan's avatar

@ikram_aurelie

try this using js

<script>
        function Export() {
            html2canvas(document.getElementById('kt_table_1'), {
            onrendered: function (canvas) {
                    var data = canvas.toDataURL();
                    var docDefinition = {
                        content: [{
                            image: data,
                            width: 500
                            }]
                    };
                    pdfMake.createPdf(docDefinition).download("pg.pdf");
                    }
            });
        }
</script>

<a href="#" class="kt-nav__link" id="btnExport" onclick="Export()"></a>

Please or to participate in this conversation.