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

长寿做网站商务网站开发实训报告

长寿做网站,商务网站开发实训报告,网上商城采购流程,广告网页推广方案word转pdf vue2java 文章目录 word转pdf vue2java一、前端 vue-pdf1、下载依赖2、封装的组件 二、java使用aspose#xff08;付费#xff09;1.引入库2.封装的工具类3、付费密钥文件 总结 提示#xff1a;以下是本篇文章正文内容#xff0c;下面案例可供参考 一、前端 vue…word转pdf vue2java 文章目录 word转pdf vue2java一、前端 vue-pdf1、下载依赖2、封装的组件 二、java使用aspose付费1.引入库2.封装的工具类3、付费密钥文件 总结 提示以下是本篇文章正文内容下面案例可供参考 一、前端 vue-pdf 1、下载依赖 安装依赖 npm install vue-pdf2、封装的组件 封装的vue组件 templatediv idcontainer!-- 上一页、下一页 --div classright-btn!-- 输入页码 --div classpageNuminput v-model.numbercurrentPagetypenumberclassinputNumberinputinputEvent() / {{ pageCount }}/divdiv clickchangePdfPage(first)classturn首页/div!-- 在按钮不符合条件时禁用 --div clickchangePdfPage(pre)classturn-btn:stylecurrentPage1?cursor: not-allowed;:上一页/divdiv clickchangePdfPage(next)classturn-btn:stylecurrentPagepageCount?cursor: not-allowed;:下一页/divdiv clickchangePdfPage(last)classturn尾页/div/divdiv classpdfAreapdf :srcsrcrefpdfv-showloadedRatio1:pagecurrentPagenum-pagespageCount$eventprogressloadedRatio $eventpage-loadedcurrentPage$eventloadedloadPdfHandlerlink-clickedcurrentPage $eventstyledisplay: inline-block;width:100%;idpdfID//div!-- 加载未完成时展示进度条组件并计算进度 --div classprogressv-showloadedRatio!1el-progress typecircle:width70color#53a7ff:percentageMath.floor(loadedRatio * 100)/el-progressbr!-- 加载提示语 --span{{ remindShow }}/span/div/div /templatescript import pdf from vue-pdf import {downFileDocCheck, priViewPdfService} from /api/safe/dayAheadCheck; import {priViewPdf} from /utils/ComponentUtils;export default {components: {pdf},computed: {},created() {this.prohibit()},destroyed() {// 在页面销毁时记得清空 setIntervalclearInterval(this.intervalID)},mounted() {priViewPdfService({id: 123}).then((res) {const pdfBlob new Blob([res], {type: application/pdf});this.src URL.createObjectURL(pdfBlob);}).catch(error {console.error(Error fetching the Pdf file:, error);});// 更改 loading 文字this.intervalID setInterval(() {this.remindShow this.remindText.refresh? this.remindShow this.remindText.loading: this.remindShow this.remindText.refresh}, 4000)// 监听滚动条事件this.listenerFunction()},data() {return {// ----- loading -----remindText: {loading: 加载文件中文件较大请耐心等待...,refresh: 若卡住不动可刷新页面重新加载...},remindShow: 加载文件中文件较大请耐心等待...,intervalID: ,// ----- vuepdf -----// src静态路径: /static/xxx.pdf// src服务器路径: http://.../xxx.pdfsrc: ,// 当前页数currentPage: 0,currentPageTWO: 1,// 总页数pageCount: 0,// 加载进度loadedRatio: 0}},methods: {// 监听滚动条事件listenerFunction(e) {document.getElementById(container).addEventListener(scroll, true)},// 页面回到顶部toTop() {document.getElementById(container).scrollTop 0},// 输入页码时校验inputEvent() {if (this.currentPage this.pageCount) {// 1. 大于maxthis.currentPage this.pageCount} else if (this.currentPage 1) {// 2. 小于minthis.currentPage 1}},// 切换页数changePdfPage(val) {if (val pre this.currentPage 1) {// 切换后页面回到顶部this.currentPage--this.toTop()} else if (val next this.currentPage this.pageCount) {this.currentPagethis.toTop()} else if (val first) {this.currentPage 1this.toTop()} else if (val last this.currentPage this.pageCount) {this.currentPage this.pageCountthis.toTop()}},// pdf加载时loadPdfHandler(e) {// 加载的时候先加载第一页this.currentPage 1},// 禁用鼠标右击、F12 来禁止打印和打开调试工具prohibit() {// console.log(document)document.oncontextmenu function () {return false}document.onkeydown function (e) {if (e.ctrlKey (e.keyCode 65 || e.keyCode 67 || e.keyCode 73 || e.keyCode 74 || e.keyCode 80 || e.keyCode 83 || e.keyCode 85 || e.keyCode 86 || e.keyCode 117)) {return false}if (e.keyCode 18 || e.keyCode 123) {return false}}}},} /scriptstyle scoped #container {overflow: auto;height: 100%;width: 100%;font-family: PingFang SC;display: flex;justify-content: center;position: relative;background-color: #E6E6E6; }/* 右侧功能按钮区 */ .right-btn {position: fixed;right: 5%;bottom: 15%;width: 120px;display: flex;flex-wrap: wrap;justify-content: center;z-index: 99; }.pdfArea {padding: 0 30%;width: 100%; }/* ------------------- 输入页码 ------------------- */ .pageNum {margin: 10px 0;font-size: 18px; }/*在谷歌下移除input[number]的上下箭头*/ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {-webkit-appearance: none !important;margin: 0; }/*在firefox下移除input[number]的上下箭头*/ input[typenumber] {-moz-appearance: textfield; }.inputNumber {border-radius: 8px;border: 1px solid #999999;height: 35px;font-size: 18px;width: 60px;text-align: center; }.inputNumber:focus {border: 1px solid #00aeff;background-color: rgba(18, 163, 230, 0.096);outline: none;transition: 0.2s; }/* ------------------- 切换页码 ------------------- */ .turn {background-color: #888888;opacity: 0.7;color: #ffffff;height: 70px;width: 70px;border-radius: 50%;display: flex;align-items: center;justify-content: center;margin: 5px 0; }.turn-btn {background-color: #000000;opacity: 0.6;color: #ffffff;height: 70px;width: 70px;border-radius: 50%;margin: 5px 0;display: flex;align-items: center;justify-content: center; }.turn-btn:hover, .turn:hover {transition: 0.3s;opacity: 0.5;cursor: pointer; }/* ------------------- 进度条 ------------------- */ .progress {position: absolute;right: 50%;top: 50%;text-align: center; }.progress span {color: #199edb;font-size: 14px; } /style二、java使用aspose付费 1.引入库 引入依赖(阿里云仓库无此依赖) dependencygroupIdcom.aspose/groupIdartifactIdaspose-words/artifactIdversion15.12.0/version/dependencyjar包 加我qq获取1092705638记得备注csdn 2.封装的工具类 封装的工具类 package com.hz.jx.utils.MingWeiUtil;import com.aspose.words.Document; import com.aspose.words.License; import com.aspose.words.SaveFormat;import java.io.*;/*** Word 转 Pdf 帮助类** 备注:需要引入 aspose-words-15.8.0-jdk16.jar*/ public class PdfUtil {private static boolean getLicense() {boolean result false;try {InputStream is PdfUtil.class.getClassLoader().getResourceAsStream(license.xml);License aposeLic new License();aposeLic.setLicense(is);result true;} catch (Exception e) {e.printStackTrace();}return result;}/*** 生成pdf文件* param wordPath 需要被转换的word全路径带文件名* param pdfPath 转换之后pdf的全路径带文件名*/public static void doc2pdf(String wordPath, String pdfPath) {// 验证License 若不验证则转化出的pdf文档会有水印产生if (!getLicense()) {return;}try {long old System.currentTimeMillis();//新建一个pdf文档File file new File(pdfPath);FileOutputStream os new FileOutputStream(file);//Address是将要被转化的word文档Document doc new Document(wordPath);//全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换doc.save(os, SaveFormat.PDF);long now System.currentTimeMillis();os.close();//转化用时System.out.println(共耗时 ((now - old) / 1000.0) 秒);} catch (Exception e) {e.printStackTrace();}}/*** 将word文件转成成pdf文件流* param wordPath word文件地址* param outputStream 输出流*/public static void doc2pdfFileStream(String wordPath, OutputStream outputStream) {// 验证License 若不验证则转化出的pdf文档会有水印产生if (!getLicense()) {return;}try {long old System.currentTimeMillis();//Address是将要被转化的word文档Document doc new Document(wordPath);//全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换doc.save(outputStream, SaveFormat.PDF);long now System.currentTimeMillis();outputStream.close();//转化用时System.out.println(共耗时 ((now - old) / 1000.0) 秒);} catch (Exception e) {e.printStackTrace();}} }3、付费密钥文件 resouce目录下创建文件license.xml LicenseDataProductsProductAspose.Total for Java/ProductProductAspose.Words for Java/Product/ProductsEditionTypeEnterprise/EditionTypeSubscriptionExpiry20991231/SubscriptionExpiryLicenseExpiry20991231/LicenseExpirySerialNumber8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7/SerialNumber/Data !-- word转pdf付费密钥--SignaturesNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppod0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU/Signature /License 总结 后端获取word文件转成pdf文件流前端接收文件流使用vue-pdf分页展示。 小编也是试了很多这个最好用。
http://www.hkea.cn/news/14263237/

相关文章:

  • 网站伪静态免费炫酷网站模板
  • 专业合肥网站建设广州市住房和城乡建设局官方网站
  • 天津城乡住房建设厅网站首页绵阳 网站
  • 网站会员注册怎么做上海市场监督管理局
  • 公司建立网站的意义做网站需要多少钱知乎
  • 网站建设 部署与发布视频教程广州网站设计权威乐云践新
  • 小网站建设公司排名销量不高的网站怎么做
  • 做网站最省钱零食铺网站建设策划书
  • 做网站是前端还是后端物流公司创建
  • 网站建设和托管哪家好wordpress主题模板文件
  • 上海高端网站开发站霸网络专业网站的建设设行吗
  • 网站描述标签优化网站建设 工作计划
  • 学网站开发需要会什么建设部房地产网站
  • 苏州建网站必去苏州聚尚网络创业做网站APP开发
  • 外贸工厂 网站建设wordpress本地登录密码
  • 网站设计比例揭阳网站建设工作
  • 民制作网站价格深圳投资推广署
  • 官方网站建设案例网页设计工具有哪些
  • 网站建设论坛首页驻马店北京网站建设
  • 泰兴做网站的公司重新建网站需要转域名吗
  • 一个优秀的个人网站微网站生成app
  • 除了速卖通还有什么网站做外贸wordpress获取手机号
  • 在线医疗网站建设cdr做网站流程
  • 国外网站推广如何做免费连网络的软件有哪些
  • 怎么在网站上做游戏代练wordpress主动提交
  • 网站功能建设规划书传奇手游新开服网站
  • 怎样在工商局网站做公示广州必去十大景点排名
  • 做系统前的浏览网站能找回吗希音跨境平台入驻条件
  • 网站 图文混编网站设计 psd
  • 江苏营销型网站建设网站建设有何好处