I've followed this answer to print a specific element of a view and it works great, but without CSS styling. I want to print a bootstrap table with some fields, nothing too fancy. This is the code I ended up using:
function printDiv(divId) {
window.frames["print_frame"].document.body.innerHTML= $("." + divId).html();
window.frames["print_frame"].window.focus();
window.frames["print_frame"].window.print();
}
The answer has an extra part where it declares this:
printDivCSS = new String ('<link href="myprintstyle.css" rel="stylesheet" type="text/css">')
And later concatenates in the html as follows:
printDivCSS + $("." + divId).html()
I've added a scss file but it doesn't properly show the bootstrap table, which seems reasonable since it is not defined in that sass file (although other thins are defined and are shown properly).
So the real question should be: how can I properly print a bootstrap table with its css formatting? It is printing the correct information ATM, but it is pretty ugly.
The application is a rails application. In which I have all css files under:
add/assets/stylesheets
I need to include bootstrap assets. I have the following file:
bootstrap_and_override.css.less
@import "twitter/bootstrap/bootstrap";
// Glyphicons
@import "twitter/bootstrap/glyphicons.less";
I tried doing:
printDivCSS = new String ('<link href="bootstrap_and_overrides.css.less" rel="app/assets/stylesheet">')
In a similar fashion as before but it is not working either.