• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
3

Adding dynamic QR code generator to ColdFusion program

Explorer ,
Feb 28, 2024 Feb 28, 2024

Copy link to clipboard

Copied

When I took over the care of a CF intranet site, the Google chart API was being used to generate QR codes that are on employee badges; this won't be working for much longer and I need to find a replacement.  

 

<cfimage source="#myImage#" 
destination="c:/workgroups/webdata/badgecards/#BadgPhotoName#" 
action="write" 
overwrite="Yes">
 
result="qrcode" 
getasbinary="yes">
 
<cfimage action="write" 
destination="c:/workgroups/webdata/badgecards/qr/#Replace(BadgPhotoName,'.jpg','.png','All')#"  
source="#qrcode.filecontent#" 
overwrite="yes">
 
This is what the code looks like I found a new generator, but I haven't been able to get it to work correctly.  The generator that I was looking at is goqr.me/api, but I was wondering if Adobe has something like that, that I could use?
TOPICS
Advanced techniques , Builder , Getting started

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Community Expert , Mar 24, 2024 Mar 24, 2024

No, there are currently no facilities for generating QR codes in ColdFusion. You have to use a third-party QR code generator. Google will show you some, such as CFQRCode.

Votes

Translate

Translate
Explorer , Mar 26, 2024 Mar 26, 2024

I found a QR code generator to use, and it has worked great since I added it - until Sunday and not it isn't working.  I copied the URL into a browser to make sure that the generator was working and it is, but the codes aren't printing on the badge card.

<cfhttp method="get" url="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='https://www.ohrc.org/binkley/badgeCard/PDFs/#replace(badgPhotoName, '.jpg', '.pdf', 'All')#'" getasbinary="yes" charset="utf-8"/>
   
    <cfif isImageFile("#
...

Votes

Translate

Translate
Community Expert , Mar 27, 2024 Mar 27, 2024

Addendum: for the sake of rigour, I would add a try/catch to catch errors that arise when the download does not have image content-type

<cftry>
	<!--- Convert the binary to an image in ColdFusion --->
	<cfimage source="#downloadedBinary#" name="downloadedImage">
	
	<cfif isImage(downloadedImage)> 
		<!--- Use, preferably, replaceNoCase: think Jpg, JPG, jpg --->    
		<cfset jpg_to_png=replaceNoCase(BadgPhotoName,'.jpg','.png','all')>
	    <cfimage action="write" source="#downloadedImage#" destin
...

Votes

Translate

Translate
Community Expert ,
Mar 24, 2024 Mar 24, 2024

Copy link to clipboard

Copied

No, there are currently no facilities for generating QR codes in ColdFusion. You have to use a third-party QR code generator. Google will show you some, such as CFQRCode.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

I found a QR code generator to use, and it has worked great since I added it - until Sunday and not it isn't working.  I copied the URL into a browser to make sure that the generator was working and it is, but the codes aren't printing on the badge card.

<cfhttp method="get" url="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='https://www.ohrc.org/binkley/badgeCard/PDFs/#replace(badgPhotoName, '.jpg', '.pdf', 'All')#'" getasbinary="yes" charset="utf-8"/>
   
    <cfif isImageFile("#cfhttp.fileContent#")>
        <cfset myImage=imageNew("#cfhttp.fileContent#")>
        <cfset isImage ("#cfhttp.fileContent#")>
        <cfimage action="write" source="#cfhttp.fileContent#" destination="c:/workgroups/webdata/badgecards/qr/#Replace(BadgPhotoName,'.jpg','.png','All')#">
    </cfif>
This is the code that is suddenly not working.  Any suggestions would be greatly appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Suggestion as a replacement for the code below the cfhttp tag:

<cfset downloadedBinary=cfhttp.fileContent>
<!--- Convert the binary to an image in ColdFusion --->
<cfimage source="#downloadedBinary#" name="downloadedImage">

<cfif isImage(downloadedImage)> 
	<!--- Use, preferably, replaceNoCase: think Jpg, JPG, jpg --->    
	<cfset jpg_to_png=replaceNoCase(BadgPhotoName,'.jpg','.png','all')>
    <cfimage action="write" source="#downloadedImage#" destination="c:/workgroups/webdata/badgecards/qr/#jpg_to_png#">
</cfif>

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 26, 2024 Mar 26, 2024

Copy link to clipboard

Copied

Thank you - I'll give that a try.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

Addendum: for the sake of rigour, I would add a try/catch to catch errors that arise when the download does not have image content-type

<cftry>
	<!--- Convert the binary to an image in ColdFusion --->
	<cfimage source="#downloadedBinary#" name="downloadedImage">
	
	<cfif isImage(downloadedImage)> 
		<!--- Use, preferably, replaceNoCase: think Jpg, JPG, jpg --->    
		<cfset jpg_to_png=replaceNoCase(BadgPhotoName,'.jpg','.png','all')>
	    <cfimage action="write" source="#downloadedImage#" destination="c:/workgroups/webdata/badgecards/qr/#jpg_to_png#">
	</cfif>
<cfcatch type="any">
	<!--- Handle any errors --->
</cfcatch>
</cftry>

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2024 Apr 18, 2024

Copy link to clipboard

Copied

LATEST

I didn't have any luck with above solutions, but I did figure out a better way to explain what I'm needing to do.  I need to generate the QR Code, save it to a folder and then set a variable with the information that I can call from another piece of code.  Generate in tst2web and then call the variable from the div starting at line 77 in the tstWhite code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation