Extract text from PDF (google app engine)

2019-02-15 15:11发布

Is there any free Java library for extracting text from PDF, that is compatible with Google Application Engine?

I've read about PDFJet, but it can't read PDF, can it?

Is there perhaps other way how to extract text from PDF? I tried http://www.pdfdownload.org/, unfortunately they don't handle non-English characters correctly.

5条回答
Rolldiameter
2楼-- · 2019-02-15 15:31

I modified the latest (1.8.0-Snapshot) version to run on Google AppEngine. Had to disable one Unit-Test, but it runs fine for simple text extraction.

Following the simple try-fail-fix approach i had to modify 5 files in total. Pretty doable.

You'll also have to explicitly use a RandomAccessBuffer, like Fabrizio explained.

For the extra lazy, heres the compiled jar, dependencies for text extraction, and the patch. Note that it might not work for every usecase (i.e. rectangle based extraction). Used it to extract text of a whole page. https://docs.google.com/folder/d/0B53n_gP2oU6iVjhOOVBNZHk0a0E/edit

查看更多
神经病院院长
3楼-- · 2019-02-15 15:32

I know there is http://pdfbox.apache.org/index.html

Apache PDFBox is an open source Java PDF library for working with PDF documents. This project allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

but I've never tested it.

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-02-15 15:41

PdfBox does not run on GAE. It uses not-allowed java classes.
(GAE only permits these http://code.google.com/appengine/docs/java/jrewhitelist.html)

I have partially modified a very old version of PdfBox (0.7.3) to be GAE complaiant. Now I'm able to extract text from PDF (whole page or rectangular area). I only modified a minumum part of the pdf text extraction and not the whole PdfBox. :)
The idea was to remove refences to java.awt.retangle & C. using my own "rectangle" class.

More info: http://fhtino.blogspot.com/2010/04/pdfbox-text-extration-gae.html

查看更多
我想做一个坏孩纸
5楼-- · 2019-02-15 15:42

iText now has a text parsing module (I'm one of the parser authors). See the com.itextpdf.text.pdf.parser.PdfContentReaderTool class for an example of how to use it.

查看更多
走好不送
6楼-- · 2019-02-15 15:44

Last month, I'd just finished extracting text from pdf file in my project. I used XPDF tool for getting text, and text coordinates, but I used it in Xcode (Objective-C). This tool was open source, written by C++, and able to be encoded in many language. However, I didn't know whether XPdf would be work on your java, or not. Anyway, You can try this tool.

查看更多
登录 后发表回答