Back to feed
Dev.to
Dev.to
7/19/2026
How to convert a PDF to images entirely in the browser (no upload)

How to convert a PDF to images entirely in the browser (no upload)

Short summary

A practical guide to converting PDFs to images entirely in the browser using Mozilla's pdf.js, with no server upload required. Covers loading pdf.js from CDN, configuring the Web Worker, scaling viewports for correct DPI (150-300), and handling JPG transparency issues by painting a white background. Includes downloadable code snippets and a DPI reference table for choosing the right resolution.

  • Use pdf.js to render PDF pages to canvas and export as PNG/JPG entirely client-side
  • Scale viewport by targetDPI/72 to avoid blurry output; 150 DPI is the sweet spot for most use cases
  • Paint white background before JPG export to prevent transparent pixels turning black

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more