cgraham
Hi!
What is currently the best library/method for parsing text and tabular data out of PDF files in Elixir or Erlang?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
asianfilm
I don’t think there is one. But would love to be proved wrong. There are a couple of PDF parsers written in Elm, one with an interesting UI. You’d think that Elixir would be a more natural choice given its pattern matching. I have thought of converting one to Elixir, but it would likely only handle text and not tables.
kip
I had a very similar idea. Until I started reading the PDF specification …
(Even after buying two technical books on it)
kokolegorille
There is one in Python…
slouchpie
About 1 year ago, I attempted a “side-project” for a guy who I met at a laptop repair place. It was a site with some simple functionality but he wanted PDF parsing. I gave up after about 4 weekends.
I tried using the python
pdfreaderlibrary but found it extremely brittle. I actually am reading the email chain from Aug 2023 about it and I explained to the guy that unpredictable spacing and layouts made a catch-all solution almost impossible (for me, at least, I’m sure some AI wizards born and raised in soundproof bunkers deep under Silicon Valley could do it).Anyway, so I tried another approach which actually works very well, but only if the PDF format does not change. I wrote something that worked for all the test data presented but the next batch of data was wildly different (different table headings, different number of columns, different data types, random annotations and notes in strange places).
This 2nd approach used a Java jar called
tabula. I got it from here https://github.com/tabulapdf/tabula-java/releases/download/v1.0.5/tabula-1.0.5-jar-with-dependencies.jar but check around, maybe there are later releases. It worked super well (until the inputs started changing like crazy).Anyway, if you want my honest opinion - do it yourself if you have strong control over the input pdfs and if there is a tolerance for mistakes. Otherwise, use an established pdf parsing service.
With all that said, here is some Elixir code I wrote (hastily) about a year ago to parse a specific pdf. I am just copying and pasting it wholesale so please don’t judge it too harshly. Maybe you can scavenge it for parts.
Good luck.
bdarla
I also went for a Java based solution, i.e. tika-server.
Then, I use e.g. HTTPoison to send the PDF content to
http://localhost:9998/tikaand I parse the result using Floki, e.g. metadata or content.It is an easy solution that works, though I cannot argue that it is the optimal solution.
tme_317
I currently use ‘pdftotext’ currently distributed in poppler to extract the text out of PDFs called by ‘System.cmd’.
After that it’s easy to parse the text file with standard Elixir code. Previously I used Ghostscript to extract text but I find pdftotext’s -layout option provides more consistent formatting of the text output making it easier to parse.
carlgleisner
Excellent question
I’ve looked into this and found three main ways:
pdf2txt.py1. Python libraries
There is
pdfreaderas mentioned by @kokolegorille. Another one ispdf2txt.pyfrom thepdfminer.sixpackage, which I use myself for some simpler use cases.One thing that limited me with this was that a recurring element in my documents (a vector and text stamp) didn’t show up with the correct line ordering in the extracted plaintext. That could be manageable for one kind of element – but quickly gets utterly unmanageable. So: it depends.
2. “Document AI” models
This is a really cool blog post on Huggingface setting out how one can use machine learning utilising not only textual information, but also positional information and scanned documents.
There is a neat table describing the licenses of the models. What’s really appealing to me is the possibility to run inference on your own.
But last time I checked I think that the cost of getting started seemed too high for me. Also, I don’t think that it’s as easy as Bumblebee 1-2-3 quite yet. Which brings me to what I went for
3. Third-party service
Since we’re a Microsoft shop I looked into Azure Document Intelligence and… yeah, it’s really nice actually.
For our use-case it’s been great. To start with, we’re a Microsoft shop as I mentioned. But primarily, it was easy to get started with the web interface giving you point and click labelling for subsequent training. Finally, we don’t have to scale massively. I guess inference could get prohibitively expensive if you do.
The coolest option? Gosh no. I wish I was the European version of Sean Moriarty, but I’m certainly not. Azure Document Intelligence allowed me to become terribly productive and cost has thus far been way below what would be acceptable.
Best of luck with your endeavor!
PS. If even @kip balks at the idea of writing a PDF parser, then I’ll be running the other way immediately.
slouchpie
Yes!
Also yes to the 3rd-party service.
akoutmos
For tabular data I have had really good luck using Tabula (GitHub - tabulapdf/tabula-java: Extract tables from PDF files · GitHub). Usage is pretty simple too and you’ll get the contents of tables in the PDF back as a CSV on STDOUT:
The only downside is I needed to add Java to my docker image…but such is life.
xavriley
For image based PDFs, GitHub - datalab-to/surya: OCR, layout analysis, reading order, table recognition in 90+ languages · GitHub is excellent. It’s recently released, open source and competes with the major cloud services for accuracy. It has some restrictions on commercial use above $5M USD gross p/a (a nice problem to have) but otherwise is free to use. Running a page through surya and passing the bounding box data (as json) into ChatGPT seems to give good comprehension on tabluar data too. Combining it with a structured output solution like Instructor or Outlines would probably yield good results.
I’ve been planning to use a similar setup (Elixir + surya) for some open data projects but haven’t got round to it yet. Please let us know how you get on with it.
For text based PDFs I agree with the suggestion of using Tika, although it’s been a few years since I worked with it so take that with a pinch of salt.