This content originally appeared on DEV Community and was authored by James Moberg
I referenced Zint Barcode Generator in a post from 2020 and included a very basic command line syntax for a QR code. Zint is able to generate 50 different barcode formats and I haven't found a java library that is capable of supporting the same formats or outputting files as BMP, EPS, GIF, PCX, TIF, EMF, PNG or SVG. (NOTE: I prefer to save as SVG and then use the static file when generating PDFs using WKHTMLTOPDF.)
There is a java port of Zint called OkapiBarcode. It's actively maintained, but looks like it requires more effort when building barcodes, requires the use of constants and doesn't appear to have any documentation beyond a couple of basic examples.
A project that I'm currently working on needs QR codes for the ticketing service. Normally, I'd use QRCode.js as it works with my CF_WKHTMLTOPDF custom tag if JavascriptDelay
is configured for a second or two, but I'm not sure how reliable this would be when generating multiple pages that each contain a QR code. (NOTE: The built-in CFHTMLtoPDF tag doesn't support a javascript delay.)
In my quest to create a "more perfect DRY world" for myself, I decided to expand our existing logic that generates a command line string. Support for other features has been added and it triggers the executable and returns results. I've also made some tweaks to allow an entire configuration to be passed as a single options
argument.
Here's sample CFML syntax to generate a basic QR code in SVG format. Enjoy!
options = [
"filePath": "D:\www\this-is-a-test.svg"
,"data": "This is a test"
,"exePath": "C:\zint\zint.exe"
];
zintData = request.generateZint(options=options);
if (zintData.success){
writeoutput('<img src="/this-is-a-test.svg" style="width:250px; height:auto;">');
} else {
writedump(var=zintData.errors, label="Zint errors");
}
Source Code
https://gist.github.com/JamoCA/fbbd2599102216448ada8e9f85d40b9c
This content originally appeared on DEV Community and was authored by James Moberg
James Moberg | Sciencx (2024-10-30T23:14:05+00:00) ColdFusion Wrapper for Zint Barcode Generator. Retrieved from https://www.scien.cx/2024/10/30/coldfusion-wrapper-for-zint-barcode-generator/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.