How mozilla/pdfjs-dist works
Project type and purpose
• PDF.js is an open-source JavaScript library for parsing and rendering PDF files in web and Node environments.
• It targets both modern platforms (ES6+) and legacy environments (see legacy/).
• The distribution includes a pre-built package (build/), a modular source tree (lib/), CMap assets, image decoders, web viewer UI, and TypeScript definitions.
File structure
• Top-level directories:
– build/ → pre-built bundles (pdf.js, pdf.worker.js, sandbox, maps)
– cmaps/ → binary CMap files for character mapping
– image_decoders/ → JPEG, JPX, JBIG2 decoders
– legacy/ → ES5-compatible builds and web viewer
– lib/ → modular source code split into core, display, shared, examples, tests
– standard_fonts/ → built-in Type 1 fonts
– types/ → .d.ts definitions mirroring lib/ structure
– web/ → standalone web viewer assets
– webpack.js → build configuration
• lib/core: PDF parsing, decryption, font & stream handling, XFA support
• lib/display: rendering layers (canvas, SVG, text, annotations), network and worker orchestration
• lib/shared: cross-cutting utilities (message handler, compatibility, hashing)
• Worker model: pdf.worker.js offloads parsing and operator list creation
README
• Confirms HTML5-based, standards-compliant PDF parser & renderer
• Mentions modern vs. legacy builds (legacy/)
• Points to NPM packaging (pdfjs-dist)