1
I got it with the help of Stackoverflow assemble a script for printing a document, now I’m with a second problem, the script opens the print page without formatting the css.
I saw an example right here but could not change according to what I need, I saw it here:
In the example css is being loaded by script, but in my example I have this:
document.getElementById('btn').onclick = function() {
var conteudo = document.getElementById('conteudo').innerHTML,
impressao = window.open('about:blank');
impressao.document.write(conteudo);
impressao.window.print();
impressao.window.close();
};
How can I load css in my example?
And where is the CSS? You want to add it to a popup open? It’s a CSS code block or a file?
– KaduAmaral
Hello @Kaduamaral, css is called on my page being inserted by this command: <link href=".. /_comp/externals/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
– adventistapr
That code
<link href="...">is within the elementdiv#conteudo? Example– KaduAmaral
No, it is called in head, the example you passed runs, shows the preview formatted but the printing is not configured.
– adventistapr
Well, then, keep in mind that
impressao.documentis a new document (a totally different and independent website for the browser). Place a copy of the code<link href="...">within the elementdiv#conteudoor try something likeimpressao.document.write('<link href="...">' + conteudo);.– KaduAmaral