# Optimize a PDF without rasterizing pages

Apply deterministic lossless PDF optimization, deduplication, compression, or Fast Web View and retain the original when a candidate is not smaller.

Publish a PDF

[Optimize a PDF in the browser](/browser/compress-pdf/) [Read the .NET guide](/docs/pdf/operations/)

Optimization summary

**Input**

PDF

**Output**

Losslessly optimized PDF

**Package**

[OfficeIMO.Pdf on NuGet](https://www.nuget.org/packages/OfficeIMO.Pdf)

**Runs on**

Browser-local WebAssembly or .NET

**Microsoft Office**

Not required

**License**

MIT

OfficeIMO optimization is lossless; it does not downsample scans or replace pages with images.

[Browse all PDF workflows](/pdf/)

Practical steps

## Optimize a PDF with an explicit profile

Choose a lossless policy, inspect the candidate result, and keep the smaller safe artifact.

1. **Select**Choose one PDF and note its original size.
2. **Profile**Choose Balanced, Maximum Compression, Web, or Archival behavior.
3. **Review**Download the result and inspect saved bytes, actions, skipped opportunities, and linearization evidence.

OfficeIMO optimization works on PDF structure and streams without rasterizing pages. Text remains text, and the operation does not deliberately trade fidelity for a smaller scan image.

## Optimize from .NET

```csharp
using OfficeIMO.Pdf;

PdfDocument source = PdfDocument.Load("report.pdf");
PdfOptimizationActionResult result =
    source.Optimization.Apply(PdfOptimizationProfile.Web);

File.WriteAllBytes("report.optimized.pdf", result.Bytes);
Console.WriteLine($"Saved bytes: {result.SavedBytes}");
Console.WriteLine($"Returned original: {result.ReturnedOriginal}");
```

If the optimized candidate is not smaller, the result can retain the original bytes rather than making the file larger merely to claim success. The action report records requested profile, candidate and returned sizes, applied actions, skipped opportunities, and linearization state.

## Compression boundaries

This is not scan downsampling, JPEG recompression, or page rasterization. Those policies can remove selectable text, accessibility information, vector quality, and signature meaning. OfficeIMO keeps that lossy workflow separate until it has explicit quality controls and evidence.

## API used on this page

- [`PdfDocument`](/api/pdf/officeimo-pdf-pdfdocument/)
- [`PdfOptimizationActionResult`](/api/pdf/officeimo-pdf-pdfoptimizationactionresult/)
- [`PdfOptimizationProfile`](/api/pdf/officeimo-pdf-pdfoptimizationprofile/)

<!-- PowerForge markdown artifact sha256:2CEEED168F7B69B7CFE042FF0ECE63B57BC4EE98CA43D31CC38B201897F723C1 -->
