[Vuejs]-How to apply styles and css and bootstrap cdn in window.print() when using vuejs?

0👍

Hi you can have two ways to achieve this

PrintScreen(el)
{
    let printWindow = window.open('', 'PRINT', 'height=600,width=800');

    printWindow.document.write('<html><head><title>' + document.title  + '</title>');
    printWindow.document.write('</head><body >');
    printWindow.document.write('<h1>' + document.title  + '</h1>');
    printWindow.document.write(document.getElementById(el).innerHTML);
    printWindow.document.write('</body></html>');

    printWindow.document.close(); // IE >= 10
    printWindow.focus(); //  IE >= 10*/

    printWindow.print();
    printWindow.close();

    return true;
}

Or

You can use a wrapper to do this stuff
Npm Link

npm install vue-html-to-paper

Leave a comment