aiskillstore/marketplace / skills/89jobrien/pdf-processing
pdf-processing
VerifiedExtract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.
| File | Kind | Size |
|---|---|---|
| FORMS.md | markdown | 2.8 KB |
| SKILL.md | skill md | 3.2 KB |
| skill-report.json | config | 24.6 KB |
FORMS.md
View on GitHub# PDF Form Filling Guide
## Overview
This guide covers filling PDF forms programmatically using PyPDF2 and pdfrw libraries.
## Analyzing form fields
First, identify all fillable fields in a PDF:
```python
from pypdf import PdfReader
reader = PdfReader("form.pdf")
fields = reader.get_fields()
for field_name, field_info in fields.items():
print(f"Field: {field_name}")
print(f" Type: {field_info.get('/FT')}")
print(f" Value: {field_info.get('/V')}")
print()
```
## Filling form fields
Fill fields with values:
```python
from pypdf import PdfReader, PdfWriter
reader = PdfReader("form.pdf")
writer = PdfWriter()
writer.append_pages_from_reader(reader)
# Fill form fields
writer.update_page_form_field_values(
writer.pages[0],
{
"name": "John Doe",
"email": "john@example.com",
"address": "123 Main St"
}
)
with open("filled_form.pdf", "wb") as output:
writer.write(output)
```
## Flattening forms
Remove form fields after filling (make non-editable):
```python
from pypdf import PdfReader, PdfWriter
reader = PdfReader("filled_form.pdf")
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
# Flatten all form fields
writer.flatten_form_fields()
with open("flattened.pdf", "wb") as output:
writer.write(output)
```
## Validation
Validate field values before filling:
```python
def validate_email(email):
return "@" in email and "." in email
def validate_form_data(data, required_fields):
errors = []
for field in required_fields:
if field not in data or not data[field]:
errors.append(f"Missing required field: {field}")
if "email" in data and not validate_email(data["email"]):
errors.append("Invalid email format")
return errors
# Usage
data = {"name": "John Doe", "email": "john@example.com"}
required = ["name", "email", "address"]
errors = validate_form_data(data, required)
if errors:
print("Validation errors:")
for error in errors:
print(f" - {error}")
else:
# Proceed with filling
pass
```
## Common field types
**Text fields:**
```python
writer.update_page_form_field_values(
writer.pages[0],
{"text_field": "Some text"}
)
```
**Checkboxes:**
```python
# Check a checkbox
writer.update_page_form_field_values(
writer.pages[0],
{"checkbox_field": "/Yes"}
)
# Uncheck a checkbox
writer.update_page_form_field_values(
writer.pages[0],
{"checkbox_field": "/Off"}
)
```
**Radio buttons:**
```python
writer.update_page_form_field_values(
writer.pages[0],
{"radio_group": "/Option1"}
)
```
## Best practices
1. **Always validate** input data before filling
2. **Check field names** match exactly (case-sensitive)
3. **Test with small files** first
4. **Keep originals** - work on copies
5. **Flatten after filling** for distribution
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |