Where to parse PDFs locally when you run WordPress

Parse PDFs locally and you solve the compliance problem, but you inherit a compute problem. Docling, the open-source parser that started at IBM Research, recovers table cells, OCR text and captions without the file leaving the machine, at roughly 1 to 5 seconds per page on CPU, after a first-run model download of a few hundred megabytes. Kezhan Shi’s piece on Towards Data Science frames it as the local answer to Azure Document Intelligence. I agree, and on a WordPress project the deciding design question is where the parser runs.

The contract is the part you keep

My position: the engine is a detail, the output contract is the product. The article runs three engines, PyMuPDF, Azure DI and Docling, and all return the same dict of relational tables, so no downstream stage knows which one ran. Every per-row table also carries a parsing_method column, docling or fitz or azure_layout, which gives you provenance, de-duplication and routing accounting.

The capability gap is real, though. On the 15-page test paper Docling recovered 28 headings where fitz recovered zero, because the PDF has no native bookmarks, and the author is careful to say the count is document-specific. Define your own tables first, then swap engines behind them instead of letting a chunker depend on one engine’s document format.

Parse PDFs locally, just not inside PHP

The install pulls in PyTorch and the parse takes seconds per page, so neither survives a request lifecycle or a shared host. The engine belongs in a worker, and WordPress owns only the handoff. The call itself is short:

from docling.document_converter import DocumentConverter

converter = DocumentConverter()
result = converter.convert("supplier-price-list.pdf")
doc = result.document
markdown = doc.export_to_markdown()

On a WooCommerce store I would let Action Scheduler queue the document, have the worker write the markdown and summary counts back to a custom table, and start the job with wp eval-file. I would not bridge PHP into Python inside a page request. On a cheap shared host you cannot parse PDFs locally at all, so the honest answer is a cloud parser or manual entry.

What the model actually buys you

TableFormer detects each table as a grid of cells with row and column indices and header flags, so structure comes from a model rather than heuristics. Captions come from a layout label instead of a line-start regex, so Fig. 2 and wrapped captions stop being missed and body sentences that open with Figure 2 stop being false positives. Text inside figures lands as ordinary lines, so diagram labels become searchable. On the test document the line count rose to 560 rows once the four tables were flattened in.

Two gaps stay: no sub-line typography, so per-word bold and italic stay with fitz, and latency. The engines complement each other.

If you have supplier price lists or spec sheets that need to land in WooCommerce as structured data, this is the kind of pipeline I build, and the first step is checking what the documents actually contain.

Cheap pass first, escalate on signal

The routing rule the article lands on is the one I use: parse everything with the cheap extractor, then re-parse pages that fail a pre-parse check, a table region with no row-like structure, an image-heavy page with sparse text, a document with no TOC. With Docling the escalation costs CPU instead of per-page fees or a network hop, which matters when the document cannot leave the building. I made the same case for splitting parsing into cheap and heavy passes; nothing here changes it.

Test the worst documents first

The numbers move with hardware and Docling versions, so time it on your own worst documents. Check that you can pre-stage the model cache if the environment has no outbound internet. The code is MIT, but the project notes individual models carry their own terms, which matters if you ship a plugin. And if your corpus is mostly clean, born-digital text, skip all of it. The cheap extractor is still the right default, and parsing locally is a fix for a problem you might not have.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.

Leave a Comment