Document Parser Skill
Purpose
Extracts text and structured data from documents using OCR technology, enabling automated processing of invoices, receipts, statements, and contracts.
Triggers
- PDF or image document uploaded
- Scanned invoice needs processing
- Receipt needs expense categorization
- Bank statement needs reconciliation
Capabilities
- OCR Text Extraction - Convert images to text
- PDF Parsing - Extract text from PDF documents
- Structured Data Extraction - Identify fields, tables, line items
- Document Classification - Classify document type
- Quality Assessment - Assess OCR confidence
Instructions
Step 1: Document Type Detection
Classify document:
- Invoice - Vendor bill
- Receipt - Proof of purchase
- Bank Statement - Monthly statement
- Contract - Legal agreement
- Other - Unknown type
Use file name, content patterns, or LLM classification.
Step 2: OCR Processing
Google Document AI (Preferred)
const document_ai = require('@google-cloud/documentai');
const client = new document_ai.DocumentProcessorServiceClient();
const [result] = await client.processDocument({
name: processor_name,
rawDocument: {
content: file_buffer.toString('base64'),
mimeType: 'application/pdf',
},
});
const extracted_text = result.document.text;
const entities = result.document.entities; // Pre-extracted fields
Tesseract OCR (Fallback)
tesseract invoice.png output -l eng
Step 3: Field Extraction
For Invoices, extract:
- Vendor name and address
- Invoice number and date
- Due date
- Line items (description, quantity, price)
- Subtotal, tax, total
For Receipts, extract:
- Merchant name
- Date and time
- Items purchased
- Total amount
For Bank Statements, extract:
- Account number
- Statement period
- Transaction list (date, description, amount)
- Beginning and ending balance
Step 4: Structured Output
Return JSON with confidence scores:
{
"document_type": "invoice",
"confidence": 0.92,
"raw_text": "...",
"extracted_fields": {
"vendor_name": "Office Depot",
"invoice_number": "INV-2024-001",
"invoice_date": "2026-01-15",
"due_date": "2026-02-15",
"total_amount": "250.00",
"currency": "USD",
"line_items": [
{
"description": "Printer Paper",
"quantity": "10",
"unit_price": "15.00",
"total": "150.00"
}
]
},
"field_confidence": {
"vendor_name": 0.95,
"invoice_number": 0.89,
"total_amount": 0.98
},
"requires_manual_review": false
}
Step 5: Quality Check
Assess quality:
- High Confidence (> 0.9) - Auto-process
- Medium Confidence (0.7 - 0.9) - Flag for review
- Low Confidence (< 0.7) - Require manual entry
Check for:
- Missing required fields
- Illegible text
- Poor image quality
- Incomplete document
Step 6: Post-Processing
- Normalize Data - Standardize dates, amounts
- Validate - Check logical consistency
- Enhance - Add context from database (e.g., known vendor)
Error Handling
- OCR Failed - Return error, suggest higher quality scan
- Unsupported Format - Return error, list supported formats
- Encrypted PDF - Request password or unlocked version
- Large File - Split into pages, process individually
- Poor Quality - Suggest rescan, adjust DPI
File Type Support
| Type |
Extension |
OCR Required |
| PDF (text) |
.pdf |
No |
| PDF (scanned) |
.pdf |
Yes |
| Image |
.png, .jpg, .jpeg |
Yes |
| Not Supported |
.doc, .docx, .xls |
Convert first |
Integration Points
- Google Document AI - Primary OCR engine
- Tesseract - Fallback OCR
- invoice-parser (AP worker) - For invoice-specific parsing
- data-validator (Data worker) - For validation
Models
- OCR: Google Document AI or Tesseract
- Classification: Claude Sonnet 4 or Gemini Flash
- Field Extraction: Claude Sonnet 4 (when OCR confidence low)
Security
- Validate file type and size before processing
- Scan for malware (if uploaded by user)
- Never store raw documents longer than needed
- Redact PII from logs
- Encrypt documents at rest
Performance
- Target: < 10s for invoice OCR
- Batch Processing: Process up to 50 invoices concurrently
- Caching: Cache OCR results for 24h (in case reprocessing needed)
Invoke this skill as the first step when processing any scanned or PDF document.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: document-parser3description: OCR and parse documents including invoices, receipts, and bank statements. Use when extracting text from PDF/images, parsing scanned documents, or processing uploaded files. Supports Google Document AI and Tesseract OCR. Use when this capability is needed.4---56# Document Parser Skill78## Purpose910Extracts text and structured data from documents using OCR technology, enabling automated processing of invoices, receipts, statements, and contracts.1112## Triggers1314- PDF or image document uploaded15- Scanned invoice needs processing16- Receipt needs expense categorization17- Bank statement needs reconciliation1819## Capabilities20211. **OCR Text Extraction** - Convert images to text222. **PDF Parsing** - Extract text from PDF documents233. **Structured Data Extraction** - Identify fields, tables, line items244. **Document Classification** - Classify document type255. **Quality Assessment** - Assess OCR confidence2627## Instructions2829### Step 1: Document Type Detection3031Classify document:32- **Invoice** - Vendor bill33- **Receipt** - Proof of purchase34- **Bank Statement** - Monthly statement35- **Contract** - Legal agreement36- **Other** - Unknown type3738Use file name, content patterns, or LLM classification.3940### Step 2: OCR Processing4142#### Google Document AI (Preferred)4344```typescript45const document_ai = require('@google-cloud/documentai');46const client = new document_ai.DocumentProcessorServiceClient();4748const [result] = await client.processDocument({49 name: processor_name,50 rawDocument: {51 content: file_buffer.toString('base64'),52 mimeType: 'application/pdf',53 },54});5556const extracted_text = result.document.text;57const entities = result.document.entities; // Pre-extracted fields58```5960#### Tesseract OCR (Fallback)6162```bash63tesseract invoice.png output -l eng64```6566### Step 3: Field Extraction6768For **Invoices**, extract:69- Vendor name and address70- Invoice number and date71- Due date72- Line items (description, quantity, price)73- Subtotal, tax, total7475For **Receipts**, extract:76- Merchant name77- Date and time78- Items purchased79- Total amount8081For **Bank Statements**, extract:82- Account number83- Statement period84- Transaction list (date, description, amount)85- Beginning and ending balance8687### Step 4: Structured Output8889Return JSON with confidence scores:90```json91{92 "document_type": "invoice",93 "confidence": 0.92,94 "raw_text": "...",95 "extracted_fields": {96 "vendor_name": "Office Depot",97 "invoice_number": "INV-2024-001",98 "invoice_date": "2026-01-15",99 "due_date": "2026-02-15",100 "total_amount": "250.00",101 "currency": "USD",102 "line_items": [103 {104 "description": "Printer Paper",105 "quantity": "10",106 "unit_price": "15.00",107 "total": "150.00"108 }109 ]110 },111 "field_confidence": {112 "vendor_name": 0.95,113 "invoice_number": 0.89,114 "total_amount": 0.98115 },116 "requires_manual_review": false117}118```119120### Step 5: Quality Check121122Assess quality:123- **High Confidence** (> 0.9) - Auto-process124- **Medium Confidence** (0.7 - 0.9) - Flag for review125- **Low Confidence** (< 0.7) - Require manual entry126127Check for:128- Missing required fields129- Illegible text130- Poor image quality131- Incomplete document132133### Step 6: Post-Processing134135- **Normalize Data** - Standardize dates, amounts136- **Validate** - Check logical consistency137- **Enhance** - Add context from database (e.g., known vendor)138139## Error Handling140141- **OCR Failed** - Return error, suggest higher quality scan142- **Unsupported Format** - Return error, list supported formats143- **Encrypted PDF** - Request password or unlocked version144- **Large File** - Split into pages, process individually145- **Poor Quality** - Suggest rescan, adjust DPI146147## File Type Support148149| Type | Extension | OCR Required |150|------|-----------|--------------|151| PDF (text) | .pdf | No |152| PDF (scanned) | .pdf | Yes |153| Image | .png, .jpg, .jpeg | Yes |154| Not Supported | .doc, .docx, .xls | Convert first |155156## Integration Points157158- **Google Document AI** - Primary OCR engine159- **Tesseract** - Fallback OCR160- **invoice-parser** (AP worker) - For invoice-specific parsing161- **data-validator** (Data worker) - For validation162163## Models164165- **OCR**: Google Document AI or Tesseract166- **Classification**: Claude Sonnet 4 or Gemini Flash167- **Field Extraction**: Claude Sonnet 4 (when OCR confidence low)168169## Security170171- Validate file type and size before processing172- Scan for malware (if uploaded by user)173- Never store raw documents longer than needed174- Redact PII from logs175- Encrypt documents at rest176177## Performance178179- **Target**: < 10s for invoice OCR180- **Batch Processing**: Process up to 50 invoices concurrently181- **Caching**: Cache OCR results for 24h (in case reprocessing needed)182183---184185Invoke this skill as the first step when processing any scanned or PDF document.186187---188> Converted and distributed by [TomeVault](https://tomevault.io/claim/alexi5000) — claim your Tome and manage your conversions.189<!-- tomevault:4.0:skill_md:2026-04-14 -->