我不太擅长JAVA
我从QRToad https://github.com/boltz/QRToad开始
ColdFusion 2016 - MS 2016 :我已经重启了几次cf服务器。
我在第5行有个错误
未找到的类: com.itextpdf.text.pdf.BarcodeQRCode
错误发生在
C:/upcloud/_live_websites/_silkea/test/QR/com/timcunningham/QRToad/QRCode.cfc: line 5
Called from C:/upcloud/_live_websites/_silkea/test/qr/getqrtest.cfm: line 2
Called from C:/upcloud/_live_websites/_silkea/test/QR/com/timcunningham/QRToad/QRCode.cfc: line 5
Called from C:/upcloud/_live_websites/_silkea/test/qr/getqrtest.cfm: line 2
3 : put the itext JAR in your ColdFusion class path.
4 : Restart ColdFusion service">
5 : <cfset QR = createObject("java","com.itextpdf.text.pdf.BarcodeQRCode")>这是JAR : itext-pdfa-5.5.13.2.jar
我把它写在: C:\ColdFusion2016\jre\lib和C:\ColdFusion2016\c聚变\lib
我是不是把它放错地方了?还是我需要改变这个?
"java","com.itextpdf.text.pdf.BarcodeQRCode“
发布于 2021-03-05 20:50:08
我将此函数与Google代码应用程序(包括中兴 )使用的中兴结合使用。您需要下载core-3.4.0.jar和javase-3.4.0.jar并将它们放到C:\ColdFusion2016\cfusion\lib中
<cfscript>
public string function createQRCode(
required string data,
integer width=180,
integer height=180,
integer margin=4,
){
local.filePath = getTempDirectory() & application.fwUtilService.generateUUID() & '.png';
local.objQRCodeWriter = CreateObject('java', 'com.google.zxing.qrcode.QRCodeWriter');
local.objBarcodeFormat = CreateObject('java', 'com.google.zxing.BarcodeFormat');
local.objEncodeHintType = CreateObject('java', 'com.google.zxing.EncodeHintType');
local.objHashMap = CreateObject('java', 'java.util.HashMap');
local.objFileSystems = CreateObject('java', 'java.nio.file.FileSystems');
local.objMatrixToImageWriter = CreateObject('java', 'com.google.zxing.client.j2se.MatrixToImageWriter');
local.qrCodeWriter = local.objQRCodeWriter.init();
local.objHashMap.put(local.objEncodeHintType.MARGIN, javacast('int', arguments.margin));
local.objHashMap.put(local.objEncodeHintType.CHARACTER_SET, "UTF-8");
local.objEnumMap = CreateObject('java', 'java.util.EnumMap').init(local.objHashMap);
local.bitMatrix = local.qrCodeWriter.encode(data, local.objBarcodeFormat.QR_CODE, arguments.width, arguments.height, local.objEnumMap);
local.path = local.objFileSystems.getDefault().getPath(local.filePath, []);
local.objMatrixToImageWriter.writeToPath(local.bitMatrix, "PNG", local.path);
return local.filePath;
}
</cfscript>发布于 2021-03-05 20:39:50
这可能要简单得多。
<cfhttp url="http://chart.apis.google.com/chart?chs=250x250&cht=qr&chl=http://www.website.com" result="qrcode" getasbinary="yes">
<cfimage action="writeToBrowser" source="#qrcode.filecontent#" style="height:250px;width:250px">所以我会用这个玩一会儿,然后试着保存谷歌的拉力。其他的QR码是相当古老的。
是的简单多了。如果没有创建qrimg,就闻一闻。
<cfif qrimg is "">
<cfhttp url="http://chart.apis.google.com/chart?chs=250x250&cht=qr&chl=http://webaddress?vid=#vid#&src=p" result="qrcode" getasbinary="yes">
<cfimage action="writeToBrowser" source="#qrcode.filecontent#" style="height:250px;width:250px">
<cfimage action="write" source="#qrcode.filecontent#" destination="#expandPath( 'QR_#vid#.jpg' )#" overwrite="true">
#vnumber# : #vname#<br>
<cfquery name="nm" datasource="#fds#">
update fv
set qrimg = 'QR_#vid#.jpg'
where vid = '#vid#'
</cfquery>
<cfelse>
<img src="QR_#vid#.jpg">
<br>
#vnumber# : #vname#<br>
</cfif>https://stackoverflow.com/questions/66498968
复制相似问题