With over 2.5 trillion PDFs in existence and approximately 290 billion created every year, PDF is the dominant document format. But PDFs aren't always the best format for sharing: you can't embed a PDF page in a slide deck, preview it on social media, or use it as a CMS thumbnail. Converting PDF to JPG solves this. JPEG is used on roughly 78% of websites and accepted by every platform, email client, and device. Here's how to do it across every environment.
Method 1: browser tool (instant, no upload)
The fastest approach, and your files never leave your device:
- Go to PDF to JPG
- Upload your PDF
- Choose quality: Low (60%), High (85%), or Maximum (100%)
- All pages are rendered as JPGs
- Download individual pages
The tool runs entirely in your browser using pdfjs-dist for rendering. No server upload, no file retention, no privacy concerns. This matters: the FBI issued an official warning in March 2025 about criminals using free online document converters to install malware and steal personal data. Malwarebytes confirmed that specific fake converter sites distributed ransomware through Google Ads. Even MIT's IT department advises against using online converters for institutional documents.
Method 2: Python with pdf2image
pdf2image wraps Poppler and is the most popular Python approach:
pip install pdf2image
# Also requires Poppler:
# macOS: brew install poppler
# Ubuntu: apt install poppler-utilsfrom pdf2image import convert_from_path
# Convert all pages at 150 DPI, save as JPEG
images = convert_from_path('document.pdf', dpi=150, fmt='jpeg')
for i, img in enumerate(images):
img.save(f'page_{i+1}.jpg', 'JPEG', quality=85)
print(f'Converted {len(images)} pages')Control JPEG quality:
# High quality (larger files)
img.save('page.jpg', 'JPEG', quality=95)
# Low quality (smaller files, good for thumbnails)
img.save('page.jpg', 'JPEG', quality=60)
# Maximum quality (no additional compression)
img.save('page.jpg', 'JPEG', quality=100)Convert specific pages only:
# Pages 2 and 3 (1-indexed)
images = convert_from_path('document.pdf', dpi=150, first_page=2, last_page=3)Method 3: Node.js with pdfjs-dist
PDF.js (the same library browsers use) works in Node.js:
npm install pdfjs-dist canvasimport { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs';
import { createCanvas } from 'canvas';
import fs from 'fs';
async function pdfToJpg(pdfPath, dpi = 150, quality = 85) {
const scale = dpi / 72; // PDF uses 72 points per inch (ISO 32000)
const data = new Uint8Array(fs.readFileSync(pdfPath));
const pdf = await getDocument({ data }).promise;
for (let i = 1; i <= pdf.numPages; i++) {
const page = await pdf.getPage(i);
const viewport = page.getViewport({ scale });
const canvas = createCanvas(viewport.width, viewport.height);
const ctx = canvas.getContext('2d');
await page.render({ canvasContext: ctx, viewport }).promise;
// Export as JPEG with quality control
const buffer = canvas.toBuffer('image/jpeg', {
quality: quality / 100,
});
fs.writeFileSync(`page_${i}.jpg`, buffer);
console.log(`Page ${i}: ${(buffer.length / 1024).toFixed(0)} KB`);
}
}
await pdfToJpg('document.pdf', 150, 85);Method 4: command line with Poppler (pdftoppm)
The fastest batch method. Poppler's pdftoppm supports JPEG output natively:
# Convert all pages to JPEG at 150 DPI, quality 85
pdftoppm -jpeg -jpegopt quality=85 -r 150 document.pdf page
# Output: page-1.jpg, page-2.jpg, ...
# 300 DPI for print-ready output
pdftoppm -jpeg -jpegopt quality=95 -r 300 document.pdf page_hires
# Single page (page 3 only)
pdftoppm -jpeg -r 150 -f 3 -l 3 document.pdf pageInstall Poppler:
# macOS
brew install poppler
# Ubuntu / Debian
apt install poppler-utilsUsing ImageMagick + Ghostscript
# Single page at 150 DPI, quality 85
convert -density 150 document.pdf[0] -quality 85 page_1.jpg
# All pages
convert -density 150 document.pdf -quality 85 page_%d.jpgImageMagick's PDF support requires Ghostscript installed. Use
-densitybefore the input path.
JPEG quality guide
JPEG quality is not standardized across tools: "85" in Photoshop is not the same as "85" in Pillow or in a browser canvas. But the general principle holds: quality above 90% adds file size without visible improvement for most images. Going from 100% to 80% typically reduces file size by 60-70% with minimal visible degradation.
| Quality | Best for | Typical file size (A4 at 150 DPI) |
|---|---|---|
| 100% | Archival, maximum fidelity | ~2-4 MB |
| 85% | Default, web, sharing | ~500 KB - 1 MB |
| 60% | Thumbnails, previews | ~200-400 KB |
File sizes are approximate and vary by document content (text-heavy vs. photo-heavy).
The sweet spot is 80-85%. At this range, the quality difference from 100% is nearly invisible to the human eye, but the file is roughly 3-5x smaller.
JPG vs PNG: which format for PDF conversion?
Both formats have legitimate use cases. The choice depends on what's in the PDF and how you'll use the output. For a detailed technical comparison, see MDN's image format guide.
| JPG | PNG | |
|---|---|---|
| Compression | Lossy: some quality lost | Lossless: pixel-perfect |
| File size | Smaller (3-10x vs PNG) | Larger |
| Transparency | Not supported | Supported (alpha channel) |
| Best for | Photos, gradients, sharing | Text, diagrams, screenshots |
| Color depth | 24-bit (8 bits/channel) | Up to 48-bit (16 bits/channel) |
Choose JPG when:
- The PDF contains photos or complex gradients
- File size matters (email attachments, CMS uploads, social media)
- You don't need transparency
- You're generating thumbnails or previews
Choose PNG when:
- The PDF has sharp text, line art, or diagrams
- You need transparency (logos, overlays)
- You'll edit the image further (avoiding generation loss)
- Pixel-perfect accuracy matters more than file size
For most PDF-to-image conversions where sharing or embedding is the goal, JPG is the right choice. For archival or further editing, PNG's lossless compression preserves every detail. See our PDF to PNG guide for the PNG workflow. If your JPGs are still too large for email, run them through PDF compression before converting.
DPI guide: which resolution to use
PDFs are fundamentally vector-based: text and shapes have no inherent resolution, and each embedded raster image has its own DPI. PDF coordinates use 72 points per inch (ISO 32000). When you convert to an image, the DPI setting controls how many pixels each point becomes. Doubling the DPI roughly quadruples the file size since both width and height double.
| Use case | DPI | A4 output size | Notes |
|---|---|---|---|
| Screen / web | 72-96 | 595 x 842 px | Small files, fast loading |
| General use | 150 | 1240 x 1754 px | Good balance of quality and size |
| 300 | 2480 x 3508 px | Professional print standard | |
| Large format | 150 | Varies | Posters/banners viewed from distance |
150 DPI is the best default for most conversions: crisp enough for screens and presentations, small enough to share easily.
Batch convert a folder of PDFs
# Using pdftoppm: all PDFs in current directory
for pdf in *.pdf; do
name="${pdf%.pdf}"
pdftoppm -jpeg -jpegopt quality=85 -r 150 "$pdf" "${name}_page"
doneimport os
from pdf2image import convert_from_path
for filename in os.listdir('.'):
if filename.endswith('.pdf'):
name = filename[:-4]
images = convert_from_path(filename, dpi=150)
for i, img in enumerate(images):
img.save(f'{name}_page_{i+1}.jpg', 'JPEG', quality=85)
print(f'Converted {filename}: {len(images)} pages')Building a document preview system
If your application generates PDFs and needs image previews (for a CMS, dashboard, or email), convert the first page to JPG for display:
async function generatePreview(templateId, data) {
// Step 1: generate the PDF via API
const response = await fetch('https://pdf4.dev/api/v1/render', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.PDF4_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ template_id: templateId, data }),
});
const pdfBytes = await response.arrayBuffer();
// Step 2: render first page as JPG thumbnail
const { getDocument } = await import('pdfjs-dist');
const pdf = await getDocument({ data: pdfBytes }).promise;
const page = await pdf.getPage(1);
const viewport = page.getViewport({ scale: 2 }); // ~150 DPI
const canvas = document.createElement('canvas');
canvas.width = viewport.width;
canvas.height = viewport.height;
await page.render({
canvasContext: canvas.getContext('2d'),
viewport,
}).promise;
// JPG at 85% quality: small file, great for thumbnails
return canvas.toDataURL('image/jpeg', 0.85);
}This is a common pattern in document management systems: store the PDF as the canonical format, display JPG thumbnails in the UI. JPG previews load faster and use less bandwidth than PNG, especially for photo-heavy documents like invoices with logos or certificates with backgrounds.
FAQ
Why do my JPGs look blurry?
Two likely causes: DPI too low or JPEG quality too low. Try 150 DPI with quality 85. The default DPI in many tools is 72, which looks small and blurry on modern high-density displays.
Can I convert password-protected PDFs?
Not without the password. Unlock the PDF first, then convert.
Does converting to JPG reduce file size compared to the PDF?
Usually yes, significantly. A 5 MB PDF with embedded images often converts to JPG pages of 200-500 KB each at 150 DPI / 85% quality. The exception is text-only PDFs, where the rasterized JPG can actually be larger than the original vector PDF.
Can I convert JPG back to PDF?
Yes. Use the Image to PDF tool to combine JPG images back into a PDF document. Note that the result will be a rasterized PDF (images only), not a searchable text PDF.
What about WebP?
WebP offers better compression than JPEG at equivalent quality, but JPG remains the most universally supported format. Every operating system, email client, CMS, and social media platform accepts JPG. If you're optimizing specifically for web performance and browser support is guaranteed, WebP is worth considering.
Start generating PDFs
Build PDF templates with a visual editor. Render them via API from any language in ~300ms.