📜  vue 将页面元素保存为 pdf - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:11.445000             🧑  作者: Mango

代码示例1
printFacture() {
    var pdf = new jsPDF();
    var element = document.getElementById('facture');
    var width= element.style.width;
    var height = element.style.height;
    html2canvas(element).then(canvas => {
        var image = canvas.toDataURL('image/png');
        pdf.addImage(image, 'JPEG', 15, 40, width, height);
        pdf.save('facture' + moment(this.facture.date_debut).format('LL') + '_' + moment(this.facture.date_fin).format('LL') + '.pdf';
    });
}