import java.io.fileinputstream;import org.apache.pdfbox.cos.cosdocument;import org.apache.pdfbox.pdfparser.pdfparser;import org.apache.pdfbox.pdmodel.pddocument;import Org.apache.pdfbox.util.pdftextstripper;public class read { public string readfdf (string file) { String docText = "; try { fileinputstream fis = new fileinputstream (file); cosdocument Cosdoc = null; pdfparser parser = new pdfparser (FIS); parser.parse (); cosdoc = parser.getdocument (); Pdftextstripper stripper = new pdftextstripper (); doctext = Stripper.gettext (New pddocument (Cosdoc)); system.out.println (docText); } catch (exception e) { sYstem.out.println ("bb=" + e.getmessage ()); } return doctext; } Public static void main (string args[]) { read read = new read ();   STRING S = READ.READFDF ("G:\\apdf\\test.pdf"); System.out.println (s); }}
Only one jar package is required to Pdfbox-app-1.8.7.jar
Jar Package http://pdfbox.apache.org/
Reference Blog: http://wangbaoaiboy.blog.163.com/blog/static/521119102010111613126524/
There's even a bag in the Pdfbox-app-1.8.7.jar, and there's no need to reintroduce it.
This article is from the "format USB disk NTFS format" blog, so be sure to keep this source http://3482583.blog.51cto.com/3472583/1582565
Java uses PDFBox to manipulate PDF files