Get your API key
How to convert PDF to PNG (high quality, free)

How to convert PDF to PNG (high quality, free)

Convert PDF pages to high-resolution PNG images online, with Python, Node.js, or command line. Includes DPI tips for print-ready output.

7 min read

Converting a PDF to PNG is useful for dozens of reasons: embedding a PDF page in a presentation, creating thumbnails for document previews, extracting diagrams for documentation, or printing individual pages at a specific resolution. Here's how to do it in every common environment.

Method 1: Browser tool (instant, no upload)

The fastest way, your PDF never leaves your device:

  1. Go to PDF to PNG
  2. Upload your PDF
  3. All pages are rendered as PNGs automatically
  4. Download individual pages or all at once as a zip

The tool renders at 150 DPI by default, which is crisp for screens. Good enough for most uses.

Method 2: Python with pdf2image

pdf2image wraps Poppler and is the most popular Python approach:

pip install pdf2image
# Also requires Poppler, install with:
# macOS:  brew install poppler
# Ubuntu: apt install poppler-utils
from pdf2image import convert_from_path
 
# Convert all pages at 150 DPI
images = convert_from_path('document.pdf', dpi=150)
 
for i, img in enumerate(images):
    img.save(f'page_{i+1}.png', 'PNG')
 
print(f'Converted {len(images)} pages')

High-resolution for print (300 DPI):

images = convert_from_path('document.pdf', dpi=300)
 
for i, img in enumerate(images):
    img.save(f'page_{i+1}_hires.png', 'PNG')

Convert only specific pages:

# Pages 2 and 3 only (first_page and last_page are 1-indexed)
images = convert_from_path('document.pdf', dpi=150, first_page=2, last_page=3)

Transparent background (useful for logos and letterheads with white backgrounds):

from pdf2image import convert_from_path
from PIL import Image
 
images = convert_from_path('logo.pdf', dpi=300, fmt='png',
                           transparent=True)
images[0].save('logo.png', 'PNG')

Method 3: Node.js with pdfjs-dist

PDF.js (the same library browsers use) works in Node.js:

npm install pdfjs-dist canvas
import { getDocument } from 'pdfjs-dist/legacy/build/pdf.mjs';
import { createCanvas } from 'canvas';
import fs from 'fs';
 
async function pdfToPng(pdfPath, dpi = 150) {
  const scale = dpi / 72; // PDF coordinates use points: 1 point = 1/72 inch (ISO 32000 spec)
  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;
 
    const buffer = canvas.toBuffer('image/png');
    fs.writeFileSync(`page_${i}.png`, buffer);
    console.log(`Rendered page ${i} at ${dpi} DPI`);
  }
}
 
await pdfToPng('document.pdf', 150);

Method 4: Command line with Poppler (pdftoppm)

The fastest batch method for scripts:

# Convert all pages to PNG at 150 DPI
pdftoppm -png -r 150 document.pdf page
 
# Output: page-1.png, page-2.png, ...
 
# 300 DPI for print-ready output
pdftoppm -png -r 300 document.pdf page_hires
 
# Convert only page 3
pdftoppm -png -r 150 -f 3 -l 3 document.pdf page

Install Poppler:

# macOS
brew install poppler
 
# Ubuntu / Debian
apt install poppler-utils

Using ImageMagick + Ghostscript

# Single page
convert -density 150 document.pdf[0] page_1.png
 
# All pages
convert -density 150 document.pdf page_%d.png
 
# With transparent background
convert -density 150 -background none document.pdf[0] page_1.png

Note: ImageMagick's PDF support requires Ghostscript installed. On modern systems you may need -density before the input path.

Method 5: Playwright (server-side, any OS)

If you already use Playwright for PDF generation, you can use it for rendering screenshots too:

import { chromium } from 'playwright';
import fs from 'fs';
 
async function pdfPageToScreenshot(pdfPath, pageIndex = 0) {
  // Serve the PDF locally or embed as data URL
  const pdfBytes = fs.readFileSync(pdfPath);
  const base64 = pdfBytes.toString('base64');
  const dataUrl = `data:application/pdf;base64,${base64}`;
 
  const browser = await chromium.launch();
  const page = await browser.newPage();
 
  await page.goto(dataUrl);
  await page.waitForLoadState('networkidle');
 
  const screenshot = await page.screenshot({ fullPage: true });
  fs.writeFileSync('page.png', screenshot);
  await browser.close();
}

This is generally slower than pdftoppm but works without native Poppler dependencies.

DPI guide: which resolution to use

300 DPI is the professional print standard for crisp, sharp output at normal viewing distance. Web displays typically run at 72–96 DPI, a convention dating back to early Macintosh monitors and still reflected in most screen environments today.

Use caseRecommended DPINotes
Web / screen display72–96 DPISmall files, fast to load
App thumbnails100–150 DPIGood balance of size and clarity
Standard print300 DPIMinimum for professional printing
High-quality print600 DPILarge files, use only when needed
Large-format print150 DPIFor banners/posters at viewing distance

PNG vs JPG for PDF conversion

Choose PNG when:

  • The PDF has text, sharp lines, or diagrams (PDF is vector-heavy)
  • You need transparency (e.g. logos on white background)
  • You'll be editing the image further
  • File size is not a constraint

Choose JPG when:

  • The PDF contains photos
  • You need smaller file sizes for web embedding
  • Transparency is not required

For most PDF conversions, PNG is the right default, PDFs often have sharp edges that JPG's compression algorithm blurs.

Building a document preview workflow

If you're building an application that generates PDFs (invoices, reports, certificates) and needs to display image previews, the workflow is: generate PDF via API → convert to PNG for display.

// Step 1: generate the PDF
async function generateAndPreview(templateId, data) {
  const pdfResponse = 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 pdfResponse.arrayBuffer();
 
  // Step 2: convert first page to PNG for a preview 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 equivalent
 
  const canvas = document.createElement('canvas');
  canvas.width = viewport.width;
  canvas.height = viewport.height;
  await page.render({ canvasContext: canvas.getContext('2d'), viewport }).promise;
 
  return {
    pdf: pdfBytes,
    preview: canvas.toDataURL('image/png'),
  };
}

This pattern is common in document management systems: store the PDF as the canonical format, display PNG thumbnails in the UI. The PDF4.dev API handles rendering quality; the PNG conversion handles display performance.

Batch convert a folder of PDFs

# Using pdftoppm, converts every PDF in current folder
for pdf in *.pdf; do
  name="${pdf%.pdf}"
  pdftoppm -png -r 150 "$pdf" "${name}_page"
done
import 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}.png', 'PNG')
        print(f'Converted {filename}: {len(images)} pages')

FAQ

Why do my PNGs look blurry?

You're likely using too low a DPI. Try 150 DPI for screen use, 300 for print. The default DPI for many tools is 72 (PDF native), which looks small and blurry on modern displays.

Can I convert only specific pages?

Yes, all methods above support page range selection. See the first_page/last_page params in pdf2image, or the -f/-l flags in pdftoppm.

What's the output size at 300 DPI for an A4 page?

An A4 page (210 × 297 mm = 8.27 × 11.69 inches) at 300 DPI produces an image of 2480 × 3508 pixels. At 150 DPI it's 1240 × 1754 pixels. The math: 8.27 × 300 = 2481px, 11.69 × 300 = 3507px (rounded to the nearest even number by most tools).

Is the output lossless?

Yes. PNG is a lossless format. The conversion from PDF vector/text to pixels involves rasterization (which is lossy by nature), but the PNG file itself does not add further compression artifacts.

Can I convert password-protected PDFs?

Not without the password. Unlock the PDF first, then convert.

Free tools mentioned:

Pdf To PngTry it free

Frequently asked questions

How do I convert a PDF to PNG for free?
Use the PDF4.dev PDF to PNG tool, which converts pages entirely in your browser without uploading files.
What resolution should I use when converting PDF to PNG?
150 DPI is good for web use. Use 300 DPI for print-ready output. Higher DPI produces larger files.
Can I convert a multi-page PDF to multiple PNG files?
Yes. The tool exports one PNG per page and lets you download all images at once.
Is PNG or JPG better for PDF conversion?
PNG is better for PDFs with text and sharp lines because it is lossless. JPG is better for photo-heavy PDFs where file size matters more than sharpness.
How long does PDF to PNG conversion take?
A typical 10-page PDF converts in 5-15 seconds in the browser. Processing time scales with page count and resolution.

Start generating PDFs

Build PDF templates with a visual editor. Render them via API from any language in ~300ms.