# PDFOptimizer Class

> Implementation of the PDF Optimizer function.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFOptimizer
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class PDFOptimizer
```

**Namespace:** `datalogics_interface`

## Description

Implementation of the PDF Optimizer function.

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

**Uses types:** [`OptimizerCompressQuality`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressQuality.md), [`OptimizerCompressionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressionType.md), [`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md), [`OptimizerObjectCompression`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerObjectCompression.md), [`OptimizerOption`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerOption.md)

## Constructors

### PDFOptimizer

```cpp
datalogics_interface::PDFOptimizer::PDFOptimizer()
```

*constructor*

Construct a CPDFOptimizer, with default Options.

### PDFOptimizer

```cpp
datalogics_interface::PDFOptimizer::PDFOptimizer(PDFOptimizer &&) noexcept
```

*constructor*

**Parameters**

- (unnamed) ([`PDFOptimizer &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFOptimizer.md))

### ~PDFOptimizer

```cpp
datalogics_interface::PDFOptimizer::~PDFOptimizer()
```

*destructor*

## Methods

### get_compression_quality

```cpp
OptimizerCompressQuality datalogics_interface::PDFOptimizer::get_compression_quality(OptimizerImageType type) const
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to query.

**Returns:** [`OptimizerCompressQuality`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressQuality.md)

The compression quality level for the specified color model.

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

### get_major_version

```cpp
int datalogics_interface::PDFOptimizer::get_major_version() const
```

**Returns:** `int`

The major PDF version number, or 0 if the Optimizer will decide.

Get the value of the Major Version of the optimized document.

NOTE: A value of 0 indicates the Optimizer will decide what version it should be.

### get_max_resolution

```cpp
int datalogics_interface::PDFOptimizer::get_max_resolution(OptimizerImageType type) const
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to query.

**Returns:** `int`

The maximum resolution in DPI above which images will be downsampled.

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

### get_minor_version

```cpp
int datalogics_interface::PDFOptimizer::get_minor_version() const
```

**Returns:** `int`

The minor PDF version number.

Get the value of the Minor Version of the optimized document.

### get_object_compression

```cpp
OptimizerObjectCompression datalogics_interface::PDFOptimizer::get_object_compression() const
```

**Returns:** [`OptimizerObjectCompression`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerObjectCompression.md)

The current object compression type setting.

Get the value of the Object Compression of the optimized document.

### get_option

```cpp
bool datalogics_interface::PDFOptimizer::get_option(OptimizerOption option) const
```

**Parameters**

- `option` ([`OptimizerOption`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerOption.md)): The optimization option to query.

**Returns:** `bool`

true if the option is enabled, false if it is disabled.

Get the value of a single Optimizer Option.

### get_recompression_type

```cpp
OptimizerCompressionType datalogics_interface::PDFOptimizer::get_recompression_type(OptimizerImageType type) const
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to query.

**Returns:** [`OptimizerCompressionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressionType.md)

The compression type that will be applied to images of the specified color model.

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

### get_resample_to_resolution

```cpp
int datalogics_interface::PDFOptimizer::get_resample_to_resolution(OptimizerImageType type) const
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to query.

**Returns:** `int`

The target resolution in DPI to which images will be downsampled.

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

### operator=

```cpp
PDFOptimizer & datalogics_interface::PDFOptimizer::operator=(PDFOptimizer &&) noexcept
```

**Parameters**

- (unnamed) ([`PDFOptimizer &&`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFOptimizer.md))

**Returns:** [`PDFOptimizer &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFOptimizer.md)

### optimize

```cpp
void datalogics_interface::PDFOptimizer::optimize(Document &document, const std::string &output_path)
```

**Parameters**

- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The document to optimize.
- `output_path` (`const std::string &`): The file system path where the optimized document will be saved.

**Returns:** `void`

Optimize a document and save to a new file path. Perform the Optimization of a single document, saving the result in a new file.

### set_compression_quality

```cpp
void datalogics_interface::PDFOptimizer::set_compression_quality(OptimizerImageType type, OptimizerCompressQuality value)
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to set.
- `value` ([`OptimizerCompressQuality`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressQuality.md)): The compression quality level to apply.

**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.

### set_major_version

```cpp
void datalogics_interface::PDFOptimizer::set_major_version(int major)
```

**Parameters**

- `major` (`int`): The major PDF version number.

**Returns:** `void`

Set the value for the Major Version for the optimized document.

### set_max_resolution

```cpp
void datalogics_interface::PDFOptimizer::set_max_resolution(OptimizerImageType type, int value)
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to set.
- `value` (`int`): The maximum resolution in DPI.

**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.

### set_minor_version

```cpp
void datalogics_interface::PDFOptimizer::set_minor_version(int minor)
```

**Parameters**

- `minor` (`int`): The minor PDF version number.

**Returns:** `void`

Set the value for the Minor Version for the optimized document.

### set_object_compression

```cpp
void datalogics_interface::PDFOptimizer::set_object_compression(OptimizerObjectCompression type)
```

**Parameters**

- `type` ([`OptimizerObjectCompression`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerObjectCompression.md)): The desired object compression type.

**Returns:** `void`

Set the value for the Object Compression for the optimized document.

### set_option

```cpp
void datalogics_interface::PDFOptimizer::set_option(OptimizerOption option, bool value)
```

**Parameters**

- `option` ([`OptimizerOption`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerOption.md)): The optimization option to set.
- `value` (`bool`): true to enable the option, false to disable it.

**Returns:** `void`

Set the value of a single Optimizer option.

### set_recompression_type

```cpp
void datalogics_interface::PDFOptimizer::set_recompression_type(OptimizerImageType type, OptimizerCompressionType value)
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to set.
- `value` ([`OptimizerCompressionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerCompressionType.md)): The compression type to apply.

**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.

### set_resample_to_resolution

```cpp
void datalogics_interface::PDFOptimizer::set_resample_to_resolution(OptimizerImageType type, int value)
```

**Parameters**

- `type` ([`OptimizerImageType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/OptimizerImageType.md)): The image color type (Color, Gray, or BW) to set.
- `value` (`int`): The target resolution in DPI.

**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.
