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

网站建设定义免费永久网站空间

网站建设定义,免费永久网站空间,微信小程序页面跳转,短期设计培训班​ 最近接到用户提过来的需求#xff0c;需要一个能够自动打印图纸的功能#xff0c;经过几天的研究整出来个初版了的#xff0c;分享出来给大家#xff0c;希望能有帮助。 需求描述: ​ 生产车间现场每天都有大量的图纸需要打印#xff0c;一个一个打印太慢了#xff0…​ 最近接到用户提过来的需求需要一个能够自动打印图纸的功能经过几天的研究整出来个初版了的分享出来给大家希望能有帮助。 需求描述: ​ 生产车间现场每天都有大量的图纸需要打印一个一个打印太慢了希望可以有个批量打印的功能。 分析 ​ 我们的图纸是存在服务器上都是pdf版本的所以批量打印程序可以通过文件名称然后程序自动将共享文件推送到打印机上打印这样就可以实现自动化了并且后续还可以根据情况进行扩展 代码 初版的程序比较简单使用的是springboot spring shell 来实现具体代码如下 !-- pom.xml 片段 -- !-- spring-boot-starter 版本是随意选的 -- parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.7.14/version /parent dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependency!-- spring-shell 版本需要与 spring-boot-starter 匹配 --dependencygroupIdorg.springframework.shell/groupIdartifactIdspring-shell-starter/artifactIdversion2.1.11/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversion1.18.26/versionoptionaltrue/optionalscopecompile/scope/dependencydependencygroupIdorg.apache.pdfbox/groupIdartifactIdpdfbox/artifactIdversion2.0.26/version/dependencydependencygroupIdcn.hutool/groupIdartifactIdhutool-all/artifactIdversion5.8.22/version/dependency/dependenciesbuildfinalNameDrawPrinter/finalNamepluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdversion2.5.4/version !-- 使用适合你的Spring Boot版本 --executionsexecutiongoalsgoalrepackage/goal/goals/execution/executions/plugin/plugins/buildshell命令代码 package xxxx;import cn.hutool.core.util.StrUtil; import com.higer.ipd.tools.drawprinter.commons.PdfPrinter; import com.higer.ipd.tools.drawprinter.entity.DrawInfoEntity; import com.higer.ipd.tools.drawprinter.service.IDrawInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.shell.standard.ShellComponent; import org.springframework.shell.standard.ShellMethod;import java.io.File; import java.util.HashMap; import java.util.List;ShellComponent public class CommonCommand {Autowiredprivate IDrawInfoService drawInfoService;ShellMethod(value 打印消息,key000,group test)public void printMessage(String message) {System.out.println(message);}ShellMethod(value 查看本地打印机,key101,group print)public void showLocPrinter(){PdfPrinter.getLocalPrinter().keySet().forEach(System.out::println);}ShellMethod(value打印图纸,key103,group print)public void printPdf(String printerName,String fileName,String pageSize){try {String result PdfPrinter.print(new File(fileName), printerName, pageSize);if(StrUtil.isBlank(result)){System.out.println(打印成功);}else{System.out.println(result);}} catch (Exception e) {e.printStackTrace();System.out.println(打印出错!);}} }上面开发了两个shell命令:“查看本地打印机和打印图纸”. 打印图纸代码片段如下 public static String print(File file, String printerName,String pageSize) throws Exception {if(StrUtil.isBlank(printerName) || file null || !file.exists()){return 未指定打印机或待文件不存在请确认;}// 1.根据打印机名称找到对应的打印机服务MapString, PrintService printerMap getLocalPrinter();PrintService printService printerMap.get(printerName);if(printService null){return 没有找到指定的打印机;}// 2.加载pdf文件并设置打印配置打印try (PDDocument document PDDocument.load(file)){PrinterJob printJob PrinterJob.getPrinterJob();printJob.setJobName(file.getName());printJob.setPrintService(printService);PDFPrintable pdfPrintable new PDFPrintable(document, Scaling.SCALE_TO_FIT);Book book new Book();PageFormat pageFormat new PageFormat();pageFormat.setOrientation(PageFormat.PORTRAIT);//纵向pageFormat.setPaper(getPaper(pageSize));//设置纸张book.append(pdfPrintable, pageFormat, document.getNumberOfPages());printJob.setPageable(book);printJob.setCopies(1);//设置打印份数HashPrintRequestAttributeSet pars new HashPrintRequestAttributeSet();pars.add(Sides.ONE_SIDED); //设置单双页printJob.print(pars);}return ; }效果 启动后进入输入命令状态输入help可以看到帮助信息效果如下 输入 help 103 可以看到打印图纸的帮助信息命令格式为: 103 打印机名称 文件名称 页面大小A3/A4 源码下载
http://www.yutouwan.com/news/48666/

相关文章:

  • 做网站线哈尔滨营销型网站建设
  • 网站建设规划书的空间做网站前期需要准备什么
  • 企业网站定制多少钱泉州网红打卡地
  • 百度推广建站平台自己做的网站怎么发布
  • 吉安市建设规划局网站wordpress 产品报价系统
  • ps做网站边框如何开网店无货源不需要投资
  • 网站开发中所需要的绘图工具四川泸州做网站的公司有哪些
  • 龙岗网站建设排名网站优化大计
  • 2023最好用的浏览器seo引擎搜索网站
  • 成都市建设质监站网站怎样淘宝做seo网站推广
  • 洛阳霞光做网站重庆网页制作工作室
  • 深圳生产型企业网站建设专业网站设计制合肥作
  • 关键词网站建设优化建设局跟住建局一样吗
  • zencart 官方网站贵阳国家经济技术开发区门户网站
  • 深圳优秀网站建设定制网站ico如何添加
  • 小白建站软件凡科网账号怎么注销
  • 团购网站建设工程监理网站
  • 建立网站请示企业制作网站一般多少钱
  • 广州网站开发服务外协机械加工订单
  • thinkphp网站建设课程上海建智建设工程咨询
  • 怎样做网站软件网站开发面试都会问什么问题
  • 网站由哪些部分组成部分组成部分庆阳有人做农资网站吗
  • 高端网站设计理念深圳市中心房价
  • 养老网站备案必须做前置审批吗博物馆网站建设经费请示
  • 老河口建设局网站网站建设教程网页
  • 坪山网站建设自动外链工具
  • 网站 无限下拉wordpress 更新 固定链接
  • 济南做网站的好公司有哪些兵团公共资源交易中心
  • 免费可商用的素材网站wordpress黑色名片主题
  • 网站建设开发费入什么科目做外贸网站用什么空间