pdflib-syntax-document

Create, load, modify, and save PDF documents with pdf-lib in TypeScript and JavaScript.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Prevents common pdf-lib mistakes that lead to silent failures or data loss, such as forgetting to await asynchronous APIs, unintentionally overwriting original metadata when loading, choosing the wrong save format for browser contexts, or mishandling encrypted PDFs.

Core Features & Use Cases

  • Guidance for correct PDF lifecycle operations: creating, loading, modifying, and saving documents with pdf-lib.
  • Metadata management and preservation strategies for archival and distribution workflows, including title, author, keywords, language, and creation/modification timestamps.
  • Output and compatibility decisions for Node.js and browser contexts, including choosing between binary saves and base64/data URI exports, attachments handling, and encryption-aware loading.

Quick Start

Load the PDF bytes with updateMetadata set to false to preserve original metadata, make your changes, then await save or saveAsBase64 for the correct output format.

Frequently Asked Questions about pdflib-syntax-document

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

FAQPage Schema
How do I load and save a PDF with pdf-lib without losing original metadata?

To load and save a PDF without losing original metadata, use the `updateMetadata: false` option when loading the document. This preserves archival fields like title, author, and keywords during modification, preventing unintentional overwrites when you await the final save operation.

Why does my pdf-lib document save fail silently in Node.js or the browser?

Silent save failures occur when pdf-lib asynchronous APIs are not awaited. You must await the `save` or `saveAsBase64` methods to ensure the PDF binary or base64 output is fully processed before the workflow continues, preventing data loss.

Should I use saveAsBase64 or binary save for pdf-lib in browser contexts?

For browser contexts, use `saveAsBase64` to generate a data URI suitable for downloads or embedding. Binary saves are intended for Node.js file system workflows, ensuring the output format matches your platform's compatibility requirements.

Can I load encrypted PDFs using pdf-lib?

Yes, you can load encrypted PDFs by passing the `ignoreEncryption: true` option during the load operation. This allows you to access and modify the document contents, though it bypasses the encryption layer rather than decrypting it for re-saving.

What is the best way to attach files to a PDF using pdf-lib?

The best way to attach files to a PDF is to load the document bytes, call the attachment methods provided by pdf-lib, and then await the `save` operation with `useObjectStreams` configured to meet your compatibility and preservation requirements.

Does pdf-lib work with both JavaScript and TypeScript workflows?

Yes, pdf-lib works with both JavaScript and TypeScript workflows in Node.js and browser contexts. It handles tasks like creating new PDFs, preserving metadata, attaching files, and producing binary or base64 outputs across these environments.