# How to Configure the DPI Setting for PDF Rendering in LiteParse

> Easily configure DPI for PDF rendering in LiteParse using Rust, CLI, or wrappers. Adjust resolution for optimal PDF processing and accuracy. Learn how now!

- Repository: [LlamaIndex/liteparse](https://github.com/run-llama/liteparse)
- Tags: how-to-guide
- Published: 2026-06-07

---

**TLDR:** LiteParse allows you to configure the DPI (dots per inch) for PDF rendering through the `LiteParseConfig` struct in Rust, the `--dpi` CLI flag, or constructor options in the Node.js and Python wrappers, with a default resolution of 150 DPI.

LiteParse, developed by run-llama, is a Rust-based PDF parsing library that converts documents into structured data using OCR and screenshot capabilities. Configuring the DPI setting controls the resolution of rendered pages, directly impacting OCR accuracy and image clarity while trading off processing speed.

## Understanding the DPI Configuration Structure

The DPI value is stored in the `LiteParseConfig` struct defined in [`crates/liteparse/src/config.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/config.rs) (lines 18-20). The default value is `150.0` DPI, which provides a baseline balance between image quality and performance. When parsing begins, this configuration propagates to the rendering layer in [`crates/liteparse/src/render.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/render.rs) (lines 46-48), where each page is processed using the `page.render(dpi)` method.

## Configuring DPI Across Different Interfaces

### Rust Core Library

In the Rust API, modify the `dpi` field of `LiteParseConfig` before constructing the `LiteParse` instance:

```rust
use liteparse::LiteParseConfig;

let mut cfg = LiteParseConfig::default();
cfg.dpi = 300.0;  // Render at 300 DPI
let parser = LiteParse::new(cfg);

```

### Command Line Interface

The CLI exposes the `--dpi` flag as documented in [`docs/src/content/docs/liteparse/cli-reference.md`](https://github.com/run-llama/liteparse/blob/main/docs/src/content/docs/liteparse/cli-reference.md) (line 37) and implemented in [`packages/node/src/cli.ts`](https://github.com/run-llama/liteparse/blob/main/packages/node/src/cli.ts) (lines 27-33):

```bash
lit parse report.pdf --dpi 300 --ocr-language eng

```

### Node.js Wrapper

The Node.js package exposes the `dpi` option through the constructor in [`packages/node/src/lib.ts`](https://github.com/run-llama/liteparse/blob/main/packages/node/src/lib.ts) (lines 24-30). The value forwards directly to the Rust core:

```javascript
import { LiteParse } from "liteparse";

const parser = new LiteParse({
  outputFormat: "json",
  dpi: 300,  // 300 DPI for OCR and screenshots
});

await parser.parse("document.pdf");

```

### Python Wrapper

Python users can pass the `dpi` keyword argument when instantiating the parser, as implemented in [`packages/python/liteparse/parser.py`](https://github.com/run-llama/liteparse/blob/main/packages/python/liteparse/parser.py) (lines 73-90):

```python
from liteparse import LiteParse

parser = LiteParse(dpi=300)  # 300 DPI rendering

result = parser.parse("document.pdf")

```

### WebAssembly (Browser)

For browser environments using the WASM build, pass the DPI value in the configuration object:

```javascript
import { LiteParse } from "liteparse-wasm";

const parser = new LiteParse({ dpi: 300 });
await parser.parse(file);

```

## How DPI Propagates to the Rendering Engine

When you configure a DPI value, LiteParse propagates it through the following pipeline:

- The value is stored in `LiteParseConfig.dpi` in [`crates/liteparse/src/config.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/config.rs)
- During page processing, the rendering engine in [`crates/liteparse/src/render.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/render.rs) calls `page.render(dpi)` using the configured value
- Higher DPI values generate larger bitmaps, improving OCR accuracy but consuming more memory and processing time

## Summary

- The default DPI in LiteParse is **150.0**, defined in [`crates/liteparse/src/config.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/config.rs)
- Configure DPI via `config.dpi` in Rust, the `--dpi` flag in CLI tools, or constructor options in Node.js and Python bindings
- The setting propagates to [`crates/liteparse/src/render.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/render.rs) where `page.render(dpi)` executes the actual rendering
- Increasing DPI improves OCR accuracy and screenshot quality but reduces processing speed and increases memory usage
- All major interfaces (Rust, CLI, Node.js, Python, and WASM) support consistent DPI configuration

## Frequently Asked Questions

### What is the default DPI setting in LiteParse?

The default DPI is **150.0**, as defined in the `LiteParseConfig` struct at [`crates/liteparse/src/config.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/config.rs) (lines 18-20). This default provides an optimal balance between image resolution for OCR text recognition and processing performance across all supported interfaces.

### How does increasing the DPI affect PDF processing performance?

Higher DPI values produce sharper page renders in [`crates/liteparse/src/render.rs`](https://github.com/run-llama/liteparse/blob/main/crates/liteparse/src/render.rs), which typically improves OCR accuracy. However, each increment increases memory consumption and processing time because the `page.render(dpi)` method must generate larger bitmaps for each PDF page.

### Can I use different DPI settings for different PDFs in the same application?

Yes, DPI is configured per `LiteParse` instance. You can create multiple parser instances with different DPI values (e.g., one at 150 DPI for fast processing and another at 300 DPI for high-accuracy OCR), as the `LiteParseConfig` struct is instantiated independently for each parser.

### Is the DPI setting available when using LiteParse in the browser?

Yes, the WebAssembly (WASM) build supports DPI configuration through the constructor options object. Pass a `dpi` field when creating a new `LiteParse` instance in JavaScript to control rendering resolution in browser-based applications, consistent with the Node.js and Python APIs.