Vue-Element-Admin 内实现word 模板静默打印
主要从两个维度入手:
- PHPWORD 安装包,将模板参数替换好生成对应的
test.docx
docx
是XML 文件 doc 是二进制文件无法解析
// 核心实现方式
$this->templateExtend($templateProcessor = new TemplateProcessor($this->getTemplate()));
$templateProcessor->setValues($this->getNeedKeys());
$templateProcessor->saveAs($docPath);
生成好的
docx
文件存在服务器,生成一个链接,开始下面的步骤接入
光速云打印服务
带水印(但有办法去掉,花钱也能去掉)云打印word 方式:
GSCloudPlugin.PrintWord({ Title: 'Word0001', Width: 210, Height: 297, Url: 'https://gsypp.com/files/demo/demo.docx', PrinterName: app.getPrinterName(), OnSuccess: function(result) { app.console.log(result); }, OnError: function(result) { app.console.log(result); }, });
云打印地址
:点我
光速云插件是一个前端的插件,支持windows , Mac ,Linux ,Android
打印本机都是在局域网,外网打印暂时没支持,给有需要的朋友提供个途径,这个东西花费了1周多才找到好的方案,挺难的
本作品采用《CC 协议》,转载必须注明作者和本文链接
什么办法去掉