When you prepare print books for Amazon KDP, two small mistakes cause the majority of rejections:

  1. Page-count drift after a last-minute edit silently breaks paperback spine width by 0.02–0.05 inches.
  2. Unembedded fonts, Type 3 fonts, or wrong trim boxes slip through until KDP's print RIP rejects the interior PDF.

Most online checkers ask you to upload unreleased client manuscripts to a third-party server. I wanted a 100% browser-local, single-file MIT utility with zero dependencies, zero build step, and zero network uploads — something you can open on GitHub Pages or double-click offline.

5 Real-World PDF Traps We Hit (and Fixed in v1.2)

Building a browser-local PDF inspector without shipping a multi-megabyte library taught us five practical lessons fast:

1. Do NOT decode the whole PDF into a JS string

Decoding a 95 MB PDF via TextDecoder("latin1") into a single JavaScript string doubles memory in UTF-16 and spikes the heap by hundreds of megabytes.

Instead, we scan stream / endstream boundaries directly on the raw Uint8Array, decoding only the structural dictionary bytes between streams. Result on a synthetic 95 MB PDF: 413 ms runtime and +0.1 MB heap delta, without even needing a Blob Web Worker (so opening index.html locally via file:// still works).

2. Check TrimBox before MediaBox

Thanks to pre-press feedback from Ignacio Ferro Picón (building Postext), we caught a subtle PDF/X-1a and PDF/X-4 trap: full-bleed files often have a larger MediaBox (for bleed or crop marks) while the true trimmed book size lives in TrimBox.

v1.2 reads TrimBox first, falls back to MediaBox, applies /Rotate 90/270 swaps, resolves indirect references (12 0 R), and detects mixed page sizes across the document.

3. Chrome/Skia B-tree /Pages trap

PDFs generated by headless Chrome or WeasyPrint split the page tree into intermediate /Type /Pages branch nodes (each showing /Count 8). Naively grabbing the first /Pages /Count reports 8 pages for a 90-page book. Following /Catalog -> /Pages -> /Count (with indirect reference resolution and leaf /Type /Page fallback) fixes it cleanly.

4. Compressed /ObjStm streams + DecompressionStream error handling

Modern PDF 1.5+ files pack dictionaries inside /Type /ObjStm /FlateDecode streams. Native DecompressionStream("deflate") handles them with zero dependencies — but remember to attach .catch(() => null) directly to new Response(stream).arrayBuffer(), because a synchronous try/catch will not catch stream-decompression rejections, and always slice each stream's dictionary strictly from its own N 0 obj header so adjacent objects never bleed into each other.

5. Real font-stream & UTF-8 byte checks

  • Fonts: Checking /FontDescriptor alone is not enough — v1.2 verifies actual non-zero byte length between stream and endstream for FontFile / FontFile2 / FontFile3, follows Type0 CID descendants, decodes #20 hex names, and flags KDP-rejected Type3 fonts.
  • Keywords: Amazon KDP caps each of the 7 backend keyword boxes at 50 UTF-8 bytes, not 50 characters (ó, é, ñ consume 2 bytes each). TextEncoder catches silent truncation before upload, paired with a stack-based HTML validator for KDP's sanctioned tags (h4–h6, p, br, b, i, u, ol, ul, li, em).

Try Breaking It

Drop a real InDesign, Affinity, LaTeX, or WeasyPrint interior PDF into the sidebar (nothing leaves your browser) and open an issue or comment below if any edge case trips it up:

Built by **Velvet Studio* — KDP Print Pre-Flight, Amazon A+ visual systems, and white-label publishing tools (Studio Showcase · 3-Page Studio Dossier PDF · Live KDP Portfolio).*