<style>
table, th, td {
	border: 1px solid;
}
table th:first-of-type {
	width: 25%;
}
table th:nth-of-type(2) {
	width: 75%;
} 
</style>

# Settings

The `PdfFormatProvider` class imports and exports PDF documents. The import and export settings provide options for controlling encryption, image quality, font embedding, compliance levels, and more.

## Import Settings

The `PdfFormatProvider` class exposes the `ImportSettings` property, which allows you to control how the content is imported. The following table lists the available import settings:

| Property                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ReadingMode`                  | Gets or sets the mode for loading the document pages content on import. *Introduced in R2 2020*.<ul><li>**ReadAllAtOnce**: All document pages content is loaded on import. This is the default behavior.</li><li>**OnDemand**: The document pages content is loaded on demand. This mode is designed for use with PdfViewers and only the currently visible page is loaded. </td></tr></ul> The **OnDemand** mode must be applied when used with viewers only.                                                                                                                           |
| `CopyStream`                   | Gets or sets whether to copy the document stream on import. When false and ReadingMode is OnDemand, the original stream must be kept open while the document is in use. When true, the original stream can be disposed after import, regardless of the reading mode.                                                                                                                                                                                                                                                                                                                     |
| `IgnoreMarkedContent`          | When `true`, imports the content inside marked-content containers without preserving the containers and skips the document structure tree. The default is `false`, which preserves marked content and imports the structure tree.                                                                                                                                                                                                                                                                                                                                                        |
| `InvalidStructureTreeHandling` | Controls how import handles malformed structure-tree entries. `Continue` (default) skips invalid entries and continues import. `Throw` throws `InvalidStructureTreeException` unless an event handler handles it. See [structure-tree exception handling](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/features/handling-document-exceptions#handling-invalid-structure-trees) for event behavior and limitations.                                                                                                                     |
| `MaxDecodedStreamSize`         | Gets or sets the maximum decoded output, in bytes, for one PDF stream or filter stage. The default is 256 MiB.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `MaxTotalDecodedStreamSize`    | Gets or sets the maximum cumulative decoded output, in bytes, for one document. The default is 1 GiB. Intermediate filter output and deferred image decoding count toward this limit. Repeated decoding charges only output that was not counted before.                                                                                                                                                                                                                                                                                                                                 |
| `MaxImagePixelCount`           | Gets or sets the maximum number of pixels decoded for one CCITT image. The default is 64 million pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `MaxJbig2ImagePixelCount`      | Limits pixels per JBIG2 page, region, or intermediate bitmap. Default: 640 million. Independent of the CCITT-only `MaxImagePixelCount`. Increase before `Import()` for larger images; each import captures the value, including for deferred decoding. `MaxDecodedStreamSize`, `MaxTotalDecodedStreamSize`, and the `int.MaxValue` pixel ceiling still apply. Increase `MaxDecodedStreamSize` if valid files need more temporary decoder storage. Pixel or decoded-byte limit violations throw `InvalidDataException`. Raise limits only for trusted documents, within available memory. |
| `MaxNestingDepth`              | Gets or sets the maximum depth of recursive PDF object conversion. The default is 256. This limit applies to color spaces, decode parameters, streams, Form XObjects, image masks, stitching functions, marked content, and clipping paths. Exceeding the limit raises `NestingDepthExceededException`.                                                                                                                                                                                                                                                                                  |
| `MaxTreeDepth`                 | Gets or sets the maximum depth of PDF trees and linked-object chains. The default is 1,024. This limit applies to page trees, outlines, field parents, actions, name and ID trees, structure elements, indirect-object forwarding, and cross-reference sections. Exceeding the limit raises `NestingDepthExceededException`.                                                                                                                                                                                                                                                             |
| `MaxOptionalContentNodeCount`  | Gets or sets the maximum expanded node count for imported optional-content properties. The default is 1,000,000 nodes. Shared subtrees count once per logical occurrence. Exceeding the limit raises `InvalidDataException`.                                                                                                                                                                                                                                                                                                                                                             |
| `MaxStructureElementCount`     | Gets or sets the maximum number of structure elements materialized per document. The default is 1,000,000 elements. Shared branches count once per emitted occurrence. Exceeding the limit raises `InvalidDataException`.                                                                                                                                                                                                                                                                                                                                                                |

Use separate provider and settings instances for concurrent imports, and do not mutate one settings instance concurrently.

All numeric limits must be positive. Remaining execution-stack checks can reject recursion before `MaxNestingDepth` or `MaxTreeDepth` is reached. Cycle detection remains active independently of these limits. Circular references raise `InvalidDataException` or `NestingDepthExceededException`, depending on the traversal path.

| Event                                 | Description                                                                                                                                                                                                                                                  |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `UserPasswordNeeded`                  | The event fires when a *user* password is needed to open the document. The password can be set in the `PasswordNeededEventArgs.Password` property.                                                                                                           |
| `OwnerPasswordNeeded`                 | The event fires when an *owner* password is needed to open the document. The password can be set in the `PasswordNeededEventArgs.Password` property.                                                                                                         |
| `DuplicatedEmbeddedFileNameResolving` | The event fires when the provider resolves conflicts between [embedded file names](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/features/embedded-file-streams/embedded-file-streams) with the same names. |
| `DocumentUnhandledException`          | Raised when an exception occurs during document import. Provides error details and a chance to handle it. For `InvalidStructureTreeException`, the initial `Handled` value depends on `InvalidStructureTreeHandling`.                                        |

The following example shows how to create a `PdfImportSettings` object with the desired settings and handle the offered events:

```C#
PdfFormatProvider provider = new PdfFormatProvider();
PdfImportSettings settings = new PdfImportSettings();
settings.UserPasswordNeeded += (s, a) =>
{
    a.Password = "Us3rP4ssw0rd";
};
settings.OwnerPasswordNeeded += (s, a) =>
{
    a.Password = "Own3erP4ssw0rd";
};
settings.DuplicatedEmbeddedFileNameResolving += (s, a) =>
{
    string myNewName = "2_" + a.Name;
    if (!a.UsedNames.Contains(myNewName))
    {
        a.NewName = myNewName;
    }
};
provider.ImportSettings = settings;
```

## Export Settings

The `PdfFormatProvider` class exposes the `ExportSettings` property, which allows you to control how the content is exported. The following table lists the available export settings:

| Property                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `StripStructureTree`     | Specifies whether the PDF document strips the structure tree on export. *Introduced in Q2 2025*. The default value is **false**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `StripJavaScriptActions` | Specifies whether the PDF document strips JavaScript actions on export. *Introduced in Q4 2024*. The default value is **false**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `FontEmbeddingType`      | Controls what part of the fonts is embedded in the file: <ul><li>**None**: Does not embed fonts.</li><li>**Full**: Fully embeds fonts.</li><li>**Subset**: Embeds only the used characters subset of the fonts. This is the default approach.</li></ul> The subset export option is implemented **only** for TrueType fonts (.ttf).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `IsEncrypted`            | Specifies whether the document is encrypted. The default value is *false*. You can set the encryption algorithm through the `EncryptionType` property.</br>**All passwords for revision 6 (AES-256) must be based on Unicode**. Preprocessing of a user-provided password consists first of normalizing its representation by applying the "SASLPrep" profile (Internet RFC 4013) of the "stringprep" algorithm (Internet RFC 3454) to the supplied password using the Normalize and BiDi options. </br> This setting is ignored when `ComplianceLevel` differs from `None` as PDF/A compliant documents do not allow encryption.                                                                                                                                                                                                                      |
| `EncryptionType`         | Encryption algorithm applied when `IsEncrypted` is `true`. The supported values are: <ul><li>`AES256`: AES-256 with standard security handler revision 6. This is the default value.</li><li>`AES128`: AES-128 (*introduced in Q4 2025*).</li><li>`RC4`: RC4.</li></ul>For legacy readers that do not support AES-256, explicitly select a supported algorithm.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `UserPassword`           | The password to use if the document is encrypted. The default password is an empty string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `OwnerPassword`          | The password that governs permissions for operations such as printing, copying, and modifying the document. The default password is an empty string.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `UserAccessPermissions`  | Gets or sets the user access permissions. These permissions specify which operations are allowed when the document is opened with user access. To apply these permissions, set the `IsEncrypted` property to *true*. This property supports three types of user access permissions: [Available UserAccessPermissions](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/settings#available-useraccesspermissions)                                                                                                                                                                                                                                                                                                                                            |
| `ImageQuality`           | Specifies the quality with which images are exported to PDF. More information is available in [the ImageQuality article](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/imagequality). </br> The .NET Standard specification does not define APIs for converting images or scaling their quality. To allow the library to export images other than Jpeg and Jpeg2000, or to use ImageQuality values other than High, provide an implementation of the `JpegImageConverterBase` abstract class. Pass this implementation to the `JpegImageConverter` property of the `FixedExtensibilityManager`. For more information, refer to the [Cross-Platform Support](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/cross-platform/overview) article. |
| `ImageCompression`       | Sets the desired compression for images when exporting. You can set one of the following values of the `ImageFilterTypes` enum: <ul><li>**Default**: The image compression is preserved as in the original document.</li><li>**None**: The images are not encoded.</li><li> **FlateDecode**: The images are encoded with a FlateDecode filter. Compresses data with the zlib/deflate compression method.</li><li>**DCTDecode**: The images are encoded with a DCTDecode filter. Compresses data with a DCT (discrete cosine transform) technique based on the JPEG standard.</li></ul>                                                                                                                                                                                                                                                                 |
| `StreamCompression`      | Gets or sets the content stream compression type. Possible values: <ul><li>**None**: The content streams are not encoded.</li><li>**FlateDecode**: Compresses data with the zlib/deflate compression method.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `ComplianceLevel`        | Specifies the PDF/A or PDF/UA compliance level. It can have one of the following values: <ul><li>**None**: No compliance level.</li><li>**PdfA1B**: PDF/A-1b compliance level.</li><li>**PdfA1A**: PDF/A-1a compliance level.</li><li>**PdfA2B**: PDF/A-2b compliance level.</li><li>**PdfA2A**: PDF/A-2a compliance level.</li><li>**PdfA2U**: PDF/A-2u compliance level.</li><li>**PdfA3B**: PDF/A-3b compliance level.</li><li>**PdfA3A**: PDF/A-3a compliance level.</li><li>**PdfA3U**: PDF/A-3u compliance level.</li><li>**PdfUA1**: PDF/UA-1 compliance level.</li></ul> The default value is `None`. For more information on PDF/A compliance, refer to the [PDF/A Compliance article](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/comply-with-pdfa-standard).                    |
| `ShouldExportXfa`        | Specifies whether the PDF document exports XFA content (if any). Default value: *false*. Introduced in **Q1 2025**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `TaggingStrategy`        | Specifies the tagging strategy used when exporting the document. Default value: *UseExisting*. Introduced in **Q3 2025.** </br>Possible values: <ul><li>**UseExisting**: The document is not tagged automatically and the existing StructureTree is used.</li><li>**Build**: The document is automatically tagged and a new StructureTree is created.</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

### Available UserAccessPermissions

| UserAccessPermission Type | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PrintingPermissionType`  | Sets the permissions for document printing. Possible values: <ul><li>**None**: No printing is allowed.</li><li>**LowResolution**: Low resolution (150 dpi) printing is allowed.</li><li>**HighResolution**: Printing at the highest resolution is allowed.</li></ul>                                                                                                                                                                                                                                                                                                                |
| `ChangingPermissionType`  | Sets the permissions for making changes to the document. Possible values: <ul><li>**None**: No document changes are allowed.</li><li>**DocumentAssembly**: Inserting, deleting, and rotating page changes are allowed.</li><li>**FormFieldFillingOrSigning**: Filling in form fields and signing existing signature fields are allowed.</li><li>**FormFieldFillingOrSigningAndCommenting**: Commenting, filling in form fields, and signing existing signature fields are allowed.</li><li>**AnyExceptExtractingPages**: Any changes except extracting pages are allowed.</li></ul> |
| `CopyingPermissionType`   | Sets the permissions for document copying. Possible values: <ul><li>**None**: No copying is allowed.</li><li>**Copying**: Copying is allowed.</li><li>**TextAccess**: Text access for assistive technologies, such as screen readers, is allowed.</li></ul>                                                                                                                                                                                                                                                                                                                         |

> important The receiver of a PDF document must have the same fonts that were originally used to create it. If a different font is substituted, its character set, glyph shapes, and metrics may differ from those in the original font. This substitution can produce unexpected and unwanted results, such as lines of text extending into margins or overlapping with graphics. A PDF file can refer by name to fonts that are not embedded in the PDF file. In this case, a PDF consumer can use those fonts if they are available in its environment. This approach suffers from the uncertainties noted previously.

Starting with **Q1 2025**, the `PdfExportSettings` class exposes the `DocumentUnhandledException` event, which allows you to handle exceptions while exporting a document.

The following example shows how to create a `PdfExportSettings` object with custom settings and handle unexpected errors while exporting the PDF document:

```C#
PdfFormatProvider provider = new PdfFormatProvider();
PdfExportSettings settings = new PdfExportSettings();
provider.ExportSettings = settings;

settings.StripJavaScriptActions = true;
settings.StripStructureTree = false;
settings.FontEmbeddingType = FontEmbeddingType.Full;
settings.ComplianceLevel = PdfComplianceLevel.PdfA2B;
settings.ImageCompression = new ImageFilterTypes[] { ImageFilterTypes.FlateDecode };
settings.ImageQuality = ImageQuality.Medium;
settings.IsEncrypted = true;
settings.UserPassword = "TelerikUser";
settings.OwnerPassword = "0wn3rP4ssw0rd";
UserAccessPermissions permissions = new UserAccessPermissions
{
    Printing = PrintingPermissionType.HighResolution,
    Changing = ChangingPermissionType.AnyExceptExtractingPages,
    Copying = CopyingPermissionType.TextAccess,
};
settings.UserAccessPermissions = permissions;
settings.DocumentUnhandledException += (s, e) =>
{
    Debug.WriteLine("The document is corrupted and cannot be exported: " + e.Exception.Message);
    e.Handled = true;
};
```

## See Also

* [Handling Exceptions](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/features/handling-document-exceptions)
* [How to Comply with PDF/A Standard](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/comply-with-pdfa-standard)
* [Optimizing and Reducing the Size of PDF Files with RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/optimize-and-reduce-pdf-size-radpdfprocessing)
* [Removing Password from a PDF Using Telerik PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/remove-password-from-pdf-telerik-pdfprocessing)
