Uncaught TypeError: невозможно получить доступ к свойству "длина", e не определено - PullRequest
0 голосов
/ 06 августа 2020
• 1000 1005 * Скачать PDF

Вот мой javascript код со всеми ссылками

<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="DataTables/datatables.min.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/pdfmake.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="js/pdfmake/js/html2canvas.min.js"></script>


<script type="text/javascript" src="js/theme.js"></script>
<script type="text/javascript" src="js/withdraws_report.js"></script>
<script type="text/javascript" src="js/notifications.js"></script>

<!-- code for js pdf libray -->

<script type="text/javascript">
function downloadDoc() {

    html2canvas($("#le_table")[0], {
        onrendered: function(canvas) {
            var data = canvas.toDataURL();
            var docDefinition = {
                content: [{
                    image: data,
                    width: 500
                }]
            };
            pdfMake.createPdf(docDefinition).download("Table.pdf");
        }
    })
}
</script>


1 Ответ

0 голосов
/ 06 августа 2020

В вашем изображении ошибки говорится: «htmltocanvas не определен». просто установите его, используя npm install html2canvas

function downloadDoc() {
html2canvas(document.querySelector("#capture")).then(canvas => {
    document.body.appendChild(canvas)
});
}
<script src="https://github.com/niklasvh/html2canvas/releases/download/vtest2/html2canvas.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="DataTables/datatables.min.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/pdfmake.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/pdfmake.min.js"></script>
<script type="text/javascript" src="DataTables/pdfmake-0.1.36/vfs_fonts.js"></script>
<script type="text/javascript" src="js/pdfmake/js/html2canvas.min.js"></script>
<script type="text/javascript" src="js/theme.js"></script>
<script type="text/javascript" src="js/withdraws_report.js"></script>
<script type="text/javascript" src="js/notifications.js"></script>

<button id="capture" class="btn btn-success" onclick="downloadDoc()">Download PDF</button>
...