Notes on streaming PDFs
Engineering deep-dives, specification notes, and performance lessons from building the fastest online PDF reader.
Edit
Convert
Security
Engineering deep-dives, specification notes, and performance lessons from building the fastest online PDF reader.
Articles tagged “Specification”
A guided tour of PDF.js internals, from architecture to rendering.
A file-by-file walkthrough of the PDF.js source tree.

PDF.js PartialEvaluator source code walkthrough.
October 25, 2026 · StreamPDF Team

A source code walkthrough of the PDF.js PDFDocument and Page classes.
October 26, 2026 · StreamPDF Team

PDF.js CanvasGraphics source code walkthrough.
October 26, 2026 · StreamPDF Team

PDF.js XRef source walkthrough: cross-reference tables, xref streams, object streams, and how objects are located and retrieved.
October 26, 2026 · StreamPDF Team

A source code walkthrough of the PDF.js Lexer and Parser: tokenize byte by byte, then assemble tokens into PDF objects by recursive descent.
October 26, 2026 · StreamPDF Team

PDF.js BaseStream source walkthrough: the byte-stream abstraction contract, lookahead and multi-byte reads, cursor control, derived streams and async decoding capabilities.
October 27, 2026 · StreamPDF Team

PDF.js Stream source walkthrough: the start/pos/end triple of pointers, zero-copy subarray views, substreams and clones, plus the StringStream and NullStream subclasses.
October 27, 2026 · StreamPDF Team

PDF.js ChunkedStream and ChunkedStreamManager source walkthrough: chunked buffering, Range request merging, retry on missing data, and streaming prefetch.
October 27, 2026 · StreamPDF Team

PDF.js DecodeStream source walkthrough: output buffer growth, lazy reading, asynchronous image decoding, and the shared base for stitching multiple streams together.
October 27, 2026 · StreamPDF Team

PDF.js FlateStream source walkthrough: zlib header validation, bit buffering, Huffman table generation, the three DEFLATE block types and LZ77 back-references.
October 27, 2026 · StreamPDF Team

PDF.js PredictorStream source walkthrough: TIFF and PNG row predictors, the five filter formulas, row-buffer reuse and truncation handling.
October 27, 2026 · StreamPDF Team

PDF.js LZWStream source walkthrough: 9-bit variable-length codes, a three-array dictionary, the earlyChange widening point, and the KwKwK special case.
October 27, 2026 · StreamPDF Team

PDF.js Ascii85Stream source walkthrough: five-character groups, the z shortcut for zero groups, whitespace skipping, and padding for a short final group.
October 27, 2026 · StreamPDF Team

PDF.js AsciiHexStream source walkthrough: bitwise decoding of hexadecimal text into bytes, nibble state across block boundaries, and end-marker handling.
October 27, 2026 · StreamPDF Team

PDF.js RunLengthStream source walkthrough: the two run semantics of the header byte, bulk fills, and buffer accumulation across blocks.
October 27, 2026 · StreamPDF Team

PDF.js BrotliStream source walkthrough: an async fast path over the browser DecompressionStream first, falling back to the bundled external/brotli decoder on whole-buffer failure.
October 27, 2026 · StreamPDF Team

PDF.js DecryptStream source walkthrough: 512-byte chunks, a lookahead that detects the last chunk, the final flag, and stream identity at the decryption layer.
October 27, 2026 · StreamPDF Team

PDF.js JpegStream source walkthrough: how DCTDecode restores JPEG pixels through both JpegImage and the browser ImageDecoder path.
October 27, 2026 · StreamPDF Team

PDF.js Jbig2Stream source walkthrough: JBIG2Decode file-header stripping, global-segment merging, and the asynchronous WASM decoding chain.
October 27, 2026 · StreamPDF Team

PDF.js JpxStream source walkthrough: whole-image JPEG 2000 decoding, lazy byte reads, and the bridge to an asynchronous WASM decoder.
October 27, 2026 · StreamPDF Team

PDF.js CCITTFaxStream source walkthrough: normalizing fax-encoding parameters, the K-value group semantics, and delegation to a WASM decoder.
October 27, 2026 · StreamPDF Team

PDF.js worker byte-stream adapter source walkthrough: how PDFWorkerStream carries display-layer network chunks into the Worker through the message protocol.
October 27, 2026 · StreamPDF Team

PDF.js primitives source walkthrough: interning Name and Cmd, dereferencing and merging Dict, caching Ref strings, and the reference sets RefSet and RefMap.
October 27, 2026 · StreamPDF Team

PDF.js core_utils source walkthrough: the shared toolbox of exception families, inheritance chains, escaping, action collection and XML encoding.
October 27, 2026 · StreamPDF Team

A walkthrough of PDF.js crypto.js: the standard security handler, RC4 and AES cipher implementations, password validation, object key derivation, and the streaming decryption dispatch chain.
October 27, 2026 · StreamPDF Team

PDF.js obj_bin_transform_core source walkthrough: compiling fonts, system fonts, patterns and glyph paths into transferable binary data for the worker boundary.
October 27, 2026 · StreamPDF Team

PDF.js object_loader source walkthrough: how ObjectLoader walks an object graph iteratively and batches every missing byte range into one request.
October 27, 2026 · StreamPDF Team

PDF.js pdf_manager source walkthrough: how BasePdfManager unifies document data access across an in-memory byte array and chunked network downloads.
October 27, 2026 · StreamPDF Team

How the PDF.js Catalog turns the /Root dictionary into a document model of page trees, name trees, outlines, attachments and forms.
October 27, 2026 · StreamPDF Team

PDF.js struct_tree source walkthrough: StructTreeRoot, ParentTree, per-page structure tree serialization, and the accessibility contract shared with the main thread.
October 27, 2026 · StreamPDF Team

A PDF.js walkthrough of the NameTree and NumberTree implementation: node traversal, Limits binary search, lazy dereferencing, and cycle protection.
October 27, 2026 · StreamPDF Team

A PDF.js walkthrough of XMP metadata parsing: repairing malformed text, the SimpleXMLParser state machine, rdf:Description traversal, and the flattened Map result.
October 27, 2026 · StreamPDF Team

A PDF.js walkthrough of default appearance handling: parsing font size and color operators from the /DA string, evaluating appearance streams, and generating a FakeUnicodeFont.
October 27, 2026 · StreamPDF Team

Shared utilities of the PDF.js font layer: FontFlags, the standard Mac glyph order, glyph-name recovery, Type1 character mapping, font-name normalisation, vertical presentation forms and Type3 bitmap compilation.
October 27, 2026 · StreamPDF Team

The standard font data layer of PDF.js: the standard 14 font aliases, substitute font mappings, the serif and symbol name sets, and the CID to glyph maps used when a font has no embedded file.
October 27, 2026 · StreamPDF Team

The core 14 font metric tables of the PDF.js font layer: where glyph widths, ascent and descent come from, and how they meet the fontMatrix conversion at 1/1000 em.
October 27, 2026 · StreamPDF Team

The single-byte encoding surface of PDF.js: seven 256-entry encoding tables, the char code to glyph name mapping, and how getEncoding divides work with CMap and ToUnicode.
October 27, 2026 · StreamPDF Team

How the PDF.js CMap translates character codes into CIDs or Unicode: codespaces, bf/cid ranges, useCMap chains and the built-in mapping factory.
October 27, 2026 · StreamPDF Team

How the PDF.js BinaryCMapReader uses big-endian bytes, varints and delta encoding to decode the codespaces and bf/cid mappings of built-in CMaps.
October 27, 2026 · StreamPDF Team

PDF.js glyphlist turns glyph names into Unicode through two lazily built tables, and explains who covers the gap when a lookup fails.
October 27, 2026 · StreamPDF Team

The core of the PDF.js font layer: how Font dispatches by type, repairs TrueType, wraps Type1/CFF, and builds ToUnicode plus the glyph caches.
October 27, 2026 · StreamPDF Team

A source walkthrough of api.js, the display-layer entry point of PDF.js: getDocument's one-shot parameter expansion, PDFWorker's test handshake and fake-worker fallback, WorkerTransport's message routing table, PDFPageProxy's intentState state machine, and RenderTask's scheduling loop.
October 27, 2026 · StreamPDF Team

A source walkthrough of MessageHandler, PDF.js cross-thread message hub: three message shapes (fire-and-forget / request-reply / streaming), the three-layer envelope protocol, and the StreamKind state machine with bidirectional backpressure built on ReadableStream.
October 27, 2026 · StreamPDF Team

A source walkthrough of PDF.js shared utilities: specification constants, typed exceptions, URL validation, binary strings, cached feature detection, affine geometry, destination validation, and runtime compatibility shims.
October 27, 2026 · StreamPDF Team

A source-level walkthrough of BasePDFStream: the single full reader, conditional range readers, headersReady metadata, abstract read/cancel contracts, cancellation semantics, and how fetch, XHR, Node.js, and push transports fulfill them.
October 27, 2026 · StreamPDF Team

A source-level walkthrough of PDF.js image_utils.js: ImageKind dispatch, 1-bit mask expansion, packed RGB-to-RGBA conversion, grayscale replication, endian-aware Uint32 writes, and the real canvas and decoder call sites.
October 27, 2026 · StreamPDF Team

PDF.js obj_bin_transform_utils source walkthrough: the shared field-order and byte-offset schema for font and pattern buffers, plus the lazy UTF-8 codecs used by the worker writer and main-thread reader.
October 27, 2026 · StreamPDF Team

PDF.js MurmurHash3_64 source walkthrough: seed initialization, string and TypedArray normalization, alternating 32-bit lanes, tail-block mixing, the finalized 16-digit digest, and real internal uses.
October 27, 2026 · StreamPDF Team

PDF.js scripting_utils source walkthrough: the exact ColorConverters exports, normalized and 0–255 component contracts, HTML color formatting, transparent sentinels, and index-based Acrobat date/time presets.
October 27, 2026 · StreamPDF Team

A source walkthrough of PDF.js css_utils.js: how control-character checks, CSS string recognition, and font-family serialization keep PDF-originated names safe across FontFace, @font-face, and XFA style boundaries.
October 27, 2026 · StreamPDF Team

A focused source walkthrough of PDF.js MathClamp: inclusive boundary behavior, NaN and reversed-bound semantics, real callers from sampled functions to editor geometry, and why this temporary compatibility helper has its own module.
October 27, 2026 · StreamPDF Team

A source walkthrough of PDF.js internal_evt.js: build-time UUID injection, the frozen internalOpt capability, mirrored library and viewer modules, and how EventBus separates internal listeners from external delivery order.
October 27, 2026 · StreamPDF Team

A source walkthrough of the PDF.js data supply layer: the reader contract of BasePDFStream, the four implementations (fetch/XHR/Node/push), the five-gate validation behind range support, where the 64KB rangeChunkSize actually takes effect, and how the GetReader/GetRangeReader messages pump bytes into the worker.
October 27, 2026 · StreamPDF Team

A source walkthrough of PDFObjects, the main-thread object-readiness coordinator in PDF.js: the INITIAL_DATA three-state model, Promise.withResolvers entries, the dual synchronous/callback get contract, document-level and page-level stores, render dependency suspension, and ImageBitmap cleanup.
October 27, 2026 · StreamPDF Team

PDF.js source walkthrough: decoding commonobj ArrayBuffers into fonts, patterns, and glyph paths, including field offsets, byte order, on-demand getters, and clearData memory release.
October 27, 2026 · StreamPDF Team

The complete main-thread font loading path in PDF.js: FontFace registration, system fonts, legacy load detection, glyph path caching, and CanvasGraphics consumption.
October 27, 2026 · StreamPDF Team

A PDF.js TextLayer source walkthrough: how streamTextContent/getTextContent data becomes a transparent DOM text layer aligned with Canvas glyphs, providing structure for selection, copying, search, and accessibility.
October 27, 2026 · StreamPDF Team