Skip to content

Instantly share code, notes, and snippets.

@jmas
Last active February 28, 2024 22:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmas/d1b5123419cdfcd909afb2ce486557f3 to your computer and use it in GitHub Desktop.
Save jmas/d1b5123419cdfcd909afb2ce486557f3 to your computer and use it in GitHub Desktop.
barcode javascript print
<svg id="code128"></svg>
<script src="https://cdn.jsdelivr.net/jsbarcode/3.3.16/barcodes/JsBarcode.code128.min.js"></script>
JsBarcode("#code128", "AD243", {
format: "CODE128",
displayValue: false
});
window.print();
@media print {
@page {
size: 30mm 21mm;
margin: 0;
padding: 0;
}
html, body {
position: relative;
width: 100%;
height: 100%;
max-width: 100%;
max-height: 97%;
margin: 0;
padding: 0;
}
svg {
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
}
}
@vineetbillorey
Copy link

how can i print barcode?

@jmas
Copy link
Author

jmas commented Aug 20, 2021

@vineetbillorey Combine together all 3 files + put styles on page and open page in browser then you will see 'Print' popup with barcode.

@vineetbillorey
Copy link

Thanks.
I already did it some way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment