Blog
Generate Barcodes and QR codes with Javascript and jQuery (ZXING)
One of the best ways to generate barcodes and QR codes is to use the open source library Zebra Crossing, aka ZXING. It’s available in multiple programming languages, but you can only reliably generate these codes on the server-side. If you are reading this blog post, it probably means you are hoping you can simply generate a barcode or QR code right from the client side front end using javascript or jquery.
Thankfully, API2PDF offers a ZXING endpoint to allow you to do just that. You would display the barcode / QR code as if it was a standard HTML <img>, making it possible to render whenever you want, or even through an ajax call.
All you need to do in an <img src=””> tag in HTML to generate a barcode or QR code using API2PDF is to follow this format:
https://v2018.api2pdf.com/zebra?format={format}&apikey={YourApiKey}&value={YourText}
Replace {format} with the type of barcode or QR code you are looking for. You can find a list of formats here: https://www.api2pdf.com/documentation/advanced-options-zxing-zebra-crossing-barcodes/
Replace {YourApiKey} with an API key that you can quickly grab here: https://portal.api2pdf.com
And lastly, replace {YourText} with the content that should be converted into a barcode or QR code.
If you are looking for a live demo where you can see this in action with javascript and jQuery, where you can click a button and generate a barcode / QR code, check out the sample JS Fiddle below. All you need to do is replace the ‘YOUR-API-KEY’ with the api key you grabbed from portal.api2pdf.com.
https://jsfiddle.net/apexdodge/4Lstxbwp/5/
That’s how simple it is to get barcodes and QR codes working from HTML web pages only! No need to deal with creating your own endpoint and installing libraries on your own servers. Just hook it up to API2PDF and you’re good to go.