Source: https://github.com/aipoch/medical-research-skills
When to Use
- You need to merge multiple PDFs into a single document offline.
- You need to split a PDF into per-page files for review, annotation, or distribution.
- You need to extract a specific page range (e.g.,
1-3,5) into a new PDF.
- You need to extract selectable text from a PDF into a
.txt file without using any cloud API.
- You need to extract tables from PDFs into CSV files locally.
Key Features
- Merge PDFs: Combine multiple input PDFs into one output PDF.
- Split PDFs: Export each page as an individual PDF.
- Extract Pages: Create a new PDF from selected pages using a page-range expression.
- Extract Text: Export extracted text to a plain text file.
- Extract Tables: Export detected tables to CSV files (may produce empty CSVs on pages without tables).
- Create PDF: Generate a simple PDF from a text file.
- Local-only execution: No network access, no external APIs, no credentials.
Dependencies
Install Python dependencies:
pip install -r scripts/requirements.txt
Example Usage
More examples may be available in references/examples.md.
Merge PDFs
python scripts/pdf_tool.py \
--operation merge \
--inputs "a.pdf" "b.pdf" \
--output "out.pdf"
Split a PDF into single-page PDFs
python scripts/pdf_tool.py \
--operation split \
--inputs "input.pdf" \
--output "out_dir"
Extract specific pages into a new PDF
python scripts/pdf_tool.py \
--operation extract-pages \
--inputs "input.pdf" \
--pages "1-3,5" \
--output "extracted.pdf"
Extract text to a .txt file
python scripts/pdf_tool.py \
--operation extract-text \
--inputs "input.pdf" \
--output "output.txt"
Extract tables to CSV files
python scripts/pdf_tool.py \
--operation extract-tables \
--inputs "input.pdf" \
--output "tables_out_dir"
Create a PDF from a text file
python scripts/pdf_tool.py \
--operation create \
--inputs "input.txt" \
--output "created.pdf"
Implementation Details
- Execution model: Local CLI tool/script (
scripts/pdf_tool.py) that reads from provided input paths and writes only to the specified output path.
- Supported operations:
merge: Concatenates PDFs in the order provided via --inputs.
split: Writes one PDF per page (output is typically a directory path).
extract-pages: Uses --pages to select pages and writes a new PDF.
extract-text: Extracts selectable text; pages with no extractable text may yield empty lines.
extract-tables: Attempts table detection/extraction; pages without tables may produce empty CSV outputs.
create: Produces a simple PDF from a text input.
- Page range format:
--pages "1-3,5" where page numbering starts at 1.
- Failure handling:
- Invalid or out-of-range pages in
--pages are ignored.
- Text extraction preserves structure minimally; no OCR is performed.
- Table extraction quality depends on the PDF's structure; complex layouts may not reconstruct well.
- Security constraints:
- No network calls.
- No external services.
- Reads only specified input files and writes only to the specified output location.
- Success criteria:
- Output file(s) exist at the specified location.
- Page counts and ordering match the requested operation.
- No writes occur outside the specified output path.
When Not to Use
- Do not use this skill when the required source data, identifiers, files, or credentials are missing.
- Do not use this skill when the user asks for fabricated results, unsupported claims, or out-of-scope conclusions.
- Do not use this skill when a simpler direct answer is more appropriate than the documented workflow.
Required Inputs
- A clearly specified task goal aligned with the documented scope.
- All required files, identifiers, parameters, or environment variables before execution.
- Any domain constraints, formatting requirements, and expected output destination if applicable.
Recommended Workflow
- Validate the request against the skill boundary and confirm all required inputs are present.
- Select the documented execution path and prefer the simplest supported command or procedure.
- Produce the expected output using the documented file format, schema, or narrative structure.
- Run a final validation pass for completeness, consistency, and safety before returning the result.
Output Contract
- Return a structured deliverable that is directly usable without reformatting.
- If a file is produced, prefer a deterministic output name such as
pdf_processor_result.md unless the skill documentation defines a better convention.
- Include a short validation summary describing what was checked, what assumptions were made, and any remaining limitations.
Validation and Safety Rules
- Validate required inputs before execution and stop early when mandatory fields or files are missing.
- Do not fabricate measurements, references, findings, or conclusions that are not supported by the provided source material.
- Emit a clear warning when credentials, privacy constraints, safety boundaries, or unsupported requests affect the result.
- Keep the output safe, reproducible, and within the documented scope at all times.
Failure Handling
- If validation fails, explain the exact missing field, file, or parameter and show the minimum fix required.
- If an external dependency or script fails, surface the command path, likely cause, and the next recovery step.
- If partial output is returned, label it clearly and identify which checks could not be completed.
Input Validation
This skill accepts requests that match the documented purpose of pdf-processor and include enough context to complete the workflow safely.
Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
pdf-processor only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
Quick Validation
Run this minimal verification path before full execution when possible:
python scripts/pdf_tool.py --help
Expected output format:
Result file: pdf_processor_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any
1---2name: pdf-processor3description: Perform basic local PDF operations (merge, split, extract pages/text/tables, create) when users request offline PDF processing without external services.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8## When to Use
9- You need to merge multiple PDFs into a single document offline.
10- You need to split a PDF into per-page files for review, annotation, or distribution.
11- You need to extract a specific page range (e.g., `1-3,5`) into a new PDF.
12- You need to extract selectable text from a PDF into a `.txt` file without using any cloud API.
13- You need to extract tables from PDFs into CSV files locally.
14
15## Key Features
16- **Merge PDFs**: Combine multiple input PDFs into one output PDF.
17- **Split PDFs**: Export each page as an individual PDF.
18- **Extract Pages**: Create a new PDF from selected pages using a page-range expression.
19- **Extract Text**: Export extracted text to a plain text file.
20- **Extract Tables**: Export detected tables to CSV files (may produce empty CSVs on pages without tables).
21- **Create PDF**: Generate a simple PDF from a text file.
22- **Local-only execution**: No network access, no external APIs, no credentials.
23
24## Dependencies
25- **Python**: 3.9+
26
27Install Python dependencies:
28```bash
29pip install -r scripts/requirements.txt
30```
31
32## Example Usage
33> More examples may be available in `references/examples.md`.
34
35### Merge PDFs
36```bash
37python scripts/pdf_tool.py \
38 --operation merge \
39 --inputs "a.pdf" "b.pdf" \
40 --output "out.pdf"
41```
42
43### Split a PDF into single-page PDFs
44```bash
45python scripts/pdf_tool.py \
46 --operation split \
47 --inputs "input.pdf" \
48 --output "out_dir"
49```
50
51### Extract specific pages into a new PDF
52```bash
53python scripts/pdf_tool.py \
54 --operation extract-pages \
55 --inputs "input.pdf" \
56 --pages "1-3,5" \
57 --output "extracted.pdf"
58```
59
60### Extract text to a `.txt` file
61```bash
62python scripts/pdf_tool.py \
63 --operation extract-text \
64 --inputs "input.pdf" \
65 --output "output.txt"
66```
67
68### Extract tables to CSV files
69```bash
70python scripts/pdf_tool.py \
71 --operation extract-tables \
72 --inputs "input.pdf" \
73 --output "tables_out_dir"
74```
75
76### Create a PDF from a text file
77```bash
78python scripts/pdf_tool.py \
79 --operation create \
80 --inputs "input.txt" \
81 --output "created.pdf"
82```
83
84## Implementation Details
85- **Execution model**: Local CLI tool/script (`scripts/pdf_tool.py`) that reads from provided input paths and writes only to the specified output path.
86- **Supported operations**:
87 - `merge`: Concatenates PDFs in the order provided via `--inputs`.
88 - `split`: Writes one PDF per page (output is typically a directory path).
89 - `extract-pages`: Uses `--pages` to select pages and writes a new PDF.
90 - `extract-text`: Extracts selectable text; pages with no extractable text may yield empty lines.
91 - `extract-tables`: Attempts table detection/extraction; pages without tables may produce empty CSV outputs.
92 - `create`: Produces a simple PDF from a text input.
93- **Page range format**: `--pages "1-3,5"` where page numbering starts at **1**.
94- **Failure handling**:
95 - Invalid or out-of-range pages in `--pages` are ignored.
96 - Text extraction preserves structure minimally; no OCR is performed.
97 - Table extraction quality depends on the PDF's structure; complex layouts may not reconstruct well.
98- **Security constraints**:
99 - No network calls.
100 - No external services.
101 - Reads only specified input files and writes only to the specified output location.
102- **Success criteria**:
103 - Output file(s) exist at the specified location.
104 - Page counts and ordering match the requested operation.
105 - No writes occur outside the specified output path.
106
107## When Not to Use
108
109- Do not use this skill when the required source data, identifiers, files, or credentials are missing.
110- Do not use this skill when the user asks for fabricated results, unsupported claims, or out-of-scope conclusions.
111- Do not use this skill when a simpler direct answer is more appropriate than the documented workflow.
112
113## Required Inputs
114
115- A clearly specified task goal aligned with the documented scope.
116- All required files, identifiers, parameters, or environment variables before execution.
117- Any domain constraints, formatting requirements, and expected output destination if applicable.
118
119## Recommended Workflow
120
1211. Validate the request against the skill boundary and confirm all required inputs are present.
1222. Select the documented execution path and prefer the simplest supported command or procedure.
1233. Produce the expected output using the documented file format, schema, or narrative structure.
1244. Run a final validation pass for completeness, consistency, and safety before returning the result.
125
126## Output Contract
127
128- Return a structured deliverable that is directly usable without reformatting.
129- If a file is produced, prefer a deterministic output name such as `pdf_processor_result.md` unless the skill documentation defines a better convention.
130- Include a short validation summary describing what was checked, what assumptions were made, and any remaining limitations.
131
132## Validation and Safety Rules
133
134- Validate required inputs before execution and stop early when mandatory fields or files are missing.
135- Do not fabricate measurements, references, findings, or conclusions that are not supported by the provided source material.
136- Emit a clear warning when credentials, privacy constraints, safety boundaries, or unsupported requests affect the result.
137- Keep the output safe, reproducible, and within the documented scope at all times.
138
139## Failure Handling
140
141- If validation fails, explain the exact missing field, file, or parameter and show the minimum fix required.
142- If an external dependency or script fails, surface the command path, likely cause, and the next recovery step.
143- If partial output is returned, label it clearly and identify which checks could not be completed.
144
145
146## Input Validation
147
148This skill accepts requests that match the documented purpose of `pdf-processor` and include enough context to complete the workflow safely.
149
150Do not continue the workflow when the request is out of scope, missing a critical input, or would require unsupported assumptions. Instead respond:
151
152> `pdf-processor` only handles its documented workflow. Please provide the missing required inputs or switch to a more suitable skill.
153
154## Quick Validation
155
156Run this minimal verification path before full execution when possible:
157
158```bash
159python scripts/pdf_tool.py --help
160```
161
162Expected output format:
163
164```text
165Result file: pdf_processor_result.md
166Validation summary: PASS/FAIL with brief notes
167Assumptions: explicit list if any
168```