ColdFusion getQRSVG() UDF - Returns responsive SVG source
In a project I'm working on, I needed to generate a QR code and display it within an HTML file that is converted to a PDF using WKHTMLTOPDF. I didn't want to rely upon physical, statically-hosted SVG image files and wished to embed it. With WKTHMLTOPDF, I could use javascript to generate the QR code, but that requires adding a time delay and I didn't want to negatively impact processing time (even though WKHTMLTOPDF is faster than CFDocument.) I already have a ColdFusion wrapper for Zint Barcode Generator function, so I just needed to write a CFML wrapper to: use generateZint() to create a temporary SVG file read the temp file data remove XML & HTML doctype headers modify the SVG XML source to "make it responsive" delete the temp file Here it is. I hope that this helps some CFML developers. Source Code https://gist.github.com/JamoCA/fbbd2599102216448ada8e9f85d40b9c

In a project I'm working on, I needed to generate a QR code and display it within an HTML file that is converted to a PDF using WKHTMLTOPDF. I didn't want to rely upon physical, statically-hosted SVG image files and wished to embed it. With WKTHMLTOPDF, I could use javascript to generate the QR code, but that requires adding a time delay and I didn't want to negatively impact processing time (even though WKHTMLTOPDF is faster than CFDocument.)
I already have a ColdFusion wrapper for Zint Barcode Generator function, so I just needed to write a CFML wrapper to:
- use generateZint() to create a temporary SVG file
- read the temp file data
- remove XML & HTML doctype headers
- modify the SVG XML source to "make it responsive"
- delete the temp file
Here it is. I hope that this helps some CFML developers.
Source Code
https://gist.github.com/JamoCA/fbbd2599102216448ada8e9f85d40b9c