I'm trying to print only the part of an HTML page that has a barcode. HTML:
<div class="barcode-img">
<svg id="barcode"
jsbarcode-textmargin="0"
jsbarcode-fontoptions="bold"
style="width: 30%; height: 30%;">
</svg>
<script>
JsBarcode("#barcode", "<?php echo $bar_number; ?>", {
format: "ean13",
width: 3
});
</script>
</div>
CSS:
@media print {
body * {
visibility: hidden;
}
#barcode, #barcode *{
visibility: visible;
}
#barcode
{
position: fixed;
left: 0px;
top: 0px;
}
I've seen similar solutions in many places, but doing so my barcode appears twice or more on the print page.
How can I solve this problem?