farzad farzad - 1 year ago 129
jQuery Question

why css omitted in print area

I have a issue with print area from page . when i try print whole page structure is work with css but when i want print area , css not work and omitted . why ?

I use bootstrap 3 and i fired print by this code :

$(document).on('click','#print', function(){
w=window.open();
w.document.write($(this).parents('.panel').find('.panel-body').html());
w.print();
w.close();
});


I try this css but not work .

@media print {
body * {
visibility: hidden;
}
table, table * {
visibility: visible;
direction:rtl;
}
table {
position: absolute;
left: 0;
top: 0;
}
}

Answer Source

You probably just need to add the style element (with the media print) to the html you are generating in the print window. Also, you should consider if you need any other css applied to the print document. You are copying some elements of the current page, but not the css.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download