I try to print a div, from jQuery, in the following way:
function printDiv(divVer) {
var printContents = document.getElementById(divVer).innerHTML;
var document_html = window.open("_blank");
document_html.document.write( "<html><head><title>Imprimir Pedido</title>" );
document_html.document.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styles.css\">" );
document_html.document.write( "</head><body>" );
document_html.document.write( printContents );
document_html.document.write( "</body></html>" );
setTimeout(function () {
document_html.print();
}, 500)
}
$(document).on('click','#imprimirPedido' ,function() {
printDiv('divVer')
});
So far, great, by giving "Print" a simple input, I opened a new tab, in which I see the format with CSS, however, in the print preview, it no longer uses the CSS styles, You see a very ugly ugly board.
Also, I would like to default to using an A5 format, and by default I get A4, I would like to know if it could also be changed.
Thank you all and regards.