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

网站管理端怎么做seo排名优化收费

网站管理端怎么做,seo排名优化收费,武汉专业网站排名推广,做网站可以用什么语言一、多余的话 java实现word转pdf可用的jar包不多,很多都是收费的。最近发现com.documents4j挺好用的,它支持在本机转换,也支持远程服务转换。但它依赖于微软的office。电脑需要安装office才能转换。鉴于没在linux中使用office,本…

一、多余的话

java实现word转pdf可用的jar包不多,很多都是收费的。最近发现com.documents4j挺好用的,它支持在本机转换,也支持远程服务转换。但它依赖于微软的office。电脑需要安装office才能转换。鉴于没在linux中使用office,本文转换在windows中进行。

用途:主要是对word文件转换成pdf后,提供在线预览服务。也可以用于合同生成等。

二、前提条件

windows服务器或电脑需安装office软件。

三、代码实现

添加依赖:

        <dependency><groupId>com.documents4j</groupId><artifactId>documents4j-local</artifactId><version>1.1.6</version></dependency><dependency><groupId>com.documents4j</groupId><artifactId>documents4j-transformer-msoffice-word</artifactId><version>1.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 inputStream=null;OutputStream outputStream = null;IConverter converter = getConverter();try {inputStream = new FileInputStream(inputFile);outputStream = new FileOutputStream(outputFile);String wordFilePath_low=fromFilePath.toLowerCase();if (wordFilePath_low.endsWith(".docx")) {Future<Boolean> 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")){Future<Boolean> 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")){Future<Boolean> 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(Future<Boolean> schedule, int timeout){int time=0;while (!schedule.isDone()){MyThread.sleep(500);time+=500;if(time>timeout){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:蓝何忠
email:lanhezhong@163.com
***********************************************************************************************

http://www.shuangfujiaoyu.com/news/28620.html

相关文章:

  • 北京网站建设排名西安百度推广电话
  • 上传文件到网站网站平台有哪些
  • 一起作做业网站班级优化大师使用心得
  • 襄樊和襄阳是一个地方吗成都关键词优化平台
  • 小程序代注册seo1搬到哪里去了
  • 株洲网站建设seo策略分析
  • ext做的网站新闻20字摘抄大全
  • 深圳网站建设设自动优化句子的软件
  • 怎么把网站改为正在建设中安卓优化大师清理
  • 建材网站开发每日新闻播报
  • 网站建设公司介绍ppt网络营销总监岗位职责
  • 企业网厅四川seo整站优化
  • 网站开发研究手段有哪些门户网站
  • 最大网站建设公司排名小红书如何引流推广
  • 2018年网站建设培训会发言国外网站推广公司
  • 前端网站建设和维护seo发外链工具
  • 有哪些做网站的网站网站域名在哪买
  • 中国制造网注册网站免费注册厦门seo排名收费
  • 芒果国际影城星沙店桔子seo网
  • 网站项目方案公司网站设计模板
  • 公司建网站多少钱成人用品推广网页
  • 网站的项目建设周期长尾关键词排名系统
  • 外贸汽车网站制作网站优化排名软件
  • 服务器可以做网站如何写软文赚钱
  • 怎样用编程语言做网站百度推广app怎么收费
  • 做网站页面的软件刷僵尸粉网站推广
  • 网站的访问量网站seo优化免费
  • 政府网站建设工作会议上的讲话南昌seo排名公司
  • 杭州号码百事通做网站网络加速器
  • cms网站管理北京网站推广排名外包