Live data from Hacker News

Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

github.com

91–95 of 95 posts

Re: Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

#91
post #88

Earlier quoted context omitted.

Have you seen the spec for .doc and .xls ?

I don't even want to know :)

Oh, you really do! The format for COM object based documents like XLS and DOC is actually a FAT filesystem: https://en.wikipedia.org/wiki/Compound_File_Binary_Format

Re: Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

#92
In case it helps someone, for a data mining project at the research lab i work, i tried more than 10 different commercial and opensource libraries. The best one was commercial version of Foxit SDK, it always kept the layout perfectly.

Function you need to use: FPDFText.FPDFText_PDFToText()

Re: Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

#93
post #7

Curious if this works better than the pdftotext utility that comes in the Debian poppler-utils package. That has a --layout option that works really well sometimes and really terrible other times. Doesn't seem to be related to document complexity either.

I had used the xpdf [1] package, a C library and a set of CLI tools (mentioned by others in this thread too, and which the pdftotext command-line utility and xppdf/pdftotext library are a part of), in a consulting project for a client some years ago. (Client had asked me to evaluate some libraries for PDF text extraction, and then recommend one, which I did (I chose xpdf), and I then consulted to them on their product, using xtpdf for part of the work. Also did some post-processing of the extracted text in Python. Interesting project, overall.)

As part of this work, I communicated over a period, with one of the key technical people at the company behind xpdf, Glyph and Cog. Got to know from him about some of the issues with text extraction from PDF, one of the key points being that in some or many cases, the extraction can be imperfect or incomplete, due to factors inherent in the PDF format itself, and its differences from text format. PDFTextStream (for Java) is another one which I had heard of, from someone I know personally, who said it was quite good. But those inherent issues of text extraction do exist.

So wherever possible, a good option is to go to the source from which the PDF was originally generated, instead of trying to reverse-engineer it, and get the text you want from there. Not always possible, of course, but a preferred approach, particularly for cases where maximum accuracy of text extraction is desired.

[1] Not to be confused with xtopdf, my PDF toolkit for PDF generation from other formats.

Re: Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

#94
post #52
post #24

Is there a PDF to HTML converter which can consistently get line breaks right?

could be a nice feature but not easy task. I'll give a try, though.

Please update us/me when you do. I'm also working on the same problem, would love to chat.

Re: Show HN: PDFLayoutTextStripper – Converts PDF to text while keeping the layout

#95
post #85

Earlier quoted context omitted.

I don't see how epub can be pixel-perfect. It's almost as much a markup format, as fb2. Clearly more explanation of how should it be done is in order.

Pixel perfection is not necessary for 99.999% of the cases PDF is used in.

That's just ridiculous statement.
Post reply on HN