-
pdfbox-app-1.8.13.jar下载
资源介绍
JAVA读取PDF所需要用到的jar包;
package com.lewei.test;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.util.PDFTextStripper;
public class PDFTest{
// TODO 自动生成方法存根
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream("E://900540.3_K.pdf");
BufferedWriter writer = new BufferedWriter(new FileWriter("E://change.txt"));
PDFParser p = new PDFParser(fis);
p.parse();
PDFTextStripper ts = new PDFTextStripper();
String ss = ts.getText(p.getPDDocument());
writer.write(ss);
fis.close();
writer.close();
System.out.println("开始读取");
FileReader fr = new FileReader("E://change.txt");//需要读取的文件路径
BufferedReader br= new BufferedReader(fr);
String s = br.readLine();
while(s!=null)//如果当前行不为空
{
if(s.length()>10){
if(s.substring(0,3).contains("G01")){
System.out.println(s);//打印当前行
String s1=s.substring(0,s.indexOf(" "));
System.out.println("Type="+s1);
}
}
s= br.readLine();//读取下一行
}
br.close();//关闭BufferReader流
fr.close();
}
}
- 上一篇: pdfbox1.8.3相关jar包
- 下一篇: pdfbox-1.8.3.jar