java - 冷融合 QR 图像 - JAVA 路径
问题描述
我不擅长 JAVA
我从这里开始使用 QRToad https://github.com/boltz/QRToad
ColdFusion 2016 - MS Server 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\cfusion\lib
我把它放错地方了吗?还是我需要改变这个?
"java","com.itextpdf.text.pdf.BarcodeQRCode"
解决方案
我将此功能与谷歌二维码应用程序(包括)使用的zxingchart.apis.google.com
结合使用。您需要下载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>
推荐阅读
- android - 谷歌移动视觉文本是否仅适用于某些智能手机?
- javascript - 如何忽略特殊的 td 节点及其整个子节点?
- django - 在 Django 查询集中结合日期和时间 - TypeError
- reactjs - 在 react-vis 时间刻度轴中设置 24 小时时间格式
- javascript - Splunk 是否支持甘特图放大功能?
- excel - 用户表单组合框搜索,但如果为空则清除
- python - Python 条形图
- r - How to use a list name as character
- java - 如何从点创建多边形(Spatial4j)
- python - 从列表/元组列表中获取值