Local AI: PDF Digestion

Introduction

My local AI, the Strata project model qwen3.8-flash-next-iq3_s, does not accept PDFs for upload.

Strata Chat Interface

The interface does accept binary images.  So if I want my chat to consider the contents of a PDF, I have to extract its text and images and then upload the text and images to my local chat.  This study compares two tools that can be used for what I call “digestion” of PDF files: 1) pymupdf and 2) docling

Methodology

Since special libraries and AI models are needed, I created separate Python environments so we know what additional packages are needed and what space they consume.  When I installed docling, I was surprised — it looks like another AI model is staged for the docling process.

Libraries

Installing either library will consume appreciable disk space.  Notably, Docling could contribute as much as 9 GB.

Setting Up the Python Environments

pymupdf

jlpoole@ryzdesk ~ $ python3 -m venv ~/venvs/pymu
jlpoole@ryzdesk ~ $ du -s ~/venvs/pymu
13380 /home/jlpoole/venvs/pymu
jlpoole@ryzdesk ~ $ du -sh ~/venvs/pymu
14M /home/jlpoole/venvs/pymu
jlpoole@ryzdesk ~ $

docling

jlpoole@ryzdesk ~ $ python3 -m venv ~/venvs/docling
jlpoole@ryzdesk ~ $ du -sh ~/venvs/docling/
14M     /home/jlpoole/venvs/docling/
jlpoole@ryzdesk ~ $

Updated disk-space accounting

Component PyMuPDF Docling
Initial virtual environment 14 MiB 14 MiB
Installed virtual environment 294 MiB 6.2 GiB
Increase over baseline ~280 MiB ~6.19 GiB
Hugging Face model weights — 506 MiB
Recently modified pip cache Not yet apportioned 3,169.61 MiB (shared)

If we provisionally attribute all 3,169.61 MiB of recently modified pip cache files to Docling, the combined footprint would be approximately 9.8 GiB, including the environment growth, model weights, and cached downloads.  That figure is an upper-bound-style estimate, not a verified total: some cached packages may belong to PyMuPDF or other pip activity.

Test PDFs

I’m using these two PDFs since they contain lots of details in formats other than text that could be relevant to an AI’s analysis.

  • Sensirion specifications for its transducer SDP810-125PA
  • “Implementation, Characterization, and Evaluation of an Inexpensive
    Low-Power Low-Noise Infrasound Sensor Based on a Micromachined
    Differential Pressure Transducer and a Mechanical Filter” (2012)2

Results

Commands

The command for the pymupdf is this script:

import fitz # PyMuPDF
import os

doc = fitz.open("ABC.pdf")
os.makedirs("output_images", exist_ok=True)

# 1. Extract all text
with open("extracted_text.txt", "w", encoding="utf-8") as f:
for page_num in range(len(doc)):
page = doc[page_num]
f.write(f"--- Page {page_num + 1} ---\n")
f.write(page.get_text())

# 2. Extract all embedded images
image_count = 0
for page_num in range(len(doc)):
page = doc[page_num]
for img_index, img in enumerate(page.get_images(full=True)):
xref = img[0]
base_image = doc.extract_image(xref)
image_bytes = base_image["image"]
image_ext = base_image["ext"]
image_filename = f"output_images/page_{page_num + 1}_img_{image_index}.{image_ext}"
with open(image_filename, "wb") as img_file:
img_file.write(image_bytes)
image_count += 1

print(f"Extracted text to extracted_text.txt and {image_count} images to output_images/")
jlpoole@ryzdesk ~/work/HDC/pdftrial/pymupdf $ cat >install.sh

The command for the docling is simply:

docling ABC.pdf --to md --image-export-mode referenced --output output_dir/

Extractions Results

text extractions

pymupdf

Johnson Study – pymupdf (text)

Sensirion specification – pymupdf (text)

docling

Johnson Study – docling (markdown)

Sensirion specification – docling (markdown)

proof sheets of the image extractions

<

Johnson PDF Sensirion PDF
pymupdf

pymupdf Johnson

pymupdf Sensirion
docling

docling Johnson

docling Sensirion

Local AI Chats Analyses Base On A Particular Extraction

pymupdf-based chat  pymufpdf_strata-chat-2026-11-06-08-49.md

docling-based chat docling_strata-chat-2026-11-06-09-04.md

Analysis Of Both Chats

Local AI Analysis of its pymupdf and docling responses Analysis_of_both_chats_strata-chat-2026-11-06-17-21.md

Conclusion

Definitely go with the docling.  For technical PDFs that contain tables and graphs, you want the benefit of that information being digested for AI.

  1. </p> <div id="refs" class="references csl-bib-body hanging-indent" role="list"> <div id="ref-ImplementationCharacterizationandEvaluationofanInexpensiveLowPowerLowNoiseInfrasoundSensorBasedonaMicromachinedDifferentialPressureTransducerandaMechanicalFilter" class="csl-entry" role="listitem">Marcillo, Omar, Jeffrey B. Johnson, and Darren Hart. 2012.<br /> “Implementation, Characterization, and Evaluation of an<br /> Inexpensive Low-Power Low-Noise Infrasound Sensor Based on a<br /> Micromachined Differential Pressure Transducer and a Mechanical<br /> Filter.” <em>Journal of Atmospheric and Oceanic Technology</em><br /> (Boston MA, USA) 29 (9): 1275–84. <a href="https://doi.org/10.1175/JTECH-D-11-00101.1">https://doi.org/10.1175/JTECH-D-11-00101.1</a>.</div> </div> <p>
  2. Marcillo, Omar, Jeffrey B. Johnson, and Darren Hart. 2012.
    “Implementation, Characterization, and Evaluation of an
    Inexpensive Low-Power Low-Noise Infrasound Sensor Based on a
    Micromachined Differential Pressure Transducer and a Mechanical
    Filter.” Journal of Atmospheric and Oceanic Technology
    (Boston MA, USA) 29 (9): 1275–84. https://doi.org/10.1175/JTECH-D-11-00101.1.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *