1---2name: oma-pdf3description: Convert PDF files to Markdown using opendataloader-pdf. Extracts text, tables, headings, lists, and images with correct reading order. Use for PDF parsing, PDF to Markdown conversion, document extraction, and AI-ready data preparation.4---5
6# PDF Skill - PDF to Markdown Conversion
7
8## Scheduling
9
10### Goal
11Convert PDF files into structured Markdown or another requested extraction format while preserving readable document structure for LLM context, RAG, or downstream review.
12
13### Intent signature
14- User asks to convert, parse, read, extract, or transform a PDF.
15- User needs PDF text, headings, lists, tables, or images prepared for AI consumption.
16- User mentions "PDF to markdown", "parse PDF", "read this PDF", or equivalent wording.
17
18### When to use
19- Converting PDF documents to Markdown for LLM context or RAG
20- Extracting structured content such as tables, headings, lists, images, footnotes, or hyperlinks
21- Preparing PDF data for AI consumption
22- Checking whether a PDF has a text layer before choosing OCR
23
24### When NOT to use
25- Generating or creating PDFs -> use document-generation tools
26- Editing existing PDFs -> out of scope
27- Reading an already-text file -> use direct file reading
28- Processing HWP, HWPX, DOCX, XLSX, or slide decks -> use the matching document skill
29
30### Expected inputs
31- `input_path`: PDF file or folder path
32- `output_dir`: optional target directory
33- `format`: optional output format, default `markdown`
34- `ocr_languages`: optional OCR language list for scanned or image-based PDFs
35- `extraction_options`: optional flags for tagged structure, image extraction, or hybrid conversion
36
37### Expected outputs
38- Markdown, text, JSON, HTML, or combined extraction output
39- Normalized Markdown when Markdown is produced
40- A short report with output path, page count, and conversion issues
41
42### Dependencies
43- `uvx opendataloader-pdf` for standard conversion
44- `uvx --from "opendataloader-pdf[hybrid]" opendataloader-pdf-hybrid` for OCR or hybrid conversion (the hybrid server is a console script of the `[hybrid]` extra, not a standalone package)
45- `uvx mdformat` for Markdown normalization
46- Local filesystem access to input and output paths
47- Optional OCR runtime via the hybrid server
48
49### Control-flow features
50- Branches on text-layer quality, tagged PDF availability, scan/OCR needs, and user-requested output format
51- Calls external CLI tools through `uvx`
52- Reads local files and writes local extraction outputs
53- Uses a hybrid server only when OCR or complex extraction needs justify it
54
55## Structural Flow
56
57### Entry
581. Confirm that the input path exists and is a PDF file, PDF folder, or supported batch input.
592. Check file size and warn when the input is large enough to risk slow conversion or memory pressure.
603. Resolve `output_dir` and the expected output filename.
61
62### Scenes
631. **PREPARE**: Validate the input path, output target, and requested extraction options.
642. **ACQUIRE**: Assess whether the PDF has a readable text layer by extracting a text preview.
653. **ACT**: Convert using standard mode, tagged-structure mode, or hybrid OCR mode.
664. **VERIFY**: Run `mdformat` for Markdown output and inspect the result for readable structure.
675. **FINALIZE**: Report output path, page count, format, and any extraction quality issues.
68
69### Transitions
70- If the preview text is readable, use standard conversion.
71- If the PDF is tagged and standard output is garbled, retry with `--use-struct-tree`.
72- If the PDF is scanned or image-based, start or reuse the hybrid OCR server and convert with hybrid mode.
73- If conversion fails because the PDF is encrypted, stop and ask for the password or an unlocked copy.
74- If conversion hits memory or size limits, process smaller page ranges or batches.
75
76### Failure and recovery
77| Failure | Recovery |
78|---------|----------|
79| `uvx` unavailable | Ask user to install `uv` before conversion |
80| `opendataloader-pdf-hybrid` not found | Invoke via `uvx --from "opendataloader-pdf[hybrid]" opendataloader-pdf-hybrid`; the bare package name does not exist on PyPI |
81| Password-protected PDF | Ask for password or unlocked PDF |
82| Garbled output | Retry with tagged structure or hybrid mode |
83| Missing tables | Retry with hybrid mode for complex or borderless tables |
84| OCR language mismatch | Retry with explicit OCR languages, for example `ko,en` |
85| Large file or memory pressure | Split into page ranges or batch smaller inputs |
86
87### Exit
88- Success: output file exists, Markdown is formatted when applicable, and extracted structure is readable.
89- Partial success: output exists but quality issues are reported explicitly.
90- Failure: no reliable output is produced and the blocking cause is reported.
91
92## Logical Operations
93
94### Actions
95| Action | SSL primitive | Evidence |
96|--------|---------------|----------|
97| Validate path and options | `VALIDATE` | Input preflight in execution protocol |
98| Probe text layer | `READ` | Text preview extraction |
99| Choose conversion strategy | `SELECT` | Standard, tagged, or hybrid mode decision |
100| Run converter | `CALL_TOOL` | `uvx opendataloader-pdf` |
101| Start OCR server | `CALL_TOOL` | `uvx --from "opendataloader-pdf[hybrid]" opendataloader-pdf-hybrid` |
102| Write output artifact | `WRITE` | Markdown, text, JSON, or HTML output |
103| Normalize Markdown | `CALL_TOOL` | `uvx mdformat` |
104| Inspect extraction quality | `VALIDATE` | Structure/readability verification |
105| Report result | `NOTIFY` | Final user-facing summary |
106
107### Tools and instruments
108- `opendataloader-pdf`: primary PDF extraction CLI
109- `opendataloader-pdf-hybrid`: hybrid OCR and complex extraction path
110- `mdformat`: Markdown normalization
111- Filesystem commands such as `file`, `wc`, or `pdfinfo` may be used for preflight when available
112
113### Canonical command path
114```bash
115uvx opendataloader-pdf "{input_path}" --format markdown --output-dir "{output_dir}"
116uvx mdformat "{output_path}"
117```
118
119For scanned/image-based PDFs, start OCR first and then convert through hybrid mode:
120```bash
121uvx --from "opendataloader-pdf[hybrid]" opendataloader-pdf-hybrid --port 5002 --force-ocr --ocr-lang "{languages}"
122uvx opendataloader-pdf --hybrid docling-fast "{input_path}" --format markdown --output-dir "{output_dir}"
123```
124
125### Resource scope
126| Scope | Resource target |
127|-------|-----------------|
128| `LOCAL_FS` | Input PDFs and generated output files |
129| `PROCESS` | `uvx` subprocesses and optional hybrid server |
130| `MEMORY` | Extracted previews and validation notes |
131| `OTHER` | OCR model/runtime behavior inside hybrid mode |
132
133### Preconditions
134- The input PDF path exists and is readable.
135- The output location is writable or can be created.
136- Required CLIs are available through `uvx`.
137- OCR is only attempted when hybrid mode is available or can be started.
138
139### Effects and side effects
140- Creates or overwrites extraction output depending on configuration and user intent.
141- May start a local hybrid OCR server on the configured port.
142- May consume significant CPU, memory, or time for large or scanned PDFs.
143- Does not intentionally modify the source PDF.
144
145### Guardrails
1461. Do not invent missing content when extraction is incomplete.
1472. Always report garbled text, missing tables, OCR uncertainty, or partial extraction.
1483. Prefer standard conversion first when the text layer is readable.
1494. Use OCR only when the PDF is scanned, image-based, or standard extraction quality is insufficient.
1505. Keep detailed command sequences in `resources/execution-protocol.md` rather than duplicating every variant here.
151
152## References
153- Execution protocol: `resources/execution-protocol.md`
154- Configuration: `config/pdf-config.yaml`
155- Context loading: `../_shared/core/context-loading.md`
156- Quality principles: `../_shared/core/quality-principles.md`