当前位置: 首页 > news >正文

世界建设企业网站福田祥菱m2柴油版

世界建设企业网站,福田祥菱m2柴油版,中学生做网站的软件,ctoc网站有哪些华为鸿蒙HarmonyOS已经发展到4.0#xff0c;使用ArkTS作为开发语言。这篇文章结合Dynamsoft Service开发一个简单的鸿蒙应用#xff0c;用来获取办公室里连接PC的扫描仪(惠普#xff0c;富士通#xff0c;爱普生#xff0c;等)#xff0c;把文档扫描到手机里。 准备工作…华为鸿蒙HarmonyOS已经发展到4.0使用ArkTS作为开发语言。这篇文章结合Dynamsoft Service开发一个简单的鸿蒙应用用来获取办公室里连接PC的扫描仪(惠普富士通爱普生等)把文档扫描到手机里。 准备工作 Dynamsoft Service 在连接着扫描仪的电脑上安装Dynamsoft Service。安装包可以满足各种国产操作系统比如统信UOS麒麟Kylin OS等。支持的架构有x86x64arm64mips64el。支持的扫描仪协议包括TWAINWIASANEICA和eSCL(AirPrint)。下载地址 Windows: Dynamsoft-Service-Setup.msimacOS: Dynamsoft-Service-Setup.pkgLinux: Dynamsoft-Service-Setup.debDynamsoft-Service-Setup-arm64.debDynamsoft-Service-Setup-mips64el.debDynamsoft-Service-Setup.rpm 然后访问http://127.0.0.1:18622/DWTAPI/Scanners。正常安装可以获取到扫描仪列表。 在浏览器中打开http://127.0.0.1:18625/把host从127.0.0.1改成PC的局域网IP地址。比如192.168.8.72修改成功可以通过局域网IP地址访问192.168.8.72:18622/DWTAPI/Scanners获取到扫描仪列表。 申请一个免费试用序列号扫描文件的时候需要用。 DevEco Studio 下载地址https://developer.harmonyos.com/cn/develop/deveco-studio/#download。安装前先安装Node.js路径中不要带空格否则安装DevEco Studio, 下载HarmonyOS SDK可能会失败。 鸿蒙程序开发 在DevEco Studio中新建工程。 在entry/src/main/module.json5中添加网络权限 {module: {...abilities: [...],requestPermissions: [{name: ohos.permission.INTERNET}]} }打开entry/src/main/etc/pages/Index.ets导入网络和图像模块 import http from ohos.net.http; import image from ohos.multimedia.image;声明UI组件包含两个按钮一个下拉按钮和一个图片控件 Entry Component struct Index {State deviceNames: SelectOption[] [{value: }]State displayImage: PixelMap undefinedlicenseKey: string LICENSE-KEY; // https://www.dynamsoft.com/customer/license/trialLicense?productdwthost: string http://192.168.8.72:18622devices []index: number 0build() {Column() {Row() {Button(Get Devices).onClick(() {});}).width(30%)Column() {Select(this.deviceNames).selected(this.index).value(this.deviceNames[this.index].value.toString()).font({size: 14, family: serif, style: FontStyle.Normal }).onSelect((index:number){this.index index;})}.width(40%).alignItems(HorizontalAlign.Center)Button(Scan).onClick(() {});}).width(30%)}.backgroundColor(0xFFFFFF).padding({ left: 12 }).width(100%).margin({bottom: 5})Divider()Image(this.displayImage).height(100%).width(100%)}.justifyContent(FlexAlign.Start).width(100%).height(100%).padding({left: 5, top: 5, right: 5, bottom: 5})} }这里的licenseKey和host需要替换成自己的。 当点击Get Devices按钮的时候我们通过HTTP GET来获取扫描仪列表 Button(Get Devices).onClick(() {let url this.host /DWTAPI/Scannerslet httpRequest http.createHttp();httpRequest.on(headersReceive, (header) {console.info(header: JSON.stringify(header));})httpRequest.request(url,{method: http.RequestMethod.GET,header: {Content-Type: application/json}}, (err, data) {if (!err) {try {const jsonArray JSON.parse(data.result.toString())this.devices []let tmp: SelectOption[] []for (const obj of jsonArray) {tmp.push({value: obj.name})this.devices.push(obj)}if (tmp.length 0) {this.index 0this.deviceNames tmp}} catch (error) {console.error(Error parsing JSON:, error);}console.info(code: JSON.stringify(data.responseCode));} else {console.info(error: JSON.stringify(err));httpRequest.off(headersReceive);httpRequest.destroy();}});}).width(30%)当点击Scan按钮的时候我们通过HTTP POST来触发扫描仪扫描文档. 字段extraData用于传输内容等同于HTTP请求中的body。传输的参数可以自定义具体可以参考在线文档。 Button(Scan).onClick(() {if (this.devices.length 0) {return;}let parameters {license: this.licenseKey,device: this.devices[this.index].device,config: {IfShowUI: false,PixelType: 2,//XferCount: 1,//PageSize: 1,Resolution: 200,IfFeederEnabled: false,IfDuplexEnabled: false,}};let url this.host /DWTAPI/ScanJobs;let httpRequest http.createHttp();httpRequest.on(headersReceive, (header) {console.info(header: JSON.stringify(header));})httpRequest.request(url,{method: http.RequestMethod.POST,header: {Content-Type: application/json},extraData: JSON.stringify(parameters),}, (err, data) {if (!err) {if (data.responseCode 201) {let jobId data.result;let url this.host /DWTAPI/ScanJobs/ jobId /NextDocument;let httpRequest http.createHttp();httpRequest.request(url,{method: http.RequestMethod.GET,expectDataType: http.HttpDataType.ARRAY_BUFFER}, (err, data) {if (!err) {if (data.responseCode 200) {// show image}} else {console.info(error: JSON.stringify(err));httpRequest.destroy();}});}} else {console.info(error: JSON.stringify(err));httpRequest.off(headersReceive);httpRequest.destroy();}});}).width(30%)获取到的图像是一个ArrayBuffer我们通过image.createImageSource来创建一个PixelMap对象然后把它赋值给displayImage就可以在UI上显示出来了。 let imageData data.result as ArrayBuffer; const imageSource image.createImageSource(imageData); imageSource.createPixelMap().then(pixelmap {this.displayImage pixelmap; });在华为手机或者鸿蒙模拟器中运行文档扫描程序 源代码 https://gitee.com/yushulx/harmonyos-document-scanner
http://www.yutouwan.com/news/153377/

相关文章:

  • 天津北京网站建设公司网站规划开发前景
  • 公司没有销售网站怎么做业务单位网站的作用
  • 金属建材企业网站建设方案东莞经济贸易学校网络营销
  • 网站开发工程师的经验百度教育官网登录入口
  • 中英双语网站模板跨境电商平台有哪些?列举5个
  • 在线做六级阅读网站企业网络推广宣传方案
  • 个人制作的网站模板怎么建设电影网站
  • 萌宝宝投票网站怎么做响应式视频网站模板下载
  • 找别人做网站江门模板建站系统
  • 网站开发需要服务器吗网站域名 如何选择
  • 兰州工程建设信息网站wordpress侧边导航主题
  • 电商网站开发进度表知名广州网站建设
  • 网站开发可以申请著作权吗wordpress+机械模板
  • 上海做网站服务商网页平台设计
  • 什么是网站风格策划的重点专业的seo培训机构
  • 高校网站网页设计河南工程信息网官网
  • 分页网站城乡建设网官方网站
  • 做网站合肥镇江网站排名优化费用
  • 网站开发商业计划书做外贸找客户最好用的网站
  • 哪里做网站比较好短网址在线生成短网址
  • 网站建设这个职业是什么响应式布局设计
  • 电子政务与网站建设工作总结wordpress框架是什么意思
  • 网站开发 作品理念建网站开发国外客户
  • 宁德公司做网站南京网站建设网站
  • 律师做网站推广有用吗笑话网站模版
  • 网站正则表达式怎么做在线制作图片加闪光字
  • 做购物类网站有哪些wordpress如何加联盟广告位
  • 深圳住房和建设局网站融悦居免费建设网站制作
  • 网站搭建心得做废旧哪个网站好
  • 萍乡网站建设公司创新驱动发展战略纲要