Tools · Making-of
PDF to JPG & PNG
Turn each page of a PDF into a JPG or PNG. The file never leaves your browser. Pick 72, 150 or 300 dpi, JPG quality and a page range, then save single pages or a ZIP. Password-protected PDFs open once you enter the password.
About this project
What it is
A tool that turns each page of a PDF into a JPG or PNG image: one slide to drop into a chat, a scanned form for a site that only accepts images, a figure from a paper for your own slides. The key point is that your file is never uploaded. Reading and drawing the PDF all happens inside this browser, so documents you would rather not send anywhere, like contracts or ID copies, can be converted as they are.
How to use it
- Drop a PDF onto the page or click the box to choose one. A preview of every page appears.
- Choose JPG or PNG. JPG is far smaller for photos and scans; PNG keeps text-heavy pages and charts sharper.
- Choose 72 dpi (screen), 150 dpi (default, for chat and documents) or 300 dpi (print). The pixel size of page 1 updates as you choose.
- Type a range such as "1-3, 5, 8-" or click previews to pick pages. One page downloads as a single image, several as one ZIP. The Save button under a preview downloads just that page.
- Password-protected PDFs open once you enter the password. The password stays in your browser too.
Data and method
Pages are drawn with pdf.js (3.11.174), Mozilla's open-source PDF engine, and ZIPs are built with JSZip (3.10.1). Both load from a public CDN, along with pdf.js character maps (CMaps) for PDFs that embed CJK fonts. Each page is drawn onto a white canvas at the chosen resolution and saved as JPG or PNG by the browser's own image encoder. The images are already compressed, so the ZIP stores them without compressing again. This page carries the site's shared analytics and ad scripts, but neither your PDF nor the converted images are sent anywhere.
Limits
- Browsers cap how large a single canvas can be (about 16.7 million pixels in iPhone Safari). When a large drawing at 300 dpi exceeds that, the resolution is lowered to fit and you are told.
- Converting hundreds of pages at high resolution can be slow or crash on a phone. Drop to 150 dpi or split the range into several batches.
- Unusual fonts or effects that pdf.js does not support may look slightly different from the original. Transparent backgrounds are filled with white.
- Once a page is an image, its text can no longer be selected or searched. Keep the original PDF.
It started with a question: could the site take a PDF and hand back JPGs or PNGs? Search for that and you get dozens of sites, and nearly all of them upload your file to a server, convert it there and send it back. So I decided to change one thing. The file would never leave your computer.
Drawing without a server
pdf.js, the engine inside Firefox, already draws PDFs well. Draw a page onto a canvas, save the canvas as an image file, and that is the core of it. Resolution is a multiplier on PDF units (72 points to the inch): about 2.08x for 150 dpi and about 4.17x for 300 dpi. An A4 page at 300 dpi comes out at 2480 × 3508 pixels.
iPhone Safari's canvas limit
A large drawing at 300 dpi can need a canvas of hundreds of millions of pixels. iPhone Safari returns a blank image, with no error, once a single canvas passes about 16.7 million pixels. So any page over 16 million pixels is drawn at a smaller scale that fits, and the result message says how many pages were reduced. Each finished canvas is shrunk to zero right away to hand its memory back; without that, converting hundreds of pages in a row kills the phone's tab.
Korean PDFs and passwords
PDFs that do not embed their Korean fonts need pdf.js character maps (CMaps) to show the text correctly. Those load from the same CDN as the library, only when needed. When pdf.js asks for a password, the page asks you in an input box on screen, and asks again in the same box if it is wrong.
The ZIP is not compressed
Several pages are bundled into one ZIP. JPG and PNG are already compressed, so compressing them again inside the ZIP saves almost nothing and costs time; the ZIP simply stores them. File names are the original PDF name plus a three-digit page number, so sorting by name in a file browser keeps the pages in order.