易截截图软件、单文件、免安装、纯绿色、仅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] )


相关文档:

java 日期格式化

1 SimpleDateFormat担当重任,怎样格式化都行
import java.util.Date;
import java.text.SimpleDateFormat;
public class Demo
{
public static void main(String[] args)
{
Date now=new Date();
SimpleDateFormat f=newSimpleDateFormat("今天是"+"yyyy年MM月dd日 E kk点mm分");
System.out.println(f.fo ......

从C++到JAVA,C++程序员学习JAVA的指南

write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie
讨论新闻组及文件
Technorati 标签: JAVA
,C++
,Python
JAVA is not just another programming language. -- 匿名
学习更新的语言,有助于了解别人对旧语言有哪些不满。 -- 匿名
 
前言

说明本文的行文习惯,文章写作流程以本人阅读《Java Progra ......

关于java的集合类,以及HashMap中Set的用法!

package com.tiantian;
import java.util.*;
public class JAVAContainer {
     public static void main(String[] args) throws Exception {
         //     ArrayList
         {
&nb ......

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号