1.1.0

Architecture

Last updated


This page gives a one-diagram overview of pdf2image: dependency injection on load, the public pdf2image class, the internal progress overlay, and the CDN libraries they rely on.

System Overview


graph TB
    subgraph On load
        Boot[Bootstrap IIFE] --> Inject[Inject preconnect / preload / script / stylesheet]
    end
    subgraph CDN
        PDFJS[pdf.js 3.4.120 + worker + CMap]
        JSZip[JSZip 3.7.1]
        CSS[pdf2image.css @latest]
    end
    Inject --> PDFJS
    Inject --> JSZip
    Inject --> CSS
    App[Caller] --> Class[pdf2image]
    Class -->|convert| PDFJS
    PDFJS --> Canvas[canvas.toDataURL]
    Canvas --> Images[images array]
    Class -->|download| JSZip
    Images --> JSZip
    JSZip --> Anchor[a download click]
    Class --> Loading[pdf2imageLoading overlay]
    CSS --> Loading
  1. graph TB
  2. subgraph On load
  3. Boot[Bootstrap IIFE] --> Inject[Inject preconnect / preload / script / stylesheet]
  4. end
  5. subgraph CDN
  6. PDFJS[pdf.js 3.4.120 + worker + CMap]
  7. JSZip[JSZip 3.7.1]
  8. CSS[pdf2image.css @latest]
  9. end
  10. Inject --> PDFJS
  11. Inject --> JSZip
  12. Inject --> CSS
  13. App[Caller] --> Class[pdf2image]
  14. Class -->|convert| PDFJS
  15. PDFJS --> Canvas[canvas.toDataURL]
  16. Canvas --> Images[images array]
  17. Class -->|download| JSZip
  18. Images --> JSZip
  19. JSZip --> Anchor[a download click]
  20. Class --> Loading[pdf2imageLoading overlay]
  21. CSS --> Loading

Layers


LayerComponentResponsibility
LoadBootstrap IIFEAttaches pdf.js, JSZip, and the stylesheet to <head>
Public APIpdf2image classNormalizes options; convert(), download(), images
Internal UIpdf2imageLoadingCreates and updates the progress overlay, switching labels by locale
External dependenciespdf.js, JSZip, browser APIsParse and render the PDF, build the ZIP, trigger the download

Cross-Cutting Principles


  • No bundled dependencies: all third-party code is fetched from CDNs at runtime, so the package itself is one small file
  • Client-side only: the PDF never leaves the browser, and there is no server component
  • Single entry point: pdf2image is the only public class; pdf2imageLoading is not exposed
  • Browser-side rendering, Data URL output: pdf2pic needs Node.js plus GraphicsMagick and Ghostscript, and pdf-to-img converts PDFs in Node.js; both suit servers and build scripts. pdf-img-convert, like pdf2image, is built on pdf.js, but returns PNG Uint8Array buffers from an npm module. pdf2image runs in the visitor's page and returns Data URLs that drop straight into <img src>, with its own progress overlay and ZIP download

Further Reading


中文