PDF to Markdown
PDF to Markdown is hard.
PDFs are a silly format. Truly designed with visual consumption foremost in mind.
Unlike HTML, PDF's internal format doesn't really have a sense of "this text is all in order, but position and layout affect its presentation". PDFs are all presentation
This is obviously not an uncommon problem but solving it using my favorite toolkit (bash + python scripts on macos) took research.
- First attempt
Pandoc is a well-known quantity in document conversion. But alas, no PDF support as a source document.
- Second attempt
PDF2HTML looked promising, and is registered in homebrew but alas it is 9 year old software. Will it still work? Sadly, no.
- Third attempt
PDF2HTMLEx is a more up to date fork (this not, not that one) but also has no mac os support. A docker image is the recommended starting point. ugh
- Fourth attempt
Docling !
- Bonus attempt
In the process I also learned about pdftotext, which is what Anthropic's Computer Use demo uses.