What problem does it solve?
Provides authoritative, version-aware guidance to avoid the most common and critical pdf-lib mistakes — forgetting to await async operations, using the wrong coordinate origin, mis-embedding fonts, and incorrect cross-document page handling — so developers produce reliable PDF code across environments.
Core Features & Use Cases
- Library architecture & lifecycle: Clear create/load/configure/draw/save patterns and the distinction between async embeds and sync drawing operations.
- Font and image rules: When and how to register fontkit, prefer custom fonts for Unicode, and embed only PNG/JPEG images with correct scaling.
- Coordinate system & layout patterns: Bottom-left origin guidance, top-aligned positioning using page height, and common page sizes and defaults.
- Practical use case: Author code that creates an A4 document, registers fontkit, embeds a TTF font, draws a header and images with proper sizing, and saves the output without runtime errors.
Quick Start
Create a new A4 PDF with pdf-lib 1.x, register fontkit before embedding any TTF, embed the font, draw a top-aligned header using page height for positioning, and save the PDF while awaiting all async embed and save calls.