vuejs generate pdf code example

Example 1: vue save page elements to pdf

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';
    });
}

Example 2: vue-pdf example

// Look at this maybe that can help
https://www.youtube.com/watch?v=u1Q1glqVEkc&ab_channel=CodingShiksha

//look at the git repository :
https://github.com/FranckFreiburger/vue-pdf

Tags:

Misc Example