# PDFOptimizer Class

> Implementation of the PDF Optimizer function.

- Product: Adobe PDF Library 18
- Language: .NET
- Version: APDFL18.0.5PlusP2a
- HTML page: https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/PDFOptimizer
- Version index: https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/llms.txt

```csharp
class PDFOptimizer : SystemIDisposable
```

**Namespace:** `Datalogics::PDFL`

**Inherits from:** `SystemIDisposable`

## Description

Implementation of the PDF Optimizer function.

Use the PDFOptimizer object to accumulate options for the Optimization, and to Optimize documents.

**Referenced by:** [`PDFOptimizer`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/PDFOptimizer.md)

**Uses types:** [`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/CancelProc.md), [`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md), [`CompressQuality`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressQuality.md), [`CompressionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressionType.md), [`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/Document.md), [`ObjectCompressionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/ObjectCompressionType.md), [`OptimizerOption`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/OptimizerOption.md), [`PDFOptimizer`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/PDFOptimizer.md), [`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/ProgressMonitor.md)

## Constructors

### PDFOptimizer

```csharp
Datalogics.PDFL.PDFOptimizer.PDFOptimizer()
```

*constructor*

Construct a CPDFOptimizer, with default Options.

## Properties

### MajorVersion

```csharp
short Datalogics.PDFL.PDFOptimizer.MajorVersion { get; set; }
```

### MinorVersion

```csharp
short Datalogics.PDFL.PDFOptimizer.MinorVersion { get; set; }
```

### ObjectCompression

```csharp
ObjectCompressionType Datalogics.PDFL.PDFOptimizer.ObjectCompression { get; set; }
```

## Methods

### Dispose

```csharp
void Datalogics.PDFL.PDFOptimizer.Dispose()
```

**Returns:** `void`

### GetCompressionQuality

```csharp
CompressQuality Datalogics.PDFL.PDFOptimizer.GetCompressionQuality(CompressImageType type)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))

**Returns:** [`CompressQuality`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressQuality.md)

Get the value of the Compression Quality for a given color model.

### GetMaxResolution

```csharp
int Datalogics.PDFL.PDFOptimizer.GetMaxResolution(CompressImageType type)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))

**Returns:** `int`

Get the value of the Max DPI for a given color model.

### GetOption

```csharp
bool Datalogics.PDFL.PDFOptimizer.GetOption(OptimizerOption option)
```

**Parameters**

- `option` ([`OptimizerOption`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/OptimizerOption.md))

**Returns:** `bool`

Get the value of a single Optimizer Option.

### GetRecompressionType

```csharp
CompressionType Datalogics.PDFL.PDFOptimizer.GetRecompressionType(CompressImageType type)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))

**Returns:** [`CompressionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressionType.md)

Get the value of the Recompression Type for a given color model.

### GetResampleToResolution

```csharp
int Datalogics.PDFL.PDFOptimizer.GetResampleToResolution(CompressImageType type)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))

**Returns:** `int`

Get the value of the Resample To DPI for a given color model.

### Optimize

```csharp
void Datalogics.PDFL.PDFOptimizer.Optimize(Document doc, System.IO.Stream stream)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/Document.md))
- `stream` (`System.IO.Stream`)

**Returns:** `void`

### Optimize

```csharp
void Datalogics.PDFL.PDFOptimizer.Optimize(Document doc, System.IO.Stream stream, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/Document.md))
- `stream` (`System.IO.Stream`)
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/ProgressMonitor.md))
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/CancelProc.md))

**Returns:** `void`

### Optimize

```csharp
void Datalogics.PDFL.PDFOptimizer.Optimize(Document document, string newPath)
```

**Parameters**

- `document` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/Document.md))
- `newPath` (`string`)

**Returns:** `void`

### Optimize

```csharp
void Datalogics.PDFL.PDFOptimizer.Optimize(Document document, string newPath, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `document` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/Document.md))
- `newPath` (`string`)
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/ProgressMonitor.md))
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/class/CancelProc.md))

**Returns:** `void`

Perform the Optimization of a single document, saving the result in a new file.

### SetCompressionQuality

```csharp
void Datalogics.PDFL.PDFOptimizer.SetCompressionQuality(CompressImageType type, CompressQuality value)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))
- `value` ([`CompressQuality`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressQuality.md))

**Returns:** `void`

Set the value for the Compression Quality for a given color model. Any image that recompressed, regardless of the reason, will use this Quality for the Quality value of the specific compression type.

### SetMaxResolution

```csharp
void Datalogics.PDFL.PDFOptimizer.SetMaxResolution(CompressImageType type, int value)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))
- `value` (`int`)

**Returns:** `void`

Set the value for the Max DPI for a given color model. Any image above this resolution will be down sampled, if the Downsampling option is true for this color model.

### SetOption

```csharp
void Datalogics.PDFL.PDFOptimizer.SetOption(OptimizerOption option, bool value)
```

**Parameters**

- `option` ([`OptimizerOption`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/OptimizerOption.md))
- `value` (`bool`)

**Returns:** `void`

Set the value of a single Optimizer option.

### SetRecompressionType

```csharp
void Datalogics.PDFL.PDFOptimizer.SetRecompressionType(CompressImageType type, CompressionType value)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))
- `value` ([`CompressionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressionType.md))

**Returns:** `void`

Set the value for the recompression Type for a given color model. Any image that is downsampled will be compressed using this method, if the Downsampling option is true for this color model. Any image that is not downsampled, will be converted to this compression type, if it is not already compressed in this type, and the Recompression option for this color model is true.

### SetResampleToResolution

```csharp
void Datalogics.PDFL.PDFOptimizer.SetResampleToResolution(CompressImageType type, int value)
```

**Parameters**

- `type` ([`CompressImageType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2a/enum/CompressImageType.md))
- `value` (`int`)

**Returns:** `void`

Set the value for the Resample To DPI for a given color model. Any image will be downsampled to this resolution, if the Downsampling option is true for this color model.
