Concept · Rendering PDFs

Render a PDF Page to an Image
PDF to PNG

Sometimes you do not want the document, you want a picture of it: a thumbnail for a list, a preview in a viewer, a flat image to drop into another file. Rendering a PDF page means executing everything the page describes, text, vectors, images, color and transparency, and painting it onto a bitmap. This page explains how that works and shows the one-line call to do it in your language.

Like photographing a page instead of reading it

A PDF is a set of instructions, not a picture. Each page is a program: move here, set this color, stroke this path, show this glyph, draw this image. A PDF viewer follows those instructions and paints the result on your screen. The page you see is not stored as pixels anywhere in the file, it is computed every time the page is opened.

Rendering is the act of running that program yourself and capturing the painted result as a flat raster image. Instead of asking a viewer to show the page, you ask the library to draw it into a bitmap and hand you the pixels. The output is an ordinary PNG: no PDF reader required to look at it, easy to embed, thumbnail, diff or feed into another tool.

A native rasterizer, not a headless browser

Most PDF-to-image stacks shell out to a heavyweight external engine. rust-pdf renders in the same pure-Rust core as everything else.

One library, zero extra dependencies

Pure Rust, deterministic

The renderer is built on tiny-skia, a pure-Rust anti-aliased rasterizer. There is no Chromium, no Ghostscript, no PDFium, no native image codecs to install. It lives inside the same libpdf_ffi the other bindings load, so your deployment stays a single artifact. Output is deterministic: the same page and DPI produce the same pixels every time.

Real glyph outlines, real vectors

Not a rough approximation

Text is painted from the actual glyph outlines in the embedded or CID font, not boxes or substitute shapes. Vector paths are filled and stroked with proper winding rules, line caps, joins and dashes, and clipped exactly. Embedded images, including JPEG and soft masks, are composited through the page transform. Color spaces and axial or radial shadings are resolved, so the raster matches the document.

How a page becomes pixels

Rendering is the reverse of writing a PDF. Where authoring emits content operators, rendering executes them and paints the result.

Parse and interpret

The page content stream is tokenized and its operators executed in order, tracking the graphics state: transform, color, clip, line style and text state.

Paint onto a bitmap

Glyph outlines, vector fills and strokes, images and shadings are drawn into a pixel buffer with anti-aliasing, honoring transparency and blend modes.

Encode the image

The finished bitmap is encoded as a PNG at your chosen DPI, or handed back as raw RGBA pixels if you want to post-process or re-encode it yourself.

When you need to render a PDF to an image

The same one-call API covers previews, exports and visual pipelines.

Page thumbnails

Generate a small preview of the first page for a document list, search result or file picker, straight from the PDF bytes.

Viewer previews

Show a page in a web or desktop app without shipping a full PDF viewer, by rendering each page to an image on demand.

PDF to PNG export

Offer a download that turns a report page into a shareable PNG that anyone can open, with no PDF reader needed.

Visual regression

Render the same page across two builds and diff the pixels to catch unintended layout changes in a generated document.

OCR and vision input

Feed a clean page raster to an OCR engine or vision model when you need the full rendered page, not just the embedded images.

Snapshots in another doc

Drop a flattened picture of a page into a slide, an email or a different document where the live PDF is not wanted.

How to render a PDF page with rust-pdf

Pass the PDF bytes, a zero-based page index and a DPI; get PNG bytes back. Page rendering is a Pro feature, so a license must be active.

# pip install rustpdf  (set RUSTPDF_LICENSE to your Pro token)
import rustpdf

data = open("document.pdf", "rb").read()
png = rustpdf.render_page_to_png(data, page=0, dpi=150.0)
open("page1.png", "wb").write(png)
// dotnet add package RustPdf
using RustPdf;

byte[] data = File.ReadAllBytes("document.pdf");
byte[] png = Pdf.RenderPageToPng(data, pageIndex: 0, dpi: 150.0);
File.WriteAllBytes("page1.png", png);
// go get github.com/rustpdf/rustpdf-go@latest
data, _ := os.ReadFile("document.pdf")
png, _ := rustpdf.RenderPageToPng(data, 0, 150.0)
os.WriteFile("page1.png", png, 0o644)
// npm install rustpdf
const { renderPageToPng } = require("rustpdf");
const fs = require("fs");

const png = renderPageToPng(fs.readFileSync("document.pdf"), 0, 150.0);
fs.writeFileSync("page1.png", png);

The library is available in nine languages: Python, C#/.NET, Go, Node.js, Java, PHP, Ruby, Delphi and Swift. One Rust core, thin native bindings. See the full documentation for each language.

Pro feature

Page rendering is licensed in the Pro tier, alongside PDF/A archival output and encryption, and is also included in Enterprise. Basic PDF generation stays free. Set your token in the RUSTPDF_LICENSE environment variable and every binding picks it up automatically. See pricing for the tiers.

PDF rendering FAQ

How do I render a PDF page to an image?

Call render_page_to_png (Python), Pdf.RenderPageToPng (C#), rustpdf.RenderPageToPng (Go), or renderPageToPng (Node) with the PDF bytes, a zero-based page index and a DPI. The library parses the document, interprets the page content stream, paints it onto a bitmap and returns PNG bytes. Page rendering is a Pro feature, so a valid license must be active.

Does it need a headless browser or external tool?

No. The rasterizer is written in pure Rust on top of tiny-skia. There is no Chromium, no Ghostscript, no PDFium and no C dependency. It ships inside the same single library as the rest of the bindings, so deployment stays a single artifact.

What does the renderer support?

Vector fills and strokes with clipping, real glyph outlines for embedded and CID fonts, raster images including JPEG and soft masks, DeviceGray, RGB, CMYK, Indexed, ICCBased, Separation and DeviceN color spaces, Form XObjects, constant alpha and blend modes, and axial and radial shadings. Page rotation and crop box are honored. Non-embedded standard fonts fall back to a bundled sans-serif, and a few rare constructs (mesh shadings, tiling patterns, JPEG 2000 / CCITT / JBIG2 images) are not yet painted.

What resolution does it produce?

You choose. The DPI argument scales the output: 72 DPI gives one pixel per point (the PDF's natural size), 150 DPI is good for previews, 300 DPI for print-quality rasters. The bitmap dimensions are the page size in points multiplied by DPI divided by 72.

Is page rendering free?

Basic PDF generation is free. Page rendering is a Pro feature, bundled with PDF/A and encryption in the self-serve Pro tier, and also included in Enterprise. Without an active license the call returns a license error and produces no image.

Render PDFs to images in your language

One Rust core, the same native rasterizer across nine languages. Prototype for free, license Pro when you ship.