将java工程导成jar包 使用 bat 执行 jar 包。

---------------------------------------------------------------------------------------------------------------

eclipse 工程

  1. Pdf2Word.java 解析pdf主类。
  2. laq_.txt             操作说明。
  3. license.xml       aspose license。
  4. aspose.pdf-11.5.0.jar 转word所需jar包 可在 aspose 官网 https://docs.aspose.com/display/pdfnet/Printing+PDF+Document 下载

---------------------------------------------------------------------------------------------------------------

附源码

Pdf2Word.java

package com.bxj;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;

import com.aspose.pdf.Document;
import com.aspose.pdf.License;
import com.aspose.pdf.SaveFormat;

public class Pdf2Word {

public static boolean getLicense() {
boolean result = false;
try
{
InputStream license = ClassLoader.getSystemResourceAsStream("license.xml");
License aposeLic = new License();
aposeLic.setLicense(license);
result = true;
}
catch (Exception e)
{
System.out.println("license not found!");
}
return result;
}

public static void main(String[] args) {
try
{
if (!getLicense()) {
return;
}
String pdfFile = args[0];
pdfFile = pdfFile.replace("\\", "/");
AnalyzePdf pdf=new AnalyzePdf(pdfFile);
AnalyzeTxt txt=new AnalyzeTxt();
Thread t1=new Thread(pdf);
Thread t2=new Thread(txt);
t1.start();
t2.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

class AnalyzePdf implements Runnable{

String fileDir;

public AnalyzePdf(String fileDir){
this.fileDir = fileDir;
}

@Override
public void run()
{
recursion(fileDir);
}

private static void recursion(String fileDir)
{
File file = new File(fileDir);
File[] files = file.listFiles();// 获取目录下的所有文件或文件夹
if (files == null)
{
return;
}
for (File f : files)
{
if (f.isFile() && f.getName().endsWith(".pdf"))
{
pdf2word(f);
}
else if (f.isDirectory())
{
//递归
recursion(f.getAbsolutePath());
}
}
}

private static void pdf2word(File pdfFile)
{
try {
InputStream fileInput = new FileInputStream(pdfFile);// 待处理的文件
Document pdfDocument = new Document(fileInput);
String fileName = pdfFile.getAbsolutePath().replace("pdf", "doc");
File file = new File(fileName);
if (!file.exists())
{
file.createNewFile();
}
OutputStream fileOutput = new FileOutputStream(fileName);
pdfDocument.save(fileOutput, SaveFormat.DocX);
} catch (Exception e) {
e.printStackTrace();
}
}

public String getFileDir()
{
return fileDir;
}

public void setFileDir(String fileDir)
{
this.fileDir = fileDir;
}
}

class AnalyzeTxt implements Runnable{

@Override
public void run()
{
try
{
InputStream inputStream = ClassLoader.getSystemResourceAsStream("laq_.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
int c;
while((c=reader.read()) != -1){
if(c!= 32){
Thread.sleep(1);
}
System.out.print((char)c);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

laq_.txt 

  • 将需转换的pdf文件置于 out 目录
  • 输出文件在 out 目录查看

license.xml

<License>
<Data>
<Products>
<Product>Aspose.Total for Java</Product>
<Product>Aspose.Pdf for Java</Product>
</Products>
<EditionType>Enterprise</EditionType>
<SubscriptionExpiry>20991231</SubscriptionExpiry>
<LicenseExpiry>20991231</LicenseExpiry>
<SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>
</Data>
<Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>
</License>

MANIFEST.MF

Manifest-Version: 1.0
Class-Path: lib/aspose.pdf-11.5.0.jar
Main-Class: com.bxj.Pdf2Word

---------------------------------------------------------------------------------------------------------------

导为 jar 包

导出目录

lib 存放 aspose.pdf-11.5.0.jar 

out 存放 转换的pdf文件 (转换完成的word文件也在这个路径)

 运行.bat 批处理文件

@echo off
set current_path=%cd%\out
java -jar -Xms4000m -Xmx4000m -Xmn2000m Pdf2Word_LAQ.jar %current_path%
@pause

欢迎关注  有疑问可交流  

java pdf转word 高效不失真的更多相关文章

  1. java PDF转word的初步实现

    package com.springboot.springboot.util; import java.io.File; import java.io.FileOutputStream; import ...

  2. java实现word转pdf文件(高效不失真)

    import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import org.aspectj ...

  3. Java解析OFFICE(word,excel,powerpoint)以及PDF的实现方案及开发中的点滴分享

    Java解析OFFICE(word,excel,powerpoint)以及PDF的实现方案及开发中的点滴分享 在此,先分享下写此文前的经历与感受,我所有的感觉浓缩到一个字,那就是:"坑&qu ...

  4. Java 将PDF 转为Word、图片、SVG、XPS、Html、PDF/A

    本文将介绍通过Java编程来实现PDF文档转换的方法.包括: 1. PDF转为Word 2. PDF转为图片 3. PDF转为Html 4. PDF转为SVG 4.1 将PDF每一页转为单个的SVG ...

  5. 15个最好的PDF转word的在线转换器,将PDF文件转换成doc文件

    PDF是一种文件格式,包含文本,图像,数据等,这是独立于操作系统的文件类型.它是一个开放的标准,压缩,另一方面DOC文件和矢量图形是由微软文字处理文件.该文件格式将纯文本格式转换为格式化文档.它支持几 ...

  6. iText导出pdf、word、图片

    一.前言 在企业的信息系统中,报表处理一直占比较重要的作用,本文将介绍一种生成PDF报表的Java组件--iText.通过在服务器端使用Jsp或JavaBean生成PDF报表,客户端采用超级连接显示或 ...

  7. java 如何将 word,excel,ppt如何转pdf--jacob

    问题:java 如果将 word,excel,ppt如何转pdf 我个人的观点:windows server下用 jacob; linux server下 用openoffice.   PS:1.本文 ...

  8. CAJ Viewer安装流程以及CAJ或Pdf转换为Word格式

        不多说,直接上干货! pdf转word格式,最简单的就是,实用工具 Adobe Acrobat DC 首先声明的是,将CAJ或者Pdf转换成Word文档,包括里面的文字.图片以及格式,根本不需 ...

  9. asp.net导出excel-一行代码实现excel、xml、pdf、word、html、csv等7种格式文件导出功能而且美观-SNF快速开发平台

    分享: 腾讯微博  新浪微博   搜狐微博   网易微博  腾讯朋友  百度贴吧  豆瓣   QQ好友  人人网 作者:王春天  原文地址:http://www.cnblogs.com/spring_ ...

随机推荐

  1. 操作 实例 / dom

    响应式:数据改变时会触发其他联动.例如:模板中的数据绑定:计算属性的重新计算: ---------------------------------------------------- vm.$par ...

  2. azkaban使用--邮件发送配置

    前置条件:你的服务器是可以连外网. 当任务是异步定时的,我们对于结果的感知往往没有手动跑脚本那么及时,但是如果任何一个任务运行失败可能都会引起一些列问题,在这个情况下消息通知就很重要了,azkaban ...

  3. 沙箱机制(Sandboxie)

    一.沙箱是什么? 沙箱是一个虚拟系统程序,沙箱提供的环境相对于每一个运行的程序都是独立的,而且不会对现有的系统产生影响. 二.沙箱的应用 (1)搭建测试环境.沙箱的应用只能访问自己的应用访问目录,而不 ...

  4. 【Debug】逻辑分析仪数据错乱,看波形为信号耦合导致数据错乱,实际上为逻辑分析仪地线没接上!

    如图都有数据的时间段,数据错乱,实际为逻辑分析仪地线未接,接上就不会了.

  5. GDI+_从Bitmap里得到的Color数组值解决方案

    ' InkHin_ZhiZhuo ' Date :2019.2.18 ' E-mail lqx@tyningling.Top 'This function and Module is written ...

  6. 程序配置的原则和实践以及 Spring Boot 支持方式

    原则 软件需要在不同的环境中部署,代码是保持不变的,但是不同的运行环境存在差异,所以需要使用配置适应不同的环境.比如: 数据库,Redis,以及其他 后端服务 的配置: 第三方服务的证书,如 oAut ...

  7. js解决下拉列表框互斥选项的问题

    如图不区分选项与其他选项是互斥的关系,当选择了不区分时,其他选项就要去除,当有其他选项存在时,就不能有不区分 解决办法:定义change事件,若列表发生改变,首先判断点击的是否是不区分,若是,则将其他 ...

  8. Java相关查询记录

    Version of Spring Facet could not be detected. http://yijiesuifeng.iteye.com/blog/2221444

  9. springboot+dubbo+mybatis多模块项目invalid boundexception

    invalid boundexception的原因大抵是因为mybatis扫描不到mapper映射文件(xml),无法将mapper接口类(java)中的接口与mapper映射器绑定起来.这可能是因为 ...

  10. 15. 3Sum (JAVA)

    Given an array nums of n integers, are there elements a, b, cin nums such that a + b + c = 0? Find a ...