pdf

Read, OCR, inspect, transform, and write PDFs in SQL

Maintainer(s): asubbarao

Installing and Loading

INSTALL pdf FROM community;
LOAD pdf;

Example

LOAD pdf;
-- One row per page (file, list, or glob; parallel across pages/files)
SELECT filename, page, text
FROM read_pdf('reports/*.pdf')
WHERE contains(lower(text), 'revenue');
-- Metadata census
SELECT file, title, author, page_count FROM pdf_info('reports/*.pdf');
-- RAG chunks in one statement
CREATE TABLE chunks AS FROM pdf_chunks('reports/*.pdf');
-- Page raster + native write
SELECT pdf_to_png('report.pdf', 1, 150) AS page_image;
COPY (SELECT * FROM findings)
TO 'findings.pdf' (FORMAT pdf, TITLE 'Findings', FOOTER 'page {page}');

About pdf

Everything PDF, in SQL — Poppler, Tesseract (OCR), qpdf, and libharu, statically linked. Paths or globs; no external tools at runtime for core ops. Full docs and recipes: github.com/asubbarao/duckdb-pdf.

Readread_pdf, read_pdf_lines, read_pdf_words / read_pdf_layout (word boxes), read_pdf_elements, read_pdf_tables, pdf_chunks. Auto-OCR on image-only pages; English model bundled.

Inspectpdf_info, outline, attachments, form fields, annotations, revisions, signatures, embedded images.

Convert / render — text, markdown, HTML, XML, SVG, PNG; low-level poppler_render_page + tesseract_ocr for blob pipelines.

Transform & write — merge, split, rotate, compress, encrypt/decrypt, watermark, Bates, sign, redact; write_pdf / COPY … (FORMAT pdf); to_pdf for office docs (LibreOffice at runtime).

Scope — deterministic extraction, not ML document AI. License — GPL-2.0-or-later (Poppler).

Added Functions

function_name function_type description comment examples
pdf_annotations table NULL NULL
pdf_attachments table NULL NULL
pdf_bates scalar NULL NULL
pdf_chunks table NULL NULL
pdf_compress scalar NULL NULL
pdf_decrypt scalar NULL NULL
pdf_destinations table NULL NULL
pdf_encrypt scalar NULL NULL
pdf_fonts table NULL NULL
pdf_form_fields table NULL NULL
pdf_images table NULL NULL
pdf_info table NULL NULL
pdf_json scalar NULL NULL
pdf_merge scalar NULL NULL
pdf_outline table NULL NULL
pdf_page_images table NULL NULL
pdf_pages scalar NULL NULL
pdf_pages_info table NULL NULL
pdf_permissions table NULL NULL
pdf_qpdf_info table NULL NULL
pdf_redact table NULL NULL
pdf_redact_lateral table NULL NULL
pdf_repair scalar NULL NULL
pdf_revisions table NULL NULL
pdf_rotate scalar NULL NULL
pdf_sign table NULL NULL
pdf_signatures table NULL NULL
pdf_split table NULL NULL
pdf_split_blank table NULL NULL
pdf_to_html scalar NULL NULL
pdf_to_markdown scalar NULL NULL
pdf_to_png scalar NULL NULL
pdf_to_svg scalar NULL NULL
pdf_to_text scalar NULL NULL
pdf_to_xml scalar NULL NULL
pdf_watermark scalar NULL NULL
pdf_write_page_images table NULL NULL
poppler_render_page scalar NULL NULL
poppler_version scalar NULL NULL
read_pdf table NULL NULL
read_pdf_elements table NULL NULL
read_pdf_layout table NULL NULL
read_pdf_lines table NULL NULL
read_pdf_meta table NULL NULL
read_pdf_tables table NULL NULL
read_pdf_words table NULL NULL
tesseract_ocr scalar NULL NULL
to_pdf scalar NULL NULL
write_pdf scalar NULL NULL

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.