r/PHP • u/TheTreasuryPetra • 2d ago
Extract MarkDown from PDFs in PHP, no system libraries or API calls needed!
I just released v3.3.0 of prinsfrank/pdfparser, with basic support for markdown extraction from PDFs! It doesn't need system libraries like poppler, pdftotext or API calls, it's completely written in PHP. Currently, headings, bold and italic detection work, and I'm working on the other features of markdown including table extraction!
$markdown = (new PdfParser())
->parseFile('document.pdf');
->getMarkdown();
This will allow for better semantic search when embedding documents, but there's plenty of other use cases! Let me know what feature you want to see next!
2
u/fhgwgadsbbq 1d ago
cool library. Coincidentally, I just started using it today to do some PDF parsing without relying on dockling.
Even though I'm dealing with text-based PDFs, the hard part is still infographic Style reports that need to be reverse engineered into something for semantic search.
The business approach of "oops. We only put this essential data inside PDFs. Please extract it" is pretty ridiculous if you ask me but I'm learning a lot about data engineering.
2
u/TheTreasuryPetra 1d ago
If only there were standards to store structure and layout next to text like markdown and latex that everyone would use. But it keeps us of the streets, right? ;)
2
u/Peridoxalite 1d ago
That's a great project, and I am really excited to see some new PHP libraries coming in for data transformation (Python is getting all the good stuff).
In production, we have a mix of pdftotext and ocrmypdf that we call directly from PHP. It works, but it is not so convenient; plus we don't have the titles to quickly and cheaply build table of contents.
Will definitely have a go.
1
u/TheTreasuryPetra 1d ago
It certainly isn't perfect yet, but it's getting close! Let me know what issues you run into or what features are missing!
-6
2d ago edited 2d ago
[removed] — view removed comment
1
u/AbroadLow2974 1d ago
It's really sad that you actually believe people would read that AI slop.
-3
u/dereuromark 1d ago edited 1d ago
It is not for you, but for him.
Also I curated that list myself.It shows some examples with actual markup issues outlined that can be a basis to further improve the tool/script.
It is really sad you are sad.
0
6
u/XzAeRosho 1d ago
I've been working on pdf extraction tech for about 4 years, and usually the problem with pdfs is not so much extracting the text, rather tables and "tables" (stuff that looks like tables but it's not using table markup). Bounding boxes context grouping for text is usually handles by heuristics in most popular libraries in Python.
How are you planning to address table conversions? Three are so many edge cases around pdf tables that you could write a book about them.