- 浏览: 21607 次
文章分类
最新评论
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class FileConverterService {
private static final Logger logger = Logger.getLogger(FileConverterService.class);
private static final Set<String> OFFICE_TYPE = new HashSet<String>();
private static final String VISIO_TYPE = "vsd";
private static String webPath = "";
private static String webFileName = "";
static{
OFFICE_TYPE.add("doc");
OFFICE_TYPE.add("docx");
OFFICE_TYPE.add("xls");
OFFICE_TYPE.add("xlsx");
OFFICE_TYPE.add("ppt");
OFFICE_TYPE.add("pptx");
OFFICE_TYPE.add("txt");
}
public static boolean canReadOnLine(String filePath){
boolean flag = false;
int index = filePath.lastIndexOf(".");
String extName = filePath.substring(index + 1);
flag = isPdfFile(extName) || isOfficeFile(extName) || isVisioFile(extName);
return flag;
}
public static boolean convertFile2Swf(String fileFullName){
boolean flag = false;
if(null != fileFullName){
String tmpFileName = null;
int index = fileFullName.lastIndexOf(".");
String fileName = fileFullName.substring(0,index);
String extName = fileFullName.substring(index + 1);
if(isOfficeFile(extName)){
tmpFileName = fileName + ".pdf";
boolean opFlag = convertOffice2Pdf(fileFullName, tmpFileName, fileFullName.substring(index + 1, fileFullName.length()));
if(opFlag){
try{
flag = convertPdf2Swf(tmpFileName, fileName+".swf");
}catch(Exception e){
logger.error("将Office文档的PDF文档转换成SWF文件失败!", e);
}
}
}else if(isPdfFile(extName)){
flag = convertPdf2Swf(fileFullName, fileName+".swf");
}else if(isVisioFile(extName)){
tmpFileName = fileName + ".pdf";
boolean opFlag = convertVisio2Pdf(fileFullName);
if(opFlag){
try{
flag = convertPdf2Swf(tmpFileName, fileName+".swf");
}catch(Exception e){
logger.error("将VISIO创建的PDF文档转换成SWF文件失败!", e);
}
}
}
}
return flag;
}
/**
* 将Office文档转换成PDF文档(新)。
* @param inFileName
* @param outFileName
*/
private static boolean convertOffice2Pdf(String inFileName, String outFileName,String extName){
boolean flag = false;
if("doc".equals(extName.toLowerCase()) || "docx".equals(extName.toLowerCase())){
flag = FileWordToPdf.wordToPDF(inFileName, outFileName, 17);
}
else{
return convertOffice2Pdf(inFileName,outFileName);
}
return flag;
}
/**
* 将Office文档转换成PDF文档。
* @param inFileName
* @param outFileName
*/
private static boolean convertOffice2Pdf(String inFileName, String outFileName){
boolean flag = false;
OpenOfficeConnection connection = null;
try{
File inFile = new File(inFileName);
File outFile = new File(outFileName);
connection = new SocketOpenOfficeConnection(8100);
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inFile, outFile);
flag = true;
}catch(Exception e){
logger.error("将Office文档转换为PDF文档失败!", e);
}finally{
if(null != connection){
connection.disconnect();
}
}
return flag;
}
/**
* 将VISIO文档转换成PDF文档。
* 分为两步:
* 1、将VSD各页转换成emf图片文件
* 2、将所有的emf转换成PDF
* @param inFileName
* @param outFileName
*/
private static boolean convertVisio2Pdf(String inFileName){
boolean flag = false;
try{
ComThread.InitSTA();
java.util.ArrayList<String> tmpFileName = null;
int index = inFileName.lastIndexOf(".");
String tmpDescPath = inFileName.substring(0,index);
ActiveXComponent vsd = null;
StringBuffer command = null;
vsd = new ActiveXComponent("Visio.Application");
vsd.setProperty("Visible", new Variant(false));
Dispatch docs = vsd.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.call(docs, "Open", inFileName).toDispatch();
Dispatch pages = Dispatch.get(doc, "Pages").toDispatch();
if(null != pages){
tmpFileName = new java.util.ArrayList<String>();
command = new StringBuffer("im_convert ");
int count = Integer.parseInt(Dispatch.get(pages, "Count").toString());
for(int i = 1; i <= count; i++){
Dispatch page = Dispatch.call(pages, "item", new Object[]{ new Integer(i)}).toDispatch();
String name = Dispatch.get(page, "Name").toString();
String emfName = tmpDescPath + "_" + name + ".emf";
tmpFileName.add(emfName);
Dispatch.call(page, "Export", new Object[]{emfName });
command.append(emfName + " ");
}
}
Dispatch.put(doc, "Saved", new Variant(true));
vsd.invoke("Quit", new Variant[]{});
command.append(tmpDescPath+".pdf");
Process pro = Runtime.getRuntime().exec(command.toString());
StreamGobbler errGob = new StreamGobbler(pro.getErrorStream(),"ERROR");
StreamGobbler outGob = new StreamGobbler(pro.getInputStream(),"OUTINFO");
errGob.start();
outGob.start();
if(0 == pro.waitFor()){
flag = true;
}
// 删除临时的图片文件
File file = null;
if(null != tmpFileName){
for(String name: tmpFileName){
file = new File(name);
if(null != file && file.exists()){
file.delete();
}
}
}
}catch(Exception e){
logger.error("将VISIO文档转换为PDF文档失败!", e);
}finally{
ComThread.Release();
}
return flag;
}
/**
* 将PDF转换为SWF文档。
* @param inFileName
* @param outFileName
*/
private static boolean convertPdf2Swf(String inFileName, String outFileName){
boolean flag = false;
try{
if(hasFileDir(outFileName)){
StringBuffer command =
new StringBuffer("pdf2swf -G -f -T 9 -t -s storeallcharacters ").append(inFileName).append(" -o ").append(webPath + webFileName);
// 执行命令是在单独的线程中完成。不等完成就直接返回。
Process pro = Runtime.getRuntime().exec(command.toString());
StreamGobbler errGob = new StreamGobbler(pro.getErrorStream(),"ERROR");
StreamGobbler outGob = new StreamGobbler(pro.getInputStream(),"OUTINFO");
errGob.start();
outGob.start();
if(0 == pro.waitFor()){
flag = true;
// if(hasFileDir(outFileName)){
// System.out.println("-------webPath:"+webPath + webFileName);
// String str = "copy "+ outFileName + " "+webPath + webFileName;
// System.out.println("-------str:"+str);
// //forChannel(outFileName,webPath + webFileName);
// pro = Runtime.getRuntime().exec(str);
// }
}
}
}catch(Exception e){
logger.error("将PDF文档转换为SWF文档失败或者拷贝文件失败!", e);
}
return flag;
}
/**
* 根据文件判断是否为Office文档,doc、docx、xls、xlsx、ppt、pptx
* @param fileName
* @return
*/
private static boolean isOfficeFile(String extName){
if(null != extName){
if(OFFICE_TYPE.contains(extName.toLowerCase())){
return true;
}
}
return false;
}
/**
* 根据文件扩展名判断是否为PDF文件。
* @param fileName
* @return
*/
private static boolean isPdfFile(String extName){
if("pdf".equalsIgnoreCase(extName)){
return true;
}
return false;
}
/**
* 根据文件扩展名判断是否为VISIO文件。
* @param fileName
* @return
*/
private static boolean isVisioFile(String extName){
if(VISIO_TYPE.equalsIgnoreCase(extName)){
return true;
}
return false;
}
public static boolean hasFileDir(String fileFullName){
boolean flag = false;
if(fileFullName == null || "".equals(fileFullName)){
return flag;
}
int totalen = fileFullName.length();
int len = fileFullName.lastIndexOf("\\");
String cfile = fileFullName.substring(0,len);
webFileName = fileFullName.substring(len+1);
int tlen = cfile.lastIndexOf("\\");
String filedirName = fileFullName.substring(tlen+1, len);
// String urls = ClassLoader.getSystemResource("\\").getPath();
// int wlen = urls.indexOf("WEB-INF");
// String absolutePath = urls.substring(1,wlen);
String userdir = System.getProperty("user.dir");
String tomPath = userdir.replace("bin", "");
String absolutePath = tomPath+"webapps\\smis\\tempdocument\\attachment\\";
//String absolutePath = "D:\\work\\smis\\WebRoot\\tempdocument\\attachment\\";
webPath = absolutePath + filedirName + "\\";
// System.out.println("-----------:"+webPath);
File file = new File(webPath);
if(file.exists()){
flag = true;
}
else{
file.mkdirs();
flag = true;
}
return flag;
}
public static boolean forChannel(String s1,String s2) throws Exception{
boolean flag = false;
int length=2097152;
File f1 = new File(s1);
File f2 = new File(s2);
FileInputStream in=new FileInputStream(f1);
FileOutputStream out=new FileOutputStream(f2);
FileChannel inC=in.getChannel();
FileChannel outC=out.getChannel();
ByteBuffer b=null;
while(true){
if(inC.position()==inC.size()){
inC.close();
outC.close();
flag = true;
}
b=ByteBuffer.allocateDirect(length);
b.flip();
outC.write(b);
outC.force(false);
outC.close();
}
}
}
写个线程类StreamGobbler
/**
* aaron_ye
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
/**
* @author aaron_ye
*
*/
public class StreamGobbler extends Thread {
private InputStream is = null;
private OutputStream os = null;
private String type = null;
public StreamGobbler(InputStream _is, String _type, OutputStream _os){
this.is = _is;
this.os = _os;
this.type = _type;
}
public StreamGobbler(InputStream _is, String _type){
this.is = _is;
this.type = _type;
}
public void run() {
try{
// System.out.println("begin: "+this.type);
PrintWriter pw = null;
if (os != null){
pw = new PrintWriter(os);
}else{
pw = new PrintWriter(System.out);
}
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null){
if (pw != null){
pw.println(line);
}
}
if (pw != null){
pw.flush();
}
// System.out.println("end: "+this.type);
} catch (IOException ioe){
ioe.printStackTrace();
}
}
/**
* @return the is
*/
public InputStream getIs() {
return is;
}
/**
* @param is
* the is to set
*/
public void setIs(InputStream is) {
this.is = is;
}
/**
* @return the os
*/
public OutputStream getOs() {
return os;
}
/**
* @param os
* the os to set
*/
public void setOs(OutputStream os) {
this.os = os;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(String type) {
this.type = type;
}
}
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class FileConverterService {
private static final Logger logger = Logger.getLogger(FileConverterService.class);
private static final Set<String> OFFICE_TYPE = new HashSet<String>();
private static final String VISIO_TYPE = "vsd";
private static String webPath = "";
private static String webFileName = "";
static{
OFFICE_TYPE.add("doc");
OFFICE_TYPE.add("docx");
OFFICE_TYPE.add("xls");
OFFICE_TYPE.add("xlsx");
OFFICE_TYPE.add("ppt");
OFFICE_TYPE.add("pptx");
OFFICE_TYPE.add("txt");
}
public static boolean canReadOnLine(String filePath){
boolean flag = false;
int index = filePath.lastIndexOf(".");
String extName = filePath.substring(index + 1);
flag = isPdfFile(extName) || isOfficeFile(extName) || isVisioFile(extName);
return flag;
}
public static boolean convertFile2Swf(String fileFullName){
boolean flag = false;
if(null != fileFullName){
String tmpFileName = null;
int index = fileFullName.lastIndexOf(".");
String fileName = fileFullName.substring(0,index);
String extName = fileFullName.substring(index + 1);
if(isOfficeFile(extName)){
tmpFileName = fileName + ".pdf";
boolean opFlag = convertOffice2Pdf(fileFullName, tmpFileName, fileFullName.substring(index + 1, fileFullName.length()));
if(opFlag){
try{
flag = convertPdf2Swf(tmpFileName, fileName+".swf");
}catch(Exception e){
logger.error("将Office文档的PDF文档转换成SWF文件失败!", e);
}
}
}else if(isPdfFile(extName)){
flag = convertPdf2Swf(fileFullName, fileName+".swf");
}else if(isVisioFile(extName)){
tmpFileName = fileName + ".pdf";
boolean opFlag = convertVisio2Pdf(fileFullName);
if(opFlag){
try{
flag = convertPdf2Swf(tmpFileName, fileName+".swf");
}catch(Exception e){
logger.error("将VISIO创建的PDF文档转换成SWF文件失败!", e);
}
}
}
}
return flag;
}
/**
* 将Office文档转换成PDF文档(新)。
* @param inFileName
* @param outFileName
*/
private static boolean convertOffice2Pdf(String inFileName, String outFileName,String extName){
boolean flag = false;
if("doc".equals(extName.toLowerCase()) || "docx".equals(extName.toLowerCase())){
flag = FileWordToPdf.wordToPDF(inFileName, outFileName, 17);
}
else{
return convertOffice2Pdf(inFileName,outFileName);
}
return flag;
}
/**
* 将Office文档转换成PDF文档。
* @param inFileName
* @param outFileName
*/
private static boolean convertOffice2Pdf(String inFileName, String outFileName){
boolean flag = false;
OpenOfficeConnection connection = null;
try{
File inFile = new File(inFileName);
File outFile = new File(outFileName);
connection = new SocketOpenOfficeConnection(8100);
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inFile, outFile);
flag = true;
}catch(Exception e){
logger.error("将Office文档转换为PDF文档失败!", e);
}finally{
if(null != connection){
connection.disconnect();
}
}
return flag;
}
/**
* 将VISIO文档转换成PDF文档。
* 分为两步:
* 1、将VSD各页转换成emf图片文件
* 2、将所有的emf转换成PDF
* @param inFileName
* @param outFileName
*/
private static boolean convertVisio2Pdf(String inFileName){
boolean flag = false;
try{
ComThread.InitSTA();
java.util.ArrayList<String> tmpFileName = null;
int index = inFileName.lastIndexOf(".");
String tmpDescPath = inFileName.substring(0,index);
ActiveXComponent vsd = null;
StringBuffer command = null;
vsd = new ActiveXComponent("Visio.Application");
vsd.setProperty("Visible", new Variant(false));
Dispatch docs = vsd.getProperty("Documents").toDispatch();
Dispatch doc = Dispatch.call(docs, "Open", inFileName).toDispatch();
Dispatch pages = Dispatch.get(doc, "Pages").toDispatch();
if(null != pages){
tmpFileName = new java.util.ArrayList<String>();
command = new StringBuffer("im_convert ");
int count = Integer.parseInt(Dispatch.get(pages, "Count").toString());
for(int i = 1; i <= count; i++){
Dispatch page = Dispatch.call(pages, "item", new Object[]{ new Integer(i)}).toDispatch();
String name = Dispatch.get(page, "Name").toString();
String emfName = tmpDescPath + "_" + name + ".emf";
tmpFileName.add(emfName);
Dispatch.call(page, "Export", new Object[]{emfName });
command.append(emfName + " ");
}
}
Dispatch.put(doc, "Saved", new Variant(true));
vsd.invoke("Quit", new Variant[]{});
command.append(tmpDescPath+".pdf");
Process pro = Runtime.getRuntime().exec(command.toString());
StreamGobbler errGob = new StreamGobbler(pro.getErrorStream(),"ERROR");
StreamGobbler outGob = new StreamGobbler(pro.getInputStream(),"OUTINFO");
errGob.start();
outGob.start();
if(0 == pro.waitFor()){
flag = true;
}
// 删除临时的图片文件
File file = null;
if(null != tmpFileName){
for(String name: tmpFileName){
file = new File(name);
if(null != file && file.exists()){
file.delete();
}
}
}
}catch(Exception e){
logger.error("将VISIO文档转换为PDF文档失败!", e);
}finally{
ComThread.Release();
}
return flag;
}
/**
* 将PDF转换为SWF文档。
* @param inFileName
* @param outFileName
*/
private static boolean convertPdf2Swf(String inFileName, String outFileName){
boolean flag = false;
try{
if(hasFileDir(outFileName)){
StringBuffer command =
new StringBuffer("pdf2swf -G -f -T 9 -t -s storeallcharacters ").append(inFileName).append(" -o ").append(webPath + webFileName);
// 执行命令是在单独的线程中完成。不等完成就直接返回。
Process pro = Runtime.getRuntime().exec(command.toString());
StreamGobbler errGob = new StreamGobbler(pro.getErrorStream(),"ERROR");
StreamGobbler outGob = new StreamGobbler(pro.getInputStream(),"OUTINFO");
errGob.start();
outGob.start();
if(0 == pro.waitFor()){
flag = true;
// if(hasFileDir(outFileName)){
// System.out.println("-------webPath:"+webPath + webFileName);
// String str = "copy "+ outFileName + " "+webPath + webFileName;
// System.out.println("-------str:"+str);
// //forChannel(outFileName,webPath + webFileName);
// pro = Runtime.getRuntime().exec(str);
// }
}
}
}catch(Exception e){
logger.error("将PDF文档转换为SWF文档失败或者拷贝文件失败!", e);
}
return flag;
}
/**
* 根据文件判断是否为Office文档,doc、docx、xls、xlsx、ppt、pptx
* @param fileName
* @return
*/
private static boolean isOfficeFile(String extName){
if(null != extName){
if(OFFICE_TYPE.contains(extName.toLowerCase())){
return true;
}
}
return false;
}
/**
* 根据文件扩展名判断是否为PDF文件。
* @param fileName
* @return
*/
private static boolean isPdfFile(String extName){
if("pdf".equalsIgnoreCase(extName)){
return true;
}
return false;
}
/**
* 根据文件扩展名判断是否为VISIO文件。
* @param fileName
* @return
*/
private static boolean isVisioFile(String extName){
if(VISIO_TYPE.equalsIgnoreCase(extName)){
return true;
}
return false;
}
public static boolean hasFileDir(String fileFullName){
boolean flag = false;
if(fileFullName == null || "".equals(fileFullName)){
return flag;
}
int totalen = fileFullName.length();
int len = fileFullName.lastIndexOf("\\");
String cfile = fileFullName.substring(0,len);
webFileName = fileFullName.substring(len+1);
int tlen = cfile.lastIndexOf("\\");
String filedirName = fileFullName.substring(tlen+1, len);
// String urls = ClassLoader.getSystemResource("\\").getPath();
// int wlen = urls.indexOf("WEB-INF");
// String absolutePath = urls.substring(1,wlen);
String userdir = System.getProperty("user.dir");
String tomPath = userdir.replace("bin", "");
String absolutePath = tomPath+"webapps\\smis\\tempdocument\\attachment\\";
//String absolutePath = "D:\\work\\smis\\WebRoot\\tempdocument\\attachment\\";
webPath = absolutePath + filedirName + "\\";
// System.out.println("-----------:"+webPath);
File file = new File(webPath);
if(file.exists()){
flag = true;
}
else{
file.mkdirs();
flag = true;
}
return flag;
}
public static boolean forChannel(String s1,String s2) throws Exception{
boolean flag = false;
int length=2097152;
File f1 = new File(s1);
File f2 = new File(s2);
FileInputStream in=new FileInputStream(f1);
FileOutputStream out=new FileOutputStream(f2);
FileChannel inC=in.getChannel();
FileChannel outC=out.getChannel();
ByteBuffer b=null;
while(true){
if(inC.position()==inC.size()){
inC.close();
outC.close();
flag = true;
}
b=ByteBuffer.allocateDirect(length);
b.flip();
outC.write(b);
outC.force(false);
outC.close();
}
}
}
写个线程类StreamGobbler
/**
* aaron_ye
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
/**
* @author aaron_ye
*
*/
public class StreamGobbler extends Thread {
private InputStream is = null;
private OutputStream os = null;
private String type = null;
public StreamGobbler(InputStream _is, String _type, OutputStream _os){
this.is = _is;
this.os = _os;
this.type = _type;
}
public StreamGobbler(InputStream _is, String _type){
this.is = _is;
this.type = _type;
}
public void run() {
try{
// System.out.println("begin: "+this.type);
PrintWriter pw = null;
if (os != null){
pw = new PrintWriter(os);
}else{
pw = new PrintWriter(System.out);
}
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null){
if (pw != null){
pw.println(line);
}
}
if (pw != null){
pw.flush();
}
// System.out.println("end: "+this.type);
} catch (IOException ioe){
ioe.printStackTrace();
}
}
/**
* @return the is
*/
public InputStream getIs() {
return is;
}
/**
* @param is
* the is to set
*/
public void setIs(InputStream is) {
this.is = is;
}
/**
* @return the os
*/
public OutputStream getOs() {
return os;
}
/**
* @param os
* the os to set
*/
public void setOs(OutputStream os) {
this.os = os;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(String type) {
this.type = type;
}
}
相关推荐
word 转PDF的几种方式 1、NPOI读取Word,只支持后缀名为.docx的,用iTextSharp生成pdf文件,存在读取word的段落,表格及先后顺序,导致生成的也不一致。 2、通过读取字节判断。 3、通过Aspose.Words来操作,在项目...
在这个场景中,我们看到一个关于如何使用Java编程语言实现此功能的资源包:“利用poi+itextpdf进行word转pdf.rar”。这个压缩包包含源码、依赖库以及转换效果的示例,表明它提供了一种无需额外插件的解决方案。下面...
"java+pdf转word+word转pdf 无水印 无页数限制"这一标题揭示了我们讨论的是一个能够进行这两种转换,并且在转换过程中不添加水印,且不受页面数量限制的解决方案。以下是对这个主题的详细知识点解释: 1. **PDF转...
本文提供了一种详细的方法,确保在Word转PDF的过程中保留导航页或书签。 Word转PDF带有导航页或书签的教程主要分为两个部分:WPS版本和Office版本。无论你使用哪种版本的软件,关键在于确保Word文档中的大纲级别已...
"Word转PDF"这个主题涉及到了文件兼容性、格式保留以及跨平台查看的问题。下面将详细讲解如何在不同的操作系统环境下,将Word文档转换为PDF格式。 1. **Word与PDF的差异** - **Word**:Microsoft Word是一款文字...
标题提到的是"word转pdf所需的jar包",这通常指的是Java库,这些库可以集成到Java项目中,帮助开发者处理文件格式的转换。下面将详细讲解如何使用Java进行Word到PDF的转换以及涉及到的关键知识点。 首先,要实现这...
这个压缩包“word转PDF然后实现在线预览的功能.rar”提供了一个技术解决方案,下面我们将深入探讨其中涉及的关键知识点。 1. **Word转PDF**: - **转换工具**:通常,我们可以使用各种库或服务来实现这个转换,...
在“LibreOffice——word转pdf.zip”这个压缩包中,重点是利用LibreOffice的Writer组件将Word文档转换为PDF格式。 首先,我们来详细了解一下为什么需要将Word转换为PDF。Word文档通常用于编辑和协作,但其格式在...
在Java编程环境中,我们可以利用各种库来实现在Linux系统中将Word文档转换为PDF。...以上就是Java在Linux环境中实现Word转PDF所需的关键知识点。通过理解这些概念和工具,你可以编写出自己的转换程序,满足特定需求。
2. **iText库用于Word转PDF**: iText是一个开源的Java库,专门用于处理PDF文档。在这里,它被用来将Word文档转换为PDF。iText提供了丰富的API,可以读取Word文档(通常是.doc或.docx格式),并将其内容复制到新的...
"word转pdf pdf虚拟打印机"这一主题就是围绕如何利用PDF虚拟打印机技术将Word文档转换为PDF格式来展开的。 首先,我们要理解什么是PDF虚拟打印机。PDF虚拟打印机其实是一种软件应用,它模拟了打印机的功能,但打印...
"word转pdf需要的jar包依赖"指的是在Java项目中,我们需要引入特定的jar包来支持Word到PDF的转换。这里提到的`aspose-words-15.8.0-jdk16.jar`就是这样一个库,它是Aspose.Words for Java的一个版本,专门用于处理...
标题提到的".net WORD转PDF"是指使用.NET技术将Word文档转换为PDF文档的过程。这个过程在实际开发中具有广泛的用途,例如报告生成、合同制作、电子书籍发布等场景,因为PDF格式通常能更好地保留原始文档的格式和布局...
"Word转PDF"是一个典型的例子,它涉及到Microsoft Office套件中的Word文档与Adobe PDF格式之间的互换。下面将详细介绍如何通过第三方控件实现这一转换,并探讨相关的技术细节。 首先,Word文档(.doc或.docx)是一...
总结起来,实现Java中的Word转PDF涉及到多个库的协同工作。Apache POI提供对Word文档的读取,Docx4j负责转换为PDF,而iText或PDFBox则用于格式优化。这种转换方法虽然涉及的组件较多,但能确保转换的准确性和灵活性...
标题提到的“word 转pdf 可以跨平台同时也实现中文显示”揭示了一个重要的知识点,即如何将Microsoft Word文档转换为PDF格式,同时确保在任何平台上都能正确显示中文内容。下面将详细探讨这个过程以及相关的技术背景...
使用Libreoffice 完美实现在线word转pdf.支持word和linux两个系统
"Word转PDF工具"就是专为此目的设计的应用程序,它允许用户方便快捷地将Microsoft Word文档(.doc或.docx)转换成PDF文件。这种转换在很多场景下都是必要的,例如为了保持文档格式的一致性、防止编辑或者方便在线...
这个压缩包“word转pdf.zip”包含了实现此功能所需的jar文件和转换方法。通常,这些库如Apache POI(用于处理Word文件)和iText(用于生成PDF)会提供API,帮助开发者进行文档格式间的转换。 Apache POI是Java中...
下面我们将详细讲解如何进行“word转pdf并加水印”的过程。 1. **Word转PDF**: - **Microsoft Word内转换**:新版的Microsoft Office(如Office 2013及以后版本)提供了直接保存为PDF的功能。只需打开Word文档,...