pdflib-core-architecture

Generate pdf-lib 1.x code with correct awaits and bottom-left coordinates.

1|Updated Mar 19, 2026
One-click install
npx skills add https://github.com/OpenAEC-Foundation/pdf-lib-Claude-Skill-Package --skill pdflib-core-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pdflib-core-architecture
Source: https://github.com/OpenAEC-Foundation/pdf-lib-Claude-Skill-Package/tree/main/skills/source/pdflib-core/pdflib-core-architecture
Command: npx skills add https://github.com/OpenAEC-Foundation/pdf-lib-Claude-Skill-Package --skill pdflib-core-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

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.

Frequently Asked Questions about pdflib-core-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my pdf-lib code fail when embedding fonts or saving PDFs?

pdf-lib code fails because embedFont, loadImage, copyPages, and save are asynchronous operations that must be awaited. Forgetting to await these calls returns pending promises instead of actual objects, causing subsequent operations to fail.

How do I draw text at the top of a page using pdf-lib?

To draw text at the top of a page in pdf-lib, you must calculate the Y coordinate using the page height. Because pdf-lib uses a bottom-left coordinate origin, top-aligned positioning requires subtracting your desired top margin from the page height.

Do I need fontkit to embed custom fonts in pdf-lib?

Yes, you must register fontkit before embedding custom TTF fonts in pdf-lib. Standard fonts do not support Unicode characters, so registering fontkit is required to embed TrueType fonts and render non-ASCII text correctly.

Can I use pdf-lib to copy pages between different PDF documents?

Yes, pdf-lib supports copying pages between different PDF documents using the copyPages method. This is an asynchronous operation that must be awaited before adding the copied pages to the target document.

What image formats does pdf-lib support for embedding?

pdf-lib supports embedding only PNG and JPEG images. You must use the correct embed methods and await the asynchronous embedding process to ensure proper scaling and avoid runtime errors.

Does pdf-lib work in React Native and Deno environments?

Yes, pdf-lib runs in Node.js, browser, Deno, and React Native environments. The core create, load, modify, and save patterns remain consistent across these platforms, provided you handle async operations correctly.