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

求一个手机能看的网站网页制作图片显示不出来

求一个手机能看的网站,网页制作图片显示不出来,蓝色旅游网站模板,wordpress娱乐网概述 本篇博客以简单的示例代码分别在Windows和Linux环境下完成Word转PDF的文档转换。 文章提供SpringBoot Vue3的示例代码。 文章为什么要分为Windows和Linux环境#xff1f; 因为在如下提供的Windows后端示例代码中使用documents4j库做转换#xff0c;此库需要调用命令行…概述 本篇博客以简单的示例代码分别在Windows和Linux环境下完成Word转PDF的文档转换。 文章提供SpringBoot Vue3的示例代码。 文章为什么要分为Windows和Linux环境 因为在如下提供的Windows后端示例代码中使用documents4j库做转换此库需要调用命令行工具并且需要安装Microsoft Word但在Linux上无法安装Microsoft Word因此如下提供了两份后端代码。 过程 前端传入word文件 - 后端处理 - 返回转换后的字节数组byte[] Windows后端代码 maven依赖 dependencygroupIdcom.documents4j/groupIdartifactIddocuments4j-local/artifactIdversion1.0.3/version /dependencydependencygroupIdcom.documents4j/groupIdartifactIddocuments4j-transformer-msoffice-word/artifactIdversion1.0.3/version /dependency 示例代码 // controller接口 PostMapping(/upload)public byte[] convertDocxToPdf(RequestParam(file) MultipartFile file) throws IOException {if (!file.getOriginalFilename().endsWith(.docx)) {throw new IllegalArgumentException(文件类型不支持);}try (InputStream docxInputStream file.getInputStream();ByteArrayOutputStream outputStream new ByteArrayOutputStream()) {IConverter converter LocalConverter.builder().build();converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();return outputStream.toByteArray();}} CentOS后端代码 maven依赖 dependencygroupIdorg.jodconverter/groupIdartifactIdjodconverter-local/artifactIdversion4.4.2/version /dependency 示例代码 PostMapping(value /upload, consumes MediaType.MULTIPART_FORM_DATA_VALUE)public byte[] uploadFile(RequestParam(file) MultipartFile file) throws IOException, OfficeException {if (file.getOriginalFilename().endsWith(.docx)) {LocalOfficeManager officeManager LocalOfficeManager.install();try {officeManager.start();DocumentConverter converter LocalConverter.builder().officeManager(officeManager).build();ByteArrayOutputStream out new ByteArrayOutputStream();converter.convert(file.getInputStream()).as(DefaultDocumentFormatRegistry.DOCX).to(out).as(DefaultDocumentFormatRegistry.PDF).execute();return out.toByteArray();} finally {OfficeUtils.stopQuietly(officeManager);}} else {throw new IOException(文件类型不支持);}} *** 当使用上方的代码进行word转pdf之后输出的很大可能会出现中文文字不能正确显示文字全部变成小矩形框。 这是因为在linux上没有中文字体库导致的。 在centos7中安装中文字体库  1.首先检查安装所需要的工具 yum -y install fontconfig yum -y install ttmkfdir 2.之后检查/usr/share目录是否有fonts 和 fontconfig 3.创建chinese目录用于存放我们需要的字体 在/usr/share/fonts下创建chinese 4.下载需要的字体 我们到自己的windows电脑上查找想要的字体访问C:\Windows\Fonts 可以搜索自己文档转换过程中需要的字体例如宋体 将字体拷贝放到centos的/usr/share/fonts/chinese目录中并修改chinese目录的权限 chmod -R 755 /usr/share/fonts/chinese 5.执行命令生成 TrueType 字体的字体度量 ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir 6.配置刚才创建中文字体目录使之生效即可。 vi /etc/fonts/fonts.conf  7.执行命令刷新字体缓存 fc-cache  至此重新访问后端服务进行word转pdf会发现字体成功显示。 前端测试代码 在此提供与后端代码配套测试的前端代码vue3  templatedivdiv idmy_iptlabel foript classupload-button上传文件Word 或 PDF/labelinput idipt typefile changeuploadFile accept.pdf,.docx /divhriframe v-iffileSrc :srcfileSrc width100% height600px/iframe/div /templatescript setup import { ref } from vue; import axios from axios; const fileSrc ref(null);const uploadFile async (event) {const file event.target.files[0];if (file) {if (file.type application/pdf) {fileSrc.value URL.createObjectURL(file);} else if (file.type application/vnd.openxmlformats-officedocument.wordprocessingml.document) {const formData new FormData();formData.append(file, file);const response await axios.post(/doc/upload, formData, {responseType: blob,headers: {Content-Type: multipart/form-data}});fileSrc.value URL.createObjectURL(new Blob([response.data], { type: application/pdf }));} } }; /scriptstyle scoped .upload-button {background-color: #4CAF50;border: none;color: white;padding: 10px 20px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;cursor: pointer;border-radius: 5px; }.upload-button:hover {background-color: #3e8e41; }/style
http://www.hkea.cn/news/14437255/

相关文章:

  • 四川专业网站建设推广纳税服务平台
  • vue做的项目网站python语言基础知识
  • 西宁网站设计建设专业建站网站服务
  • 小团队兼职做网站上海最大的企业
  • 网站需要更新的频率wordpress自助
  • 做下载类网站一年赚多少钱做视频网站违法么
  • 关于网站建设的申请书app开发与网站开发有何不同
  • 射阳做网站的公司有什么网站做生鲜配送的
  • 菠菜网站如何做推广网站销售公司
  • 公司微网站怎么建设在线画图网页版
  • 外贸网站域名服务商三合一网站制作公司
  • 重庆做网站电话五八同城找工作
  • 最专业的房地产网站建设idc 公司网站模板
  • 加强住房公积金网站建设网站开发怎么谈
  • 中国平安官方网站心态建设课件网站 筛选功能
  • 做网站需要注册吗企业微信scrm
  • 怎么用自己的网站做网页河北省企业网站建设公司
  • 微琅 网站建设怎么给网站做绿标
  • 容桂佛山做app网站新型塑料建筑模板图片
  • 能源公司网站模板提交网站到谷歌
  • 企业建站系统开源公司内部网站创建
  • 网站被黑应该怎么做wordpress 模板 破解版
  • 长沙做网站湖南微联讯点不错建设网站东莞
  • 好的品牌设计网站有哪些湖南长沙seo
  • 在家做网站维护兼职公众号登录微信公众号登录
  • 淘客宝网站备案号如何弄个性化定制软件
  • 做3d办公家具教程的网站问答网站如何优化
  • 济宁市城市建设局网站网络营销工具优缺点
  • 做本地网站能赚钱么十大装饰公司排名
  • 桂林建设银行招聘网站网站新闻页面无法翻页