pdf2ofd
Installation
SKILL.md
PDF to OFD High-Fidelity Converter
🎯 Purpose
A specialized skill for converting PDF documents into the Chinese National Standard OFD (GB/T 33190-2016) format. Optimized for Electronic Invoices (OFD版式发票) with advanced rendering capabilities that exceed standard conversion libraries.
✨ Key Features
- High-Fidelity Text Placement: Uses character-level positioning (
DeltaXarrays) and baseline origin data extracted viarawdictto ensure text layout is 100% identical to the source PDF. - Advanced Vector Graphics: Directly extracts original stroke colors, fill colors, and line widths. Supports complex path types and fill instructions.
- Transparency Preservation: Fully supports
AlphaandFillOpacityfor vector paths andSMasktransparency for images (e.g., electronic seals and signatures). - Cross-Platform Font Mapping: Intelligent mapping of macOS-specific (STSong, STKaiti) and Windows-specific font names to standardized OFD font names (宋体, 楷体, 黑体).
- In-Memory Packaging: Generates the final OFD zip structure entirely in memory to avoid temporary file clutter and ensure security.
- Color Snapping: Heuristic "Invoice Red" correction (
128 0 0) for financial documents while preserving non-standard colors.
🛠️ Usage Instructions
When a user asks to convert a PDF or a "High-Fidelity" invoice to OFD: