You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mike O'Leary <tm...@comcast.net> on 2007/03/22 19:08:01 UTC
Extracting formatted text from PDF files
Please forgive the laziness inherent in this question, as I haven't looked
through the PDFBox code yet. I am wondering if that code supports extracting
text from PDF files while preserving such things as sequences of whitespace
between characters and other layout and formatting information. I am working
with a project that extracts and operates on certain table-like blocks of
text from PDF files, and a lot of freeware and shareware PDF to text
converters seem to either ignore formatting or try to preserve formatting
and not get it quite right. I am wondering if PDFBox provides better support
for this kind of thing. Thanks.
Mike O'Leary
Re: Extracting formatted text from PDF files
Posted by Soeren Pekrul <so...@gmx.de>.
Mike O'Leary wrote:
> Please forgive the laziness inherent in this question, as I haven't looked
> through the PDFBox code yet. I am wondering if that code supports extracting
> text from PDF files while preserving such things as sequences of whitespace
> between characters and other layout and formatting information. I am working
> with a project that extracts and operates on certain table-like blocks of
> text from PDF files, and a lot of freeware and shareware PDF to text
> converters seem to either ignore formatting or try to preserve formatting
> and not get it quite right. I am wondering if PDFBox provides better support
> for this kind of thing. Thanks.
That is not so simple. Usually there is not this information inside a
PDF file. PDF is an output file format. It contains just the information
print a character "a" at the position x and y. In many cases a PDF file
doesn’t know even words or white spaces. We read words due to the
position of characters, we see paragraphs due to the position of
characters, and we see tables due to the position of characters. The
file doesn’t contain this information.
I found this code in a PDF file for the German word "Wuchsform" (form of
growing) and the colon ":":
/F1 1 Tf
-3.8801 -1.274 TD
[ (W) 29.60001 (uchsform:) ] TJ
First line: Select a font
Second line: Move the cursor to position -3.8801, -1.274
Third line: Print the character "W", move the cursor 29.60001 units to
right and print the characters "uchsform:".
Extracting the words from a PDF file for indexing means you have first
to build words from the characters positions. Recognizing paragraphs,
column text, tables, captions, lists, footnotes etc. is much more difficult.
Sören
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Extracting formatted text from PDF files
Posted by Daniel Noll <da...@nuix.com>.
Mike O'Leary wrote:
> Please forgive the laziness inherent in this question, as I haven't looked
> through the PDFBox code yet. I am wondering if that code supports extracting
> text from PDF files while preserving such things as sequences of whitespace
> between characters and other layout and formatting information. I am working
> with a project that extracts and operates on certain table-like blocks of
> text from PDF files, and a lot of freeware and shareware PDF to text
> converters seem to either ignore formatting or try to preserve formatting
> and not get it quite right.
Even pdftohtml? The sample outputs I've seen from that application
don't look too bad to me.
Daniel
--
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia Ph: +61 2 9280 0699
Web: http://nuix.com/ Fax: +61 2 9212 6902
This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org