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

找个兼职做网站的贵阳软件开发公司排名

找个兼职做网站的,贵阳软件开发公司排名,线上销售的方法和技巧,山东东营市有几个区县一、多余的话 java实现word转pdf可用的jar包不多#xff0c;很多都是收费的。最近发现com.documents4j挺好用的#xff0c;它支持在本机转换#xff0c;也支持远程服务转换。但它依赖于微软的office。电脑需要安装office才能转换。鉴于没在linux中使用office#xff0c;本…一、多余的话 java实现word转pdf可用的jar包不多很多都是收费的。最近发现com.documents4j挺好用的它支持在本机转换也支持远程服务转换。但它依赖于微软的office。电脑需要安装office才能转换。鉴于没在linux中使用office本文转换在windows中进行。 用途主要是对word文件转换成pdf后提供在线预览服务。也可以用于合同生成等。 二、前提条件 windows服务器或电脑需安装office软件。 三、代码实现 添加依赖 dependencygroupIdcom.documents4j/groupIdartifactIddocuments4j-local/artifactIdversion1.1.6/version/dependencydependencygroupIdcom.documents4j/groupIdartifactIddocuments4j-transformer-msoffice-word/artifactIdversion1.1.6/version/dependency 转换代码类WordToPdfUtil.java package com.lan.fts.util;import com.documents4j.api.*; import com.documents4j.job.LocalConverter;import java.io.*; import java.util.concurrent.Future;public class WordToPdfUtil {private IConverter getConverter(){return LocalConverter.builder().build();}private void releaseConverter(IConverter converter){converter.shutDown();}public boolean wordToPdf(String fromFilePath, String pdfFilePath){boolean result false;File inputFile new File(fromFilePath);File outputFile new File(pdfFilePath);InputStream inputStreamnull;OutputStream outputStream null;IConverter converter getConverter();try {inputStream new FileInputStream(inputFile);outputStream new FileOutputStream(outputFile);String wordFilePath_lowfromFilePath.toLowerCase();if (wordFilePath_low.endsWith(.docx)) {FutureBoolean schedule converter.convert(inputStream, true).as(DocumentType.DOCX).to(outputStream, true).as(DocumentType.PDF).schedule();result waitsShedule(schedule, 180000);}else if(wordFilePath_low.endsWith(.doc)){FutureBoolean schedule converter.convert(inputStream, true).as(DocumentType.DOC).to(outputStream, true).as(DocumentType.PDF).schedule();result waitsShedule(schedule, 180000);}else if(wordFilePath_low.endsWith(.txt)){FutureBoolean schedule converter.convert(inputStream, true).as(DocumentType.TEXT).to(outputStream, true).as(DocumentType.PDF).schedule();result waitsShedule(schedule, 180000);}} catch (FileNotFoundException e) {e.printStackTrace();} finally {try {if(outputStream!null)outputStream.close();} catch (IOException e) {};try {if(inputStream!null)inputStream.close();} catch (IOException e) {};releaseConverter(converter);}return result;}private boolean waitsShedule(FutureBoolean schedule, int timeout){int time0;while (!schedule.isDone()){MyThread.sleep(500);time500;if(timetimeout){schedule.cancel(true);return false;}}return true;}public static void main(String[] args) {// new WordToPdfUtil().wordToPdf(D:\\data\\out\\ffec88b6ee26397bf99834acb059f7b0.docx, D:\\data\\out\\ffec88b6ee26397bf99834acb059f7b0.docx.pdf);}} 说明waitsShedule是等待转换完成。如果超时将取消转换任务 四、运行验证 public static void main(String[] args) {new WordToPdfUtil().wordToPdf(D:\\data\\out\\lanhezhong文件转换.docx, D:\\data\\out\\lanhezhong文件转换.docx.pdf);} 运行结果 *********************************************************************************************** author蓝何忠 emaillanhezhong163.com ***********************************************************************************************
http://www.hkea.cn/news/14463835/

相关文章:

  • wordpress 全站静态化2015年做那个网站能致富
  • 固镇网站建设哪家好?无形资产 网站开发
  • 有没有做语文题的网站协会宣传网站开发方案
  • 在税局网站上如何做进项税转出wordpress插件必备
  • 海尔公司网站建设现状wordpress仿qq空间
  • 阿里云个人备案可以做企业网站吗外贸企业网站源码
  • 网站建设与规划实训总结钟表商城网站建设方案
  • 江苏州 网站制作企业网站定制收费标准
  • dw企业网站开发教程云南网站建设优化
  • 网站开发人员知乎网站建设分工
  • 上海公司网站建设wordpress的文章在哪里
  • 手机触屏版网站找项目创业网
  • 海南省城乡建设部网站首页北京建设商业网站
  • 山西省煤矿建设协会网站温州网站制作公司
  • 个人可以注册网站吗郑州网站设计收费低
  • wordpress百度站长主动推送盐城企业网站建设
  • 网站行销站网站推广
  • 企业网站模板大全wordpress前端修改
  • 南昌网站seo费用天津seo推广服务
  • 互联科技 行业网站做网站买什么服务器 便宜
  • 一级a视网站 做爰片云点wordpress
  • 建设网站需要营业执照吗临沂做网站选盛誉
  • 关于网站建设申请报告营销软文写作
  • 济南房地产网站建设学校网页设计html代码
  • 移动端h5网站开发服务app快速生成平台
  • 影视传媒网站源码精准营销的作用
  • 做网站链接的页面怎么做北京通信管理局网站备案处
  • 如何发布一个自己的网站万网 网站
  • 网站建设知识产权问题上海网站建设一般多少钱
  • 大连网站排名优化价格怎样才能把网站宣传做的更好