PDF Files → Step 1 → Images → Step 2 → JSON → Step 3 → Excel
Input: input_pdfs/*.pdf
Output: output/step1_images/*.png
Process:
- Convert PDF to 300 DPI images
- Grayscale conversion
- Auto-deskew (rotation correction)
- Contrast enhancement (CLAHE)
- Noise reduction
Parallel Processing: 6 workers (configurable)
Input: output/step1_images/*.png
Output: output/step2_json/*.json
Process:
- Resize images if needed (max 1500px)
- Encode to base64
- Send to LM Studio Vision API
- Parse JSON response
- Sanitize data (remove formatting)
API: OpenAI-compatible format
Model: Qwen3-VL (recommended)
Retry Logic: 3 attempts with exponential backoff
Input: output/step2_json/*.json
Output: output/step3_excel/Rekapitulasi_Kuitansi.xlsx
Process:
- Load all JSON files
- Transform to DataFrame
- Format currency (thousands separator)
- Sort by receipt number
- Apply Excel styling (borders, headers, auto-width)
{
"no_kuitansi": "123",
"tanggal": "15-01-2024",
"penerima": "BUDI SANTOSO",
"uang_sejumlah_rp": "615000000",
"jumlah_liter": "3000",
"keterangan": "(80,2%)"
}| No. Kuitansi | Tanggal | Penerima | Uang Sejumlah (Rp) | Jumlah (Liter) | Keterangan |
|---|---|---|---|---|---|
| 123 | 15-01-2024 | BUDI SANTOSO | 615.000.000 | 3000 | (80,2%) |
MacBook M2 16GB:
- Step 1: ~2-3 sec/page (CPU-bound)
- Step 2: ~5-10 sec/image (LLM inference)
- Step 3: <1 sec (even for 100+ rows)
Memory Usage:
- Per worker: ~2GB RAM
- Peak total: ~8GB for 6 workers
Network Layer: Retry with exponential backoff
Parsing Layer: Multiple JSON extraction strategies
Data Layer: Sanitization and validation
All settings in config.py:
- Preprocessing options
- LM Studio connection
- Parallel processing limits
- Excel formatting