[b]开源包下载地址: [url]http://bfo.com/products/download.jsp[/url][/b]
例子:
例子:
import java.io.File;
import java.io.IOException;
import org.faceless.pdf2.PDF;
import org.faceless.pdf2.PDFParser;
import org.faceless.pdf2.PDFReader;
import org.faceless.pdf2.PageExtractor;
public class Test {
public static void main(String[] args) throws IOException {
// PDF文档路径
String filepath = "rayln的博客文章 (1).pdf";
// PDFReader对象建立
PDFReader reader = new PDFReader(new File(filepath));
// 建立PDF文档对象
PDF pdf = new PDF(reader);
// 建立文档解析对象
PDFParser parser = new PDFParser(pdf);
for (int i = 0; i < pdf.getNumberOfPages(); i++) {
PageExtractor extractor = parser.getPageExtractor(i);
System.out.println("=========start================");
System.out.println(extractor.getTextInDisplayOrder().toArray()[1]);
//System.out.println(extractor.getTextAsStringBuffer());
System.out.println("=========end================");
}
}
}