易截截图软件、单文件、免安装、纯绿色、仅160KB

Java抽取Word,PDF的四种武器

在这里总结一下抽取word,pdf的几种方法。
很多人用java进行文档操作时经常会遇到一个问题,就是如何获得word,excel,pdf等文档的内容?我研究了一下,在这里总结一下抽取word,pdf的几种方法。
1. 用jacob
其实jacob是一个bridage,连接java和com或者win32函数的一个中间件,jacob并不能直接抽取word,excel等文件,需要自己写dll哦,不过已经有为你写好的了,就是jacob的作者一并提供了。
jacob jar与dll文件下载: http://danadler.com/jacob/
下载了jacob并放到指定的路径之后(dll放到path,jar文件放到classpath),就可以写你自己的抽取程序了,下面是一个简单的例子:
import java.io.File;
import com.jacob.com.*;
import com.jacob.activeX.*;
/**
 * Title: pdf extraction
 * Description: email:chris@matrix.org.cn
 * Copyright: Matrix Copyright (c) 2003
 * Company: Matrix.org.cn
 * @author chris
 * @version 1.0,who use this example pls remain the declare
 */
public class FileExtracter{
 public static void main(String[] args) {
  ActiveXComponent component = new ActiveXComponent("Word.Application");
  String inFile = "c:\\test.doc";
  String tpFile = "c:\\temp.htm";
  String otFile = "c:\\temp.xml";
  boolean flag = false;
  try {
   component.setProperty("Visible", new Variant(false));
   Object wordacc = component.getProperty("document.").toDispatch();
   Object wordfile = Dispatch.invoke(wordacc,"Open", Dispatch.Method,
                                     new Object[]{inFile,new Variant(false), new Variant(true)},
                                     new int[1] )


相关文档:

MyEclipse注册JAVA程序代码!

package cn.vicky.reg;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class MyEclipseReg {
// ///////////////////////////////////////////////////////////
// 运行该文件 输入用户名 点击回车即可生成 MyEclipse 6.0 和 7.0 通用户注册码
// ///// ......

java socket编程

前一段时间刚做了个java程序和网络上多台机器的c程序通讯的项目,遵循的是TCP/IP协议,用到了java的Socket编程。网络通讯是java的强项,用TCP/IP协议可以方便的和网络上的其他程序互通消息。
先来介绍下网络协议:
    TCP/IP
        Transmission Control Proto ......

JAVA程序反编译工具

JAVA程序反编译工具
下载地址:http://java.decompiler.free.fr/?q=jdgui
JD-GUI
JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.
JD-GUI is fre ......

java中遍历一个Map

Map map = new HashMap();
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object val = entry.getValue();
}
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号