I have looked in to doing text extraction / data extraction from PDFs and used some other stack overflow answers for help, what I have set up is Tika parsing a pdf through a custom ContentHandlerDecorator which is using sax events to parse the content. I am having an issue though where the pdf when viewed in a PDF viewer contains a table of data that is arranged in rows and columns, but that information seems to just not begin pulled from the pdf, or im not seeing how to find it using tika / sax.
This is an example of what I'm seeing:
A table like the above gives me this (when i just to string the Sax events)
START http://www.w3.org/1999/xhtml, div, , div, class = page;
START http://www.w3.org/1999/xhtml, p, , p,
END http://www.w3.org/1999/xhtml, p, , p
WHITESPACE[
], 0, 1
START http://www.w3.org/1999/xhtml, p, , p,
CHARS [I, n, f], 0, 3
WHITESPACE[
], 0, 1
CHARS [o], 0, 1
WHITESPACE[
], 0, 1
END http://www.w3.org/1999/xhtml, p, , p
START http://www.w3.org/1999/xhtml, p, , p,
CHARS [I, n, f, o], 0, 4
CHARS [ ], 0, 1
CHARS [H, 1], 0, 2
CHARS [ ], 0, 1
CHARS [H, 2], 0, 2
CHARS [ ], 0, 1
CHARS [H, 3], 0, 2
CHARS [ ], 0, 1
CHARS [H, 4], 0, 2
WHITESPACE[
], 0, 1
END http://www.w3.org/1999/xhtml, p, , p
// Start of Second Row
START http://www.w3.org/1999/xhtml, p, , p,
CHARS [1], 0, 1
CHARS [I, n, f, 1], 0, 4
WHITESPACE[
], 0, 1
CHARS [I, n, f, 2], 0, 4
WHITESPACE[
], 0, 1
END http://www.w3.org/1999/xhtml, p, , p
START http://www.w3.org/1999/xhtml, p, , p,
CHARS [I, n, f, 3], 0, 4
WHITESPACE[
], 0, 1
END http://www.w3.org/1999/xhtml, p, , p
START http://www.w3.org/1999/xhtml, p, , p,
CHARS [D, 1], 0, 2
CHARS [ ], 0, 1
CHARS [D, 4], 0, 2
END http://www.w3.org/1999/xhtml, p, , p
Due to the seemingly random ending of paragraphs, no indication of when a new row is started, and in the case of the second row, there's somehow no gaps in the data for the empty columns despite it being displayed like that in the viewer.
I'm sorry I can't provide the pdf, but i am after any information on where this extra formatting / layout data is stored or can be extracted, because there is clearly missing info in what I am getting from Tika. There aten't any attributes in any of the paragraphs.
If it helps, I know the PDF was generated using iText as I can see that in the metadata, but when trialling iText it didn't seem like it offered a way to programmatically open and parse a pdf without providing it some sort of pre made extraction template, which i don't want to do.
