自从 Google 停止使用图表 API 以来,我不得不更改我们多年来一直使用的二维码生成器。我在这里找到了一个新的https://goqr.me/api/doc/create-qr-code/。我的编程方式工作了一个月左右,但现在已经停止了。
我单独测试了生成器,通过将链接复制到浏览器中来确保它正常工作,并且它按预期工作。我认为问题出在调用生成器和将 QR 码添加到徽章卡以便可以打印之间;所以在
<cfif>
块中。我尝试使用 <img>
标签将其放在不同的位置,看看会发生什么。当我将其放在 <cfhttp>
标签下时,生成的二维码显示在上方并与徽章卡分开,但是当我将该图像标签放在 if 块内时,二维码不再显示在任何地方。
任何帮助将不胜感激,我提前感谢您。
这是制作徽章卡的输出部分。
<!DOCTYPE html>
<cfparam name="downloadedBinary" default="">
<html>
<head>
<meta charset="utf-8">
<title>Camera Output</title>
</head>
<body>
<cfif Not IsDefined('Form.LicenseType')>
<cfset Form.LicenseType='1,1'>
</cfif>
<cfif IsDefined("Form.Track")>
<cfif Form.Track eq 'Fair Meadows Tulsa'>
<cfset TrackCode='FMT'>
</cfif>
<cfif Form.Track eq 'Remington Park'>
<cfset TrackCode='RP'>
</cfif>
<cfif Form.Track eq 'Will Rogers Downs'>
<cfset TrackCode='WRD'>
</cfif>
<cfif Form.Track eq 'OHRC'>
<cfset TrackCode='OC'>
</cfif>
</cfif>
<cfif IsDefined("Form.BadgeNumber")>
<cfset Session.BadgeNumber=Form.BadgeNumber>
<cfelse>
<cfset Session.BadgeNumber='rlp'>
</cfif>
<!---<cfdump var="#form#"><cfset x=yyyyy>--->
<cfif Form.CardFormat gt ''>
<cfset newSSN=ToString(RandRange(2,999999))>
<cfset BadgPhotoName=Replace(Form.ExpYear&"-"&TrackCode&"-"&newSSN&Form.CardFormat&ListGetAt(Form.LicenseType,1)&'-1.jpg',' ','','All')>
<cfset myImage = ImageReadBase64("#form.xBase64PhotoString#")>
<cfif val(form.croppedWidth) gt 0>
<cfset ImageCrop(myImage,Val(form.xOffset),Val(form.yOffset),Val(form.croppedWidth),Val(form.croppedHeight))>
</cfif>
<cfquery name="photoList" datasource="binkleyRestore">
Select id
From BCBadgeCards
Where filename='#BadgPhotoName#'
</cfquery>
<cfif photoList.RecordCount>
<cfset newNumber=ToString(RandRange(2,9999))>
<cfset BadgPhotoName=Replace(Form.ExpYear&"-"&TrackCode&"-"&NewSSN&Form.CardFormat&ListGetAt(Form.LicenseType,1)&'-'&newNumber&'.jpg',' ','','All')>
<cfquery name="photoList" datasource="binkleyRestore" >
Select id
From BCBadgeCards
Where filename='#BadgPhotoName#'
</cfquery>
<cfif photoList.RecordCount>
<cfset newNumber=ToString(RandRange(2,9999))>
<cfset BadgPhotoName=Replace(Form.ExpYear&"-"&TrackCode&"-"&NewSSN&Form.CardFormat&ListGetAt(Form.LicenseType,1)&'-'&newNumber&'.jpg','.png ','All')>
</cfif>
</cfif>
<!---<script>
<cfoutput>
var #toScript(form, "jsvar")#;
</cfoutput>
console.log(jsvar);
</script>--->
<cfimage source="#myImage#"
destination="c:/workgroups/webdata/badgecards/#BadgPhotoName#"
action="write"
overwrite="Yes">
<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#")>
<cfoutput>
<img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://www.ohrc.org/binkley/badgeCard/PDFs/#Replace(badgPhotoName, '.jpg', '.pdf', 'All')#" alt="" title=""/>
</cfoutput>
<cfimage action="write" source="#cfhttp.fileContent#" destination="c:/workgroups/webdata/badgecards/qr/#Replace(BadgPhotoName,'.jpg','.png','All')#" overwrite="yes">
</cfif>
<cftransaction>
<cfquery datasource="binkleyRestore" name="updateBadge">
Insert Into
BCBadgeCards (ssn,
[Year],
Track,
LUpdate,
UserID,
[FileName],
BadgeType,
LicenseType,
pdfFileName)
Values ('#Form.SSN#',
'#Right(Year(Now())&Form.ExpYear,4)#',
'#TrackCode#',
'#DateFormat(Now(),'mm/dd/yyyy')#', <!---<cfqueryparam cfsqltype="cf_sql_date" value="#DateFormat(Now(),'mm/dd/yyyy')#">--->
'#Session.Auth.UserLogin#',
'#BadgPhotoName#',
'#Form.CardFormat#',
'#ListGetAt(Form.LicenseType,1)#',
'#Replace(BadgPhotoName,'.jpg','.pdf','All')#')
</cfquery>
<cfquery name="getID" datasource="binkleyRestore">
Select Max(ID) as NewID
From BCBadgeCards
</cfquery>
<cfset BadgeID=getID.NewID>
</cftransaction>
<!---<cfhttp url="http://chart.apis.google.com/chart?chs=160x160&cht=qr&chl=#urlencodedformat('http://www.ohrc.org/BadgeCardSearch/BadgeDisplay.cfm?id=#BadgeID#')#&chld=H|0" result="qrcode" getasbinary="yes">--->
<!---<cfimage action="write" destination="c:/workgroups/webdata/badgecards/qr/#Replace(BadgPhotoName,'.jpg','.png','All')#" source="#qrcode.filecontent#" overwrite="yes" />--->
<cfquery datasource="binkleyRestore" name="results">
Update BCBadgeCards
Set qrCode='#Replace(BadgPhotoName,'.jpg','.png','All')#'
Where id=#BadgeID#
</cfquery>
</cfif>
<cfif Form.CardFormat gt ''>
<cfquery name="BadgeCards" datasource="binkleyRestore">
Select *
From BCBadgeCards
Where id=#BadgeID#
</cfquery>
<cfset Session.BADGPHOTONAME='#BADGPHOTONAME#'>
<cfset Session.EXPYEAR='#Form.EXPYEAR#'>
<cfset Session.LICENSEENAMEPOINTSIZE='#Form.LICENSEENAMEPOINTSIZE#'>
<cfset Session.FULLNAME='#Form.FULLNAME#'>
<cfset Session.LicenseType='#Form.LicenseType#'>
<cfset Session.EMPLOYER='#Form.EMPLOYER#'>
<cfset Session.RESTRICTIONS='#Form.RESTRICTIONS#'>
<cfset Session.DOB='#Form.DOB#'>
<cfset Session.FPDATE='#Form.FPDATE#'>
<cfset Session.RestrictedFromBackside='#Form.RestrictedFromBackside#'>
<cfset Session.BadgeID=#BadgeID#>
<cfif IsDefined("Form.SpouseName")>
<cfset Session.SpouseName="#Form.SpouseName#">
<cfset Session.SPOUSENAMEPOINTSIZE='#Form.SPOUSENAMEPOINTSIZE#'>
</cfif>
<cfoutput>
<script>
var rowObject=window.opener.document.getElementById('BadgeCardRow');
var newCell = rowObject.insertCell(0);
newCell.align='center';
newCell.valign='center';
newCell.innerHTML =
'<span class="DataLabel" style="text-align: center;">'+
'<a class="special" href="/binkleyphotos/BadgeCards/#BadgeCards.filename#" target="_blank">'+
'<img src="/binkleyphotos/BadgeCards/#BadgeCards.filename#" border="0" height="100" alt="#BadgeCards.filename#" ><br>'+
'#BadgeCards.Year#-#BadgeCards.Track#'+
'</a>'+
'</span>'+
'<cfif session.trackdatadeletepicsuserlist Contains SESSION.Auth.UserLogin>'+
'<a href="tstDeleteBadgeCard.cfm?Photo=#BadgeCards.filename#&id=#BadgeCards.id#&tdLicenseID=#Form.tdLicenseID#">'+
' <img src="../delete.gif" border="0" alt="x" height="8" width="8" name="Delete" title="Delete This Photo">'+
'</a>'+
'</cfif>'+
'<span class="DataLabel" style="font-size: 10px;">'+
'<br />#BadgeCards.id#'+
'<cfif Trim(badgeCards.LicenseType) gt "">'+
'<br />'+
'<cfif Trim(badgeCards.pdfFileName) gt "">'+
'<a href="/Binkley/BadgeCard/PDFs/#BadgeCards.pdfFileName#" class="Special" target="_blank">'+
'#BadgeCards.LicenseType#-#BadgeCards.BadgeType#'+
'</a>'+
'<cfelse>'+
'#BadgeCards.LicenseType#-#BadgeCards.BadgeType#'+
'</cfif>'+
'<br />#DateFormat(BadgeCards.LUpDate,"mm/dd/yyyy")#'+
'</cfif>'+
'</span>';
</script>
</cfoutput>
<div style="color: Red; font-family: Calibri; font-weight: bold; font-size: 24px; text-align: center;">
<br />
<br />
Please close this window after printing your badge card
</div>
</cfif>
<cfswitch expression="#Form.CardFormat#">
<cfcase value="White">
<iframe src="WhiteOccupationalLicense.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Green">
<iframe src="GreenOccupationalLicense.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Red RP">
<iframe src="RPGamingBadge.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Red WRD">
<iframe src="WRDGamingBadge.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Red All Tracks">
<iframe src="AllTracksGamingBadge.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Under 16">
<iframe src="Under16.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Under 18">
<iframe src="Under18.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Green Under 18">
<iframe src="GreenUnder18.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Spouse">
<iframe src="SpousePass.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="FMT Green">
<iframe src="FairMeetOnlyGreen.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="FMT White">
<iframe src="FairMeetOnlyWhite.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Blue Staff">
<iframe src="OHRCStaffBadge.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfcase value="Law Enforcement Officer">
<iframe src="LawEnforcementCommission.cfm" frameborder="no" height="800" width="800" ></iframe> <!--- onload="top.window.close();" --->
</cfcase>
<cfdefaultcase>
<div style="color: Blue; font-family: Calibri; font-weight: bold; font-size: 24px; text-align: center;">
<br /> <br />
You didn't choose a card type<br />
Please choose a Card Template and try your print job agian
<br /> <br />
<div style="color: red; font-family: Calibri; font-weight: bold; font-size: 24px; text-align: center;">
You may close this window
</div>
</div>
</cfdefaultcase>
</cfswitch>
</body>
</html>
您的ColdFusion代码没有任何问题。它可以很好地获取二维码。
<cfset qrCodeURL = "https://www.ohrc.org/binkley/badgeCard/PDFs/">
<cfset apiURL = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=">
<cfhttp method="get" url="#apiURL##qrCodeURL#" getasbinary="yes">
<cfoutput>
<img
src="data:#cfhttp.mimetype#;base64,#toBase64( cfhttp.fileContent )#"
height="150" width="150"
>
</cfoutput>
如果您只是在屏幕上显示二维码图像,那么您甚至不需要使用
cfhttp
来获取图像。
<cfoutput>
<img
src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://www.ohrc.org/binkley/badgeCard/PDFs/#Replace(badgPhotoName, '.jpg', '.pdf', 'All')#"
height="150" width="150"
>
</cfoutput>
你说“我的编程方式工作了一个月左右,但现在已经停止了。”它真的在没有任何代码更改的情况下停止工作吗?
您发布了很多代码,其中包括不相关的内容(例如数据库查询),因此很难找出问题所在,但我怀疑您的 JavaScript 中有 ColdFusion 代码。例如这些行:
'</span>'+
'<cfif session.trackdatadeletepicsuserlist Contains SESSION.Auth.UserLogin>'+
'<a href="tstDeleteBadgeCard.cfm?Photo=#BadgeCards.filename#&id=#BadgeCards.id#&tdLicenseID=#Form.tdLicenseID#">'+
' <img src="../delete.gif" border="0" alt="x" height="8" width="8" name="Delete" title="Delete This Photo">'+
'</a>'+
'</cfif>'+
ColdFusion 代码在服务器上运行和评估。然后 HTML 返回到运行 JavaScript 代码的浏览器。如果您查看页面的源代码,您可能会发现问题所在。浏览器中的控制台也可能为您提供一些线索。