Reduce PDF File Size in IronOCR
How do I reduce the file size of the output PDF in IronOCR?
IronOCR will automatically upscale inputs that are detected as low quality (below 150DPI) to ensure accurate read results.
If DPI below 150 is detected, TargetDPI (default 225DPI) defines the DPI at which a PDF is rendered. This is the same as manually setting TargetDPI = 225.
To reduce output file size, you can set a lower TargetDPI, which will create smaller PDFs. However, setting it too low may affect OCR performance, so it's essential to maintain a balance.
Suggested values are 96, 72, 48.
// Example of reducing PDF output file size by lowering the DPI
// Example 1: Reducing DPI to 96
using IronOcr; // Import IronOCR namespace
var Ocr = new IronTesseract(); // Initialize IronTesseract for OCR operations
using (var Input = new OcrInput()) // Create OCR input object
{
Input.TargetDPI = 96; // Set the desired DPI; 96 is used for smaller output size
Input.LoadPdf("example.pdf", Password: "password"); // Load input PDF (with optional password)
var Result = Ocr.Read(Input); // Perform OCR on the input
Console.WriteLine(Result.Text); // Output recognized text to the console
}
// Example 2: Another way to set DPI
var ocr = new IronTesseract();
using (var ocrInput = new OcrInput()) // Create a new OCR input object
{
ocrInput.TargetDPI = 72; // Set render DPI to 72
ocrInput.LoadPdf("img/Input.pdf"); // Load the PDF
var ocrResult = ocr.Read(ocrInput); // Read and process the PDF
ocrResult.SaveAsSearchablePdf(@"Output.pdf"); // Save result to a searchable PDF
}
To disable automatic upscaling, use TargetDPI = 0. This will make IronOCR read the input file as-is, ignoring the TargetDPI value.
See the API for more information: IronOCR API Reference

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.