出品者:Temi O.

PDFKit is a full-featured PDF document generation library for Node.js and the browser, offering a chainable API for text, vector graphics, images, fonts, annotations, forms, and PDF security.
This block provides the full PDFKit library source (user@example.com), a PDF document generation library for Node.js and the browser. It covers vector graphics, text layout with line wrapping, font embedding (TTF/OTF/WOFF/WOFF2), JPEG/PNG image embedding, tables, AcroForms, annotations, outlines, PDF security/encryption, and accessibility (Tagged PDF/PDF-UA). The typical buyer is a backend or full-stack developer generating invoices, reports, or complex printable documents programmatically.
document.js — Core PDFDocument class; entry point for all document creationpage.js — PDF page management and geometryfont.js — Font loading and metrics integrationfont_factory.js — Font object factory (embedded vs. standard)image.js — Image embedding dispatcherline_wrapper.js — Line-breaking and wrapping engine for text layoutgradient.js — Linear and radial gradient definitionspattern.js — Tiling pattern supportpath.js — SVG path parser and command dispatchersecurity.js — PDF encryption (RC4/AES) and access permissionsmetadata.js — XMP metadata writingoutline.js — PDF outline (bookmark) treeobject.js — Low-level PDF object serializationreference.js — Indirect PDF reference handlingabstract_reference.js — Base class for referencesname_tree.js / number_tree.js — PDF name/number tree structurestree.js — Generic tree utilitydata.js — Binary data buffer wrapperbinary.js — Binary stream utilitiesutils.js — Shared numeric/string helpers (PDFNumber, etc.)virtual-fs.js — Abstract filesystem shim for browser compatibilityspotcolor.js — Spot color (separation) supportstructure_element.js / structure_content.js / structure_annotation.js — Tagged PDF logical structurecrypto/ — AES, MD5, RC4, SHA-256, and CSPRNG implementations隔離されたサンドボックスを起動しサーバー側で実行 — ローカル設定不要。
このバージョンの Tetrees AI Review
This JavaScript cli / script completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
パイプライン avcp-2026-08-04.1 · SHA-256 469908a160a857ad…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
レビュー日 2026年8月4日
この製品をお使いのAI IDE・Webビルダー・クラウドIDEに直接取り込みます。
Tetreesを対応AI IDEに接続し、所有製品の一覧取得と検証済みZIPの取得を、販売者のアップロード権限を公開せずに行えます。
まだレビューがありません。
Sign in to join the discussion
Loading discussion…
font/ — AFM standard fonts, embedded font subsettingimage/ — JPEG and PNG image parsersmixins/ — Feature mixins: text, vector, color, fonts, images, annotations, AcroForms, tables, outlines, metadata, markings, accessibility, PDF/A, PDF/UA, attachments, subsetssaslprep/ — SASLprep string normalization (used for PDF password handling)table/ — Structured table layout: normalization, sizing, rendering, accessibilitynpm install @noble/ciphers @noble/hashes fontkit linebreak png-js
No native modules or build steps (pod install / Android linking / expo prebuild) are required. This library runs in Node.js and modern browsers. For browser builds, a bundler (webpack/esbuild/Vite) with a
Bufferpolyfill is needed.
source/ directory into your project, e.g. src/pdfkit/.tsconfig.json (or jsconfig.json) includes the source root:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"pdfkit/*": ["src/pdfkit/*"]
},
"allowJs": true,
"esModuleInterop": true
}
}
@babel/plugin-transform-modules-commonjs or ensure "type": "module" is set in your package.json for ESM.Buffer and stream.PDFDocument from src/pdfkit/document.js as your entry point — all other modules are loaded transitively.import PDFDocument from './src/pdfkit/document.js';
const doc = new PDFDocument(options?: {
size?: string | [number, number]; // e.g. 'A4', 'LETTER', or [width, height] in points
margin?: number;
margins?: { top: number; bottom: number; left: number; right: number };
layout?: 'portrait' | 'landscape';
info?: { Title?: string; Author?: string; Subject?: string; [key: string]: any };
pdfVersion?: '1.3' | '1.4' | '1.5' | '1.6' | '1.7' | '1.7ext3';
userPassword?: string;
ownerPassword?: string;
permissions?: object;
autoFirstPage?: boolean;
bufferPages?: boolean;
lang?: string;
displayTitle?: boolean;
tagged?: boolean;
});
PDFDocument is the root object. Pipe its output stream to a writable (file, HTTP response, or blob) and call .end() to finalize. All drawing, text, font, and image methods are accessed through this object via mixins.
import LineWrapper from './src/pdfkit/line_wrapper.js';
new LineWrapper(document: PDFDocument, options: {
width: number;
height?: number;
columns?: number;
columnGap?: number;
indent?: number;
indentAllLines?: boolean;
ellipsis?: boolean | string;
horizontalScaling?: number;
characterSpacing?: number;
wordSpacing?: number;
features?: string[];
});
Used internally by the text mixin to handle automatic line wrapping, multi-column layout, and soft-hyphen processing. Use directly only when implementing custom text rendering logic outside the standard .text() mixin.
table/index.js)import PDFTable from './src/pdfkit/table/index.js';
new PDFTable(document: PDFDocument, opts?: {
data?: Iterable<Iterable<TableCell>>;
// ... table-level style/layout options
});
table.row(row: Iterable<TableCell>, lastRow?: boolean): this | PDFDocument;
table.end(): PDFDocument;
PDFTable renders a structured table into the document. Pass data for a single-call approach, or call .row() incrementally and finalize with .end(). Returns this for chaining unless lastRow is true.
Creates a single-page PDF with a title, line of text, and saves it to disk using Node.js streams.
import PDFDocument from './src/pdfkit/document.js';
import { createWriteStream } from 'fs';
const doc = new PDFDocument({
size: 'A4',
margin: 50,
info: { Title: 'Invoice #1001', Author: 'Acme Corp' },
});
const stream = createWriteStream('invoice.pdf');
doc.pipe(stream);
doc
.fontSize(25)
.text('Invoice #1001', 50, 80)
.moveDown()
.fontSize(12)
.text('Bill To: John Doe')
.text('Amount Due: $250.00')
.moveDown()
.text('Thank you for your business.');
doc.end();
stream.on('finish', () => console.log('invoice.pdf written'));
Loads an OTF font from disk, renders styled text, then draws a filled triangle using path operations.
import PDFDocument from './src/pdfkit/document.js';
import { createWriteStream } from 'fs';
const doc = new PDFDocument({ size: 'LETTER' });
doc.pipe(createWriteStream('graphics.pdf'));
// Embed font
doc
.font('./fonts/Roboto-Bold.ttf')
.fontSize(20)
.text('Vector Graphics Demo', 100, 60);
// Draw filled triangle
doc
.save()
.moveTo(100, 150)
.lineTo(100, 250)
.lineTo(200, 250)
.fill('#E63946');
// Draw SVG path
doc
.restore()
.scale(0.6)
.translate(350, -250)
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
.fill('steelblue', 'even-odd');
doc.end();
Uses PDFTable to render a data table in a single call using the data option.
import PDFDocument from './src/pdfkit/document.js';
import PDFTable from './src/pdfkit/table/index.js';
import { createWriteStream } from 'fs';
const doc = new PDFDocument({ margin: 30 });
doc.pipe(createWriteStream('table.pdf'));
new PDFTable(doc, {
data: [
[{ value: 'Product', bold: true }, { value: 'Qty', bold: true }, { value: 'Price', bold: true }],
[{ value: 'Widget A' }, { value: '3' }, { value: '$9.00' }],
[{ value: 'Widget B' }, { value: '5' }, { value: '$25.00' }],
],
});
doc.end();
Creates an encrypted PDF using AES (PDF 1.7) with user and owner passwords.
import PDFDocument from './src/pdfkit/document.js';
import { createWriteStream } from 'fs';
const doc = new PDFDocument({
pdfVersion: '1.7',
userPassword: 'open123',
ownerPassword: 'admin456',
permissions: {
printing: 'highResolution',
copying: false,
modifying: false,
},
});
doc.pipe(createWriteStream('secure.pdf'));
doc.fontSize(14).text('This document is encrypted.', 100, 100);
doc.end();
document.js — Instantiates and orchestrates the full PDF document; applies all mixins; manages pages and the output stream.page.js — Represents a single PDF page, its media box, content stream, and resource dictionaries.font.js / font_factory.js — Coordinate font loading (standard 14 or embedded), metrics resolution, and PDF font resource registration.image.js — Detects JPEG vs. PNG and delegates to the appropriate parser in image/.line_wrapper.js — Implements line-breaking via the linebreak package with column, indent, ellipsis, and soft-hyphen support.gradient.js — Builds PDF Function-based linear and radial gradient shading objects.pattern.js — Implements PDF tiling patterns for repeating fill textures.path.js — Parses SVG path d attribute strings and translates commands to PDF path operators.security.js — Handles PDF encryption setup (RC4 v2/4, AES v5), key generation (MD5/SHA-256), and permission flags.metadata.js — Serializes XMP metadata into a PDF stream for standards compliance.outline.js — Manages the PDF outline (bookmark) tree structure.object.js — Serializes JavaScript values to PDF syntax (dicts, arrays, strings, names).reference.js — Represents and serializes PDF indirect objects with their byte offsets.abstract_reference.js — Shared interface for direct and indirect reference types.name_tree.js / number_tree.js — PDF name and number tree builders for efficient lookup tables.tree.js — Generic balanced-tree helper used by name/number trees.data.js / binary.js — Low-level byte buffer and binary stream wrappers.utils.js — Numeric precision helper PDFNumber and miscellaneous utilities.virtual-fs.js — Filesystem abstraction layer allowing font/image loading in both Node.js and browser environments.spotcolor.js — Adds PDF Separation (spot) colorspace support.structure_element.js / structure_content.js / structure_annotation.js — Tagged PDF logical structure tree elements for accessibility.crypto/ — Self-contained implementations of AES-CBC/ECB, MD5, RC4, SHA-256, and CSPRNG (no Node.js crypto dependency required).font/afm.js — Parses Adobe Font Metrics for the 14 standard PDF fonts. font/embedded.js — Subsets and embeds TTF/OTF fonts via fontkit. font/standard.js — Resolves standard font names.image/jpeg.js / image/png.js — Extract image dimensions, color space, and raw data from JPEG and PNG buffers.mixins/ — Each file adds a capability group to PDFDocument: text.js (text drawing), vector.js (paths/shapes), color.js (fill/stroke), fonts.js (font selection), images.js (image embedding), annotations.js (links/notes), acroform.js (form fields), table.js (table API), outline.js (bookmarks), metadata.js (XMP), markings.js (marked content), pdfa.js/pdfua.js (standards compliance), attachments.js (file attachments), subsets.js (font subsetting), security.js-adjacent helpers.saslprep/ — Implements RFC 4013 SASLprep profile for normalizing PDF passwords before hashing.table/ — index.js exports PDFTable; normalize.js canonicalizes cell options; size.js measures columns/rows; render.js draws borders and content; style.js resolves inherited styles; accessibility.js adds table structure tags; utils.js provides table helpers.import/export. If your project uses require(), add "type": "module" to package.json or transpile with Babel/esbuild; mixing syntaxes without a bundler will throw SyntaxError.Buffer not defined in browser: PDFKit relies on Node.js Buffer. Fix: add the buffer polyfill in your bundler config (e.g. resolve.fallback: { buffer: require.resolve('buffer/') } in webpack).fontkit peer resolution: fontkit must be installed separately (npm install fontkit); it is not bundled in this source and its absence causes silent failures when embedding non-standard fonts.saslprep: The security.js module calls saslprep for password processing; if the saslprep/ directory is missing or excluded from your bundle, encrypted PDFs will fail to generate.png-js for indexed/transparent PNGs: Standard PNG parsing via png-js is required for indexed PNGs and PNGs with alpha channels; omitting it means only JPEG images will embed correctly.font/embedded.js performs subsetting via fontkit. Ensure your bundler does not tree-shake fontkit's glyph layout internals, or subsetting will produce corrupt font streams.I have dropped the PDFKit library source (pdfkit@0.18.0) into `src/pdfkit/` in my project.
The integration guide is in `USAGE.md`. Please help me integrate it step by step.
Context:
- Source root: src/pdfkit/
- Entry point: src/pdfkit/document.js (default export: PDFDocument)
- Table API: src/pdfkit/table/index.js (default export: PDFTable)
- Upstream package: user@example.com
- Runtime deps already installed: @noble/ciphers, @noble/hashes, fontkit, linebreak, png-js
Tasks:
1. Wire up PDFDocument so I can generate a PDF and pipe it to an Express response stream.
2. Add a route that accepts JSON invoice data and returns a downloadable PDF.
3. Embed a custom TTF font from the `fonts/` directory.
4. Render a data table using PDFTable with headers and row data from the request body.
5. Optionally add password protection using the pdfVersion and userPassword options.
Please read USAGE.md for real import paths, working code examples, and known pitfalls before writing any code.
Do not use the npm pdfkit package — import directly from src/pdfkit/document.js.
PDFKit is released under the MIT License. See source/LICENSE if present, or refer to the upstream repository and the npm package page for the full license text and attribution. Credit: originally authored by Devon Govett and maintained by the Foliojs contributors.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
完全なインストールガイドと統合プロンプトは購入後に解放されます。
Automation, Utilities & Developer Tools
$4