D
D
Dmitry Avramenko2016-09-14 10:17:07
css
Dmitry Avramenko, 2016-09-14 10:17:07

How to print html page?

Is it possible to somehow print the page as it is displayed from the monitor? Those. without losing the background, fonts. Or print it as a picture?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yakov Vylegzhanin, 2016-09-14
@vylegzhanin

Connect it https://html2canvas.hertzen.com/
Print like this

function printCanvas(dataUrl) {  
    var windowContent = '<!DOCTYPE html>';
    windowContent += '<html>'
    windowContent += '<head></head>';
    windowContent += '<body style="margin: 0; padding: 0;">'
    windowContent += '<img src="' + dataUrl + '" style="max-width: 100%;">';
    windowContent += '</body>';
    windowContent += '</html>';
    var printWin = window.open('','');
    printWin.document.open();
    printWin.document.write(windowContent);
    printWin.document.close();
    printWin.focus();
    printWin.print();
    printWin.close();
}

html2canvas(window.parent.document.body, {
        onrendered: function(canvas) {
            var cand = document.getElementsByTagName('canvas');
            printCanvas(canvas.toDataURL());
        }
});

Z
zooks, 2016-09-14
@zooks

Take a screenshot and print it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question