# Document Class

> The underlying PDF representation of a document.

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

```csharp
class Document : SystemIDisposable
```

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

**Inherits from:** `SystemIDisposable`

## Description

The underlying PDF representation of a document.

Use document objects to perform most of the functions related to pages in a PDF file, such as deleting pages, inserting blank pages, copying watermarks, creating bookmarks and thumbnails, and so on.

**Referenced by:** [`Action`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Action.md), [`Container`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Container.md), [`Content`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Content.md), [`DocTextFinder`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/DocTextFinder.md), [`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md), [`FileAttachment`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FileAttachment.md), [`FileSpecification`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FileSpecification.md), [`Font`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md), [`Form`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Form.md), [`Group`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Group.md), [`Image`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Image.md), [`ImageCollection`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ImageCollection.md), [`NameTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NameTree.md), [`NumberTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NumberTree.md), [`OCREngine`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OCREngine.md), [`OptionalContentConfig`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentConfig.md), [`OptionalContentContext`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentContext.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentGroup.md), [`OptionalContentMembershipDict`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentMembershipDict.md), [`OptionalContentOrderArray`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentOrderArray.md), [`PDFAConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFAConvertResult.md), [`PDFArray`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFArray.md), [`PDFBoolean`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFBoolean.md), [`PDFDict`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFDict.md), [`PDFInteger`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFInteger.md), [`PDFName`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFName.md), [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md), [`PDFOptimizer`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFOptimizer.md), [`PDFReal`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFReal.md), [`PDFStream`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFStream.md), [`PDFString`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFString.md), [`PDFXConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFXConvertResult.md), [`Page`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Page.md), [`Path`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Path.md), [`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md), [`RemoteDestination`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/RemoteDestination.md), [`SignDoc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/SignDoc.md), [`Text`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Text.md), [`ViewDestination`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ViewDestination.md), [`WordFinder`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WordFinder.md)

**Uses types:** [`AcroFormExportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/AcroFormExportType.md), [`AcroFormImportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/AcroFormImportType.md), [`Bookmark`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Bookmark.md), [`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md), [`Collection`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Collection.md), [`ColorConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ColorConvertParams.md), [`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md), [`EmbedFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EmbedFlags.md), [`EncryptionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EncryptionType.md), [`FileAttachment`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FileAttachment.md), [`FlattenTransparencyParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FlattenTransparencyParams.md), [`Font`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md), [`NameTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NameTree.md), [`NumberTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NumberTree.md), [`OptionalContentConfig`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentConfig.md), [`OptionalContentContext`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentContext.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentGroup.md), [`PDDocFormsType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDDocFormsType.md), [`PDFAConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFAConvertParams.md), [`PDFAConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFAConvertResult.md), [`PDFAConvertType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFAConvertType.md), [`PDFArray`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFArray.md), [`PDFDict`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFDict.md), [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md), [`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md), [`PDFXConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFXConvertParams.md), [`PDFXConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFXConvertResult.md), [`PDFXConvertType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFXConvertType.md), [`Page`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Page.md), [`PageDeleteFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageDeleteFlags.md), [`PageInsertFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageInsertFlags.md), [`PageLabel`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PageLabel.md), [`PageMode`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageMode.md), [`PermissionFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionFlags.md), [`PermissionRequestOperation`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionRequestOperation.md), [`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md), [`PrintProgressProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintProgressProc.md), [`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md), [`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md), [`Rect`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Rect.md), [`Redaction`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Redaction.md), [`ReportProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ReportProc.md), [`ResourceType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/ResourceType.md), [`RolledBackDocument`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/RolledBackDocument.md), [`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md), [`WatermarkParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WatermarkParams.md), [`WatermarkTextParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WatermarkTextParams.md), [`XFAFormExportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/XFAFormExportType.md), [`XPSConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/XPSConvertParams.md)

## Constructors

### Document

```csharp
Datalogics.PDFL.Document.Document()
```

*constructor*

Creates a new document. The only Cos object in the document will be a Catalog. After the document is created, at least one page must be added using CreatePage or InsertPages before the PDF Viewer can display or save the document.

### Document

```csharp
Datalogics.PDFL.Document.Document(string fileName)
```

*constructor*

**Parameters**

- `fileName` (`string`): A path name to the file, specified in whatever format is correct for fileSys.

Opens the specified document. If the call fails and the exception is pdErrNeedRebuild, then call again with doRepair set to true. This allows the application to decide whether to perform the time-consuming repair operation.

### Document

```csharp
Datalogics.PDFL.Document.Document(string fileName, string password, PermissionRequestOperation perms, bool doRepair)
```

*constructor*

**Parameters**

- `fileName` (`string`): A path name to the file.
- `password` (`string`): The password to use to attempt to open the document.
- `perms` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionRequestOperation.md)): The permissions being requested. It must be an OR of the PermissionRequestOperation values.
- `doRepair` (`bool`): If true, attempt to repair the file if it is damaged. If false, do not attempt to repair the file if it is damaged.

Opens the specified document. If the document is already open, it returns a reference to the already opened Document. You must call Close() once for every successful open. If the call fails and the exception is pdErrNeedRebuild, then call again with doRepair equal to true. This allows the application to decide whether to perform the time-consuming repair operation.

### Document

```csharp
Datalogics.PDFL.Document.Document(string XPSFilename, XPSConvertParams ConversionParams)
```

*constructor*

**Parameters**

- `XPSFilename` (`string`): The path to the XPS file to convert.
- `ConversionParams` ([`XPSConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/XPSConvertParams.md)): Additional parameters for XPS conversion.

Create a Document from an XPS file.

Documents are converted one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

NOTE: This method is only available on Windows or Linux.

### Document

```csharp
Datalogics.PDFL.Document.Document(System.IO.Stream stream)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): The Stream from which to read the Document.

Open a Document from a Stream.

This allows a document to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. Once passed to the Document constructor, ownership of the stream is passed to the Document. The Stream must remain open while the Document itself is open, as data will only be read as needed.

### Document

```csharp
Datalogics.PDFL.Document.Document(System.IO.Stream stream, string password, PermissionRequestOperation perms, bool doRepair)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): The Stream from which to read the Document.
- `password` (`string`): The password to use to attempt to open the document.
- `perms` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionRequestOperation.md)): The permissions being requested. It must be an OR of the PermissionRequestOperation values.
- `doRepair` (`bool`): If true, attempt to repair the file if it is damaged. If false, do not attempt to repair the file if it is damaged.

Open a Document from a Stream.

This allows a document to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. Once passed to the Document constructor, ownership of the stream is passed to the Document. The Stream must remain open while the Document itself is open, as data will only be read as needed.

## Properties

### Attachments

```csharp
System.Collections.Generic.IList<FileAttachment> Datalogics.PDFL.Document.Attachments { get; }
```

### Author

```csharp
string Datalogics.PDFL.Document.Author { get; set; }
```

### BaseURI

```csharp
string Datalogics.PDFL.Document.BaseURI { get; set; }
```

### BookmarkRoot

```csharp
Bookmark Datalogics.PDFL.Document.BookmarkRoot { get; }
```

### Collection

```csharp
Collection Datalogics.PDFL.Document.Collection { get; }
```

### CompressionLevel

```csharp
int Datalogics.PDFL.Document.CompressionLevel { get; }
```

### Creator

```csharp
string Datalogics.PDFL.Document.Creator { get; set; }
```

### DefaultOptionalContentConfig

```csharp
OptionalContentConfig Datalogics.PDFL.Document.DefaultOptionalContentConfig { get; }
```

### DeleteOnClose

```csharp
bool Datalogics.PDFL.Document.DeleteOnClose { get; set; }
```

### FileName

```csharp
string Datalogics.PDFL.Document.FileName { get; }
```

### FormsType

```csharp
PDDocFormsType Datalogics.PDFL.Document.FormsType { get; }
```

### HasSignature

```csharp
bool Datalogics.PDFL.Document.HasSignature { get; }
```

### InfoDict

```csharp
PDFDict Datalogics.PDFL.Document.InfoDict { get; }
```

### InstanceID

```csharp
System.Byte [] Datalogics.PDFL.Document.InstanceID { get; }
```

### IsEmbedded

```csharp
bool Datalogics.PDFL.Document.IsEmbedded { get; set; }
```

### IsLinearized

```csharp
bool Datalogics.PDFL.Document.IsLinearized { get; }
```

### IsModified

```csharp
bool Datalogics.PDFL.Document.IsModified { get; }
```

### IsOptimized

```csharp
bool Datalogics.PDFL.Document.IsOptimized { get; set; }
```

### IsPxDF

```csharp
bool Datalogics.PDFL.Document.IsPxDF { get; }
```

### Keywords

```csharp
string Datalogics.PDFL.Document.Keywords { get; set; }
```

### LoadedFonts

```csharp
System.Collections.Generic.IList<Font> Datalogics.PDFL.Document.LoadedFonts { get; }
```

### MajorVersion

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

### MajorVersionIsNewerThanCurrentLibrary

```csharp
bool Datalogics.PDFL.Document.MajorVersionIsNewerThanCurrentLibrary { get; }
```

### MergedXMPKeywords

```csharp
string Datalogics.PDFL.Document.MergedXMPKeywords { get; }
```

### MinorVersion

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

### MinorVersionIsNewerThanCurrentLibrary

```csharp
bool Datalogics.PDFL.Document.MinorVersionIsNewerThanCurrentLibrary { get; }
```

### NeedsSave

```csharp
bool Datalogics.PDFL.Document.NeedsSave { get; set; }
```

### NumPages

```csharp
int Datalogics.PDFL.Document.NumPages { get; }
```

### OptionalContentConfigs

```csharp
System.Collections.Generic.IList<OptionalContentConfig> Datalogics.PDFL.Document.OptionalContentConfigs { get; }
```

### OptionalContentContext

```csharp
OptionalContentContext Datalogics.PDFL.Document.OptionalContentContext { get; }
```

### OptionalContentGroups

```csharp
System.Collections.Generic.IList<OptionalContentGroup> Datalogics.PDFL.Document.OptionalContentGroups { get; }
```

### PageLabels

```csharp
System.Collections.Generic.IList<PageLabel> Datalogics.PDFL.Document.PageLabels { get; set; }
```

### PageMode

```csharp
PageMode Datalogics.PDFL.Document.PageMode { get; set; }
```

### PermanentID

```csharp
System.Byte [] Datalogics.PDFL.Document.PermanentID { get; }
```

### PermissionFlags

```csharp
PermissionFlags Datalogics.PDFL.Document.PermissionFlags { get; }
```

### Producer

```csharp
string Datalogics.PDFL.Document.Producer { get; set; }
```

### RequiresFullSave

```csharp
bool Datalogics.PDFL.Document.RequiresFullSave { get; set; }
```

### RolledBackDocuments

```csharp
System.Collections.Generic.IList<RolledBackDocument> Datalogics.PDFL.Document.RolledBackDocuments { get; }
```

### Root

```csharp
PDFDict Datalogics.PDFL.Document.Root { get; }
```

### StructureIDTree

```csharp
NameTree Datalogics.PDFL.Document.StructureIDTree { get; }
```

### StructureParentTree

```csharp
NumberTree Datalogics.PDFL.Document.StructureParentTree { get; }
```

### Subject

```csharp
string Datalogics.PDFL.Document.Subject { get; set; }
```

### SuppressErrors

```csharp
bool Datalogics.PDFL.Document.SuppressErrors { get; set; }
```

### Title

```csharp
string Datalogics.PDFL.Document.Title { get; set; }
```

### VersionIsOlderThanCurrentLibrary

```csharp
bool Datalogics.PDFL.Document.VersionIsOlderThanCurrentLibrary { get; }
```

### VersionString

```csharp
string Datalogics.PDFL.Document.VersionString { get; }
```

### WasRepaired

```csharp
bool Datalogics.PDFL.Document.WasRepaired { get; }
```

### XMPMetadata

```csharp
string Datalogics.PDFL.Document.XMPMetadata { get; set; }
```

## Fields

### AllPages

```csharp
static const int Datalogics.PDFL.Document.AllPages
```

*static*

All pages.

### BeforeFirstPage

```csharp
static const int Datalogics.PDFL.Document.BeforeFirstPage
```

*static*

Before first page.

### LastPage

```csharp
static const int Datalogics.PDFL.Document.LastPage
```

*static*

Last page.

## Methods

### ApplyRedactions

```csharp
bool Datalogics.PDFL.Document.ApplyRedactions()
```

**Returns:** `bool`

### ApplyRedactions

```csharp
bool Datalogics.PDFL.Document.ApplyRedactions(Redaction redact)
```

**Parameters**

- `redact` ([`Redaction`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Redaction.md))

**Returns:** `bool`

### CloneAsPDFADocument

```csharp
PDFAConvertResult Datalogics.PDFL.Document.CloneAsPDFADocument(PDFAConvertType type, PDFAConvertParams parms)
```

**Parameters**

- `type` ([`PDFAConvertType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFAConvertType.md)): The type of PDF/A conversion to perform
- `parms` ([`PDFAConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFAConvertParams.md)): A PDFAConvertParams object specifying options for the conversion

**Returns:** [`PDFAConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFAConvertResult.md)

A PDFAConvertResult object containing the Document and SaveFlags.

Create a PDF/A compliant version of this Document.

The returned Document will be compliant with the PDF/A standard. You can save it using any of the standard Save() methods.

The PDFAConvertResult object contains both the Document and the SaveFlags you should use when saving the Document. You MUST use these exact flags to save the returned Document or it will no longer be PDF/A compliant.

The returned Document will have its MajorVersion and MinorVersion set to values required for PDF/A compliance. These will not be visible until after you save the Document.

If this Document could not be converted to PDF/A, the PDFADocument field in the PDFAConvertResult object will be null or a LibraryException will be thrown.

A LibraryException message should be checked to see if setting a PDFAConvertParams property will allow conversion to succeed. For example, if the message is "Unembeddable font in annotation", then try setting the RemoveAllAnnotations property to true and then call CloneAsPDFADocument().

### CloneAsPDFXDocument

```csharp
PDFXConvertResult Datalogics.PDFL.Document.CloneAsPDFXDocument(PDFXConvertType type, PDFXConvertParams parms)
```

**Parameters**

- `type` ([`PDFXConvertType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFXConvertType.md)): The type of PDF/X conversion to perform
- `parms` ([`PDFXConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFXConvertParams.md)): A PDFXConvertParams object specifying options for the conversion

**Returns:** [`PDFXConvertResult`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFXConvertResult.md)

A PDFXConvertResult object containing the Document and SaveFlags.

Create a PDF/X compliant version of this Document.

The returned Document will be compliant with the PDF/X standard. You can save it using any of the standard Save() methods.

The PDFXConvertResult object contains both the Document and the SaveFlags you should use when saving the Document. You MUST use these exact flags to save the returned Document or it will no longer be PDF/X compliant.

The returned Document will have its MajorVersion and MinorVersion set to values required for PDF/X compliance. These will not be visible until after you save the Document.

If this Document could not be converted to PDF/X, the PDFXDocument field in the PDFXConvertResult object will be null.

### Close

```csharp
void Datalogics.PDFL.Document.Close()
```

**Returns:** `void`

Closes a document and releases its resources. Changes are not saved. You must use Save to save any modifications before calling Close.

### CollectNamesOfTree

```csharp
void Datalogics.PDFL.Document.CollectNamesOfTree(PDFArray namesArray, System.Collections.Generic.IList< FileAttachment > attachments)
```

**Parameters**

- `namesArray` ([`PDFArray`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFArray.md))
- `attachments` ([`System.Collections.Generic.IList< FileAttachment >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FileAttachment.md))

**Returns:** `void`

### ColorConvertPages

```csharp
bool Datalogics.PDFL.Document.ColorConvertPages(ColorConvertParams params_)
```

**Parameters**

- `params_` ([`ColorConvertParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ColorConvertParams.md))

**Returns:** `bool`

True if color conversion occurred. False if nothing was color converted.

Convert the colors (in place) in a Document as specified by by the params block by applying an ICC profile to the objects contained in the Document.

### ConvertToExcel

```csharp
static bool Datalogics.PDFL.Document.ConvertToExcel(string inputPDFFileFilePath, string outputOfficeFilePath)
```

*static*

**Parameters**

- `inputPDFFileFilePath` (`string`): The PDF file path to convert.
- `outputOfficeFilePath` (`string`): The output Office file path.

**Returns:** `bool`

true if the conversion was successful, false if an error occurred.

This function converts a PDF file to a Microsoft Excel Office file (.xlsx).

NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

### ConvertToPowerPoint

```csharp
static bool Datalogics.PDFL.Document.ConvertToPowerPoint(string inputPDFFileFilePath, string outputOfficeFilePath)
```

*static*

**Parameters**

- `inputPDFFileFilePath` (`string`): The PDF file path to convert.
- `outputOfficeFilePath` (`string`): The output Office file path.

**Returns:** `bool`

true if the conversion was successful, false if an error occurred.

This function converts a PDF file to a Microsoft PowerPoint Office file (.pptx).

NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

### ConvertToWord

```csharp
static bool Datalogics.PDFL.Document.ConvertToWord(string inputPDFFileFilePath, string outputOfficeFilePath)
```

*static*

**Parameters**

- `inputPDFFileFilePath` (`string`): The PDF file path to convert.
- `outputOfficeFilePath` (`string`): The output Office file path.

**Returns:** `bool`

true if the conversion was successful, false if an error occurred.

This function converts a PDF file to a Microsoft Word Office file (.docx).

NOTE: This method is only available on Windows 32/64-bit and Linux 64-bit.

### ConvertXFAFieldsToAcroFormFields

```csharp
uint Datalogics.PDFL.Document.ConvertXFAFieldsToAcroFormFields()
```

**Returns:** `uint`

the number of output pages created in the converted document

Convert a XFA document into a document with only AcroForms.

XFA content is not widely supported by PDF processors, converting this content transforms XFA fields into AcroForm fields which are more widely suppored by PDF processors All XFA fields are removed.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### CountXMPMetadataArrayItems

```csharp
int Datalogics.PDFL.Document.CountXMPMetadataArrayItems(string namespaceName, string path)
```

**Parameters**

- `namespaceName` (`string`): The XML namespace URI for the schema in which the property is to be found.
- `path` (`string`): The name of the simple property .

**Returns:** `int`

number of array items in the property array.

Returns the number of array items in a property array associated with a Document.

### CreateCollection

```csharp
void Datalogics.PDFL.Document.CreateCollection()
```

**Returns:** `void`

collection object

CreateCollection allows to create new collection in the PDF document. It replaces any existing collection.

### CreateNameTree

```csharp
NameTree Datalogics.PDFL.Document.CreateNameTree(string nameTreeName)
```

**Parameters**

- `nameTreeName` (`string`): The name of the NameTree to create.

**Returns:** [`NameTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NameTree.md)

The retrieved or newly created NameTree.

Retrieves the name tree inside the Names dictionary with the specified key name, or creates it if it does not exist.

### CreatePage

```csharp
Page Datalogics.PDFL.Document.CreatePage(int afterPageNum, Rect mediaBox)
```

**Parameters**

- `afterPageNum` (`int`): The page number after which the new page is inserted. The first page is 0. Use Document.BeforeFirstPage to insert the new page at the beginning of a document.
- `mediaBox` ([`Rect`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Rect.md)): A rectangle specifying the page's media box, specified in user space coordinates.

**Returns:** [`Page`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Page.md)

The newly created page.

Creates and acquires a new Page. The page is inserted into the document at the specified location.

### DeletePages

```csharp
void Datalogics.PDFL.Document.DeletePages(int firstPage, int lastPage)
```

**Parameters**

- `firstPage` (`int`): The page number of the first page to delete. The first page is 0.
- `lastPage` (`int`): The page number of the last page to delete.

**Returns:** `void`

Deletes the specified pages.

### DeletePages

```csharp
void Datalogics.PDFL.Document.DeletePages(int firstPage, int lastPage, PageDeleteFlags deleteFlags)
```

**Parameters**

- `firstPage` (`int`): The page number of the first page to delete. The first page is 0.
- `lastPage` (`int`): The page number of the last page to delete.
- `deleteFlags` ([`PageDeleteFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageDeleteFlags.md)): One of the DeleteFlags.

**Returns:** `void`

Deletes the specified pages with option to parse Structure Tree.

### Dispose

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

**Returns:** `void`

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts()
```

**Returns:** `void`

Embed unembedded fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

With no flags, fonts marked as embedded or subsettable will be embedded.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts(EmbedFlags flags)
```

**Parameters**

- `flags` ([`EmbedFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EmbedFlags.md)): One of the EmbedFlags

**Returns:** `void`

Embed unembedded fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts(EmbedFlags flags, ProgressMonitor progressMonitor, CancelProc cancelProc, ReportProc reportProc)
```

**Parameters**

- `flags` ([`EmbedFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EmbedFlags.md)): One of the EmbedFlags
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md)): a ProgressMonitor that will receive progress information, may be null
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md)): a CancelProc, which can return true to cancel the operation, may be null
- `reportProc` ([`ReportProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ReportProc.md)): a ReportProc, which will be called with warnings about fonts that do not embed, may be null

**Returns:** `void`

Embed unembedded fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts(System.Collections.Generic.IList< Font > fonts)
```

**Parameters**

- `fonts` ([`System.Collections.Generic.IList< Font >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md))

**Returns:** `void`

Embed specified fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, use the version of this call that takes a list of Font objects and a set of flags for embedding. Passing the list of new Fonts and the DontScanDocument flag will directly embed the fonts in the list without scanning the document.

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts(System.Collections.Generic.IList< Font > fonts, EmbedFlags flags)
```

**Parameters**

- `fonts` ([`System.Collections.Generic.IList< Font >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md)): The list of fonts to embed. See restrictions above.
- `flags` ([`EmbedFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EmbedFlags.md)): One of the EmbedFlags

**Returns:** `void`

Embed specified fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, pass the list of new Fonts and the DontScanDocument flag. This will directly embed the fonts in the list without scanning the document.

### EmbedFonts

```csharp
void Datalogics.PDFL.Document.EmbedFonts(System.Collections.Generic.IList< Font > fonts, EmbedFlags flags, ProgressMonitor progressMonitor, CancelProc cancelProc, ReportProc reportProc)
```

**Parameters**

- `fonts` ([`System.Collections.Generic.IList< Font >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md)): The list of fonts to embed. See restrictions above.
- `flags` ([`EmbedFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EmbedFlags.md)): One of the EmbedFlags
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md)): a ProgressMonitor that will receive progress information, may be null
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md)): a CancelProc, which can return true to cancel the operation, may be null
- `reportProc` ([`ReportProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ReportProc.md)): a ReportProc, which will be called with warnings about fonts that do not embed, may be null

**Returns:** `void`

Embed specified fonts in a document.

To keep the changes the document must be saved. Fonts on the user's system that match the original font definition will be embedded. For the Times-Roman and Helvetica and corresponding styles, if displayed with a font alias, then the font alias will be embedded in the file. If the font has information that indicates the font cannot be embedded for print and preview, then the font will not be embedded in the document.

The fonts passed to this function must be fonts actually used in the current document. These fonts may be obtained by using the GetFonts or GetLoadedFonts functions, or obtained from a TextRun. Fonts created by name will not work in this context.

By default, the font embedding process scans the entire document for font usage information when subsetting fonts. For documents with large numbers of fonts or pages, this can take a long time. In cases where new Font objects are created and used to set text, it's not necessary to scan the entire document; instead, pass the list of new Fonts and the DontScanDocument flag. This will directly embed the fonts in the list without scanning the document.

### EmbedOCRFonts

```csharp
void Datalogics.PDFL.Document.EmbedOCRFonts()
```

**Returns:** `void`

Embed fonts that were used in creating OCR text.

This is also done automatically when saving.

### EnumIndirectPDFObjects

```csharp
bool Datalogics.PDFL.Document.EnumIndirectPDFObjects(PDFObjectEnumProc enumProc)
```

**Parameters**

- `enumProc` ([`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md)): A user-supplied callback to call for each indirect object in dP. Enumeration ends when enumProc returns false or all indirect objects have been enumerated. The value parameter returned in enumProc is always null.

**Returns:** `bool`

true if all of the calls to enumProc returned true. It returns false as soon as a call to enumProc returns false.

Enumerates all the indirect objects of this document.

The objects are enumerated in no particular order. Successive enumerations of the same Document are not guaranteed to enumerate objects in the same order.

This method does not enumerate invalid objects, which include objects that are defined as null, objects that are not defined at all (those having no cross-reference entry), and objects that are on the free list.

This re-raises any exception that proc raises.

### EnumResources

```csharp
void Datalogics.PDFL.Document.EnumResources(int startPage, int endPage, ResourceType resourceType, PDFObjectEnumProc enumProc)
```

**Parameters**

- `startPage` (`int`): The first page in the range of pages.
- `endPage` (`int`): The last page in the range of pages.
- `resourceType` ([`ResourceType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/ResourceType.md)): Resource type to enumerate.
- `enumProc` ([`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md)): A user-supplied callback to call once for each resource of the specified type. NOTE: The resource is the first parameter of the callback, the second is unused.

**Returns:** `void`

Enumerates the specified type of Page Resource, for a specified range of Pages.

This method enumerates resources in each page's Resources dictionary (ColorSpace, Font, ExtGState, etc.).

### ExportAcroFormsData

```csharp
bool Datalogics.PDFL.Document.ExportAcroFormsData(string fileName, AcroFormExportType exportType)
```

**Parameters**

- `fileName` (`string`): The path on disk of the file the AcroForms data is exported to.
- `exportType` ([`AcroFormExportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/AcroFormExportType.md)): The format type the AcroForm data should be exported to. The supported types are XFDF, FDF, and XML.

**Returns:** `bool`

true indicates exporting succeeded and false indicates an error occurred

Export the AcroForms data.

AcroForms data is exported into a format that can later be imported into another AcroForms document.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### ExportAsPostScript

```csharp
void Datalogics.PDFL.Document.ExportAsPostScript(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.
- `printProgressProc` ([`PrintProgressProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintProgressProc.md)): A PrintProgressProc, may be null.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### ExportAsPostScript

```csharp
void Datalogics.PDFL.Document.ExportAsPostScript(PrintUserParams userParams, PrintCancelProc printCancelProc, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### ExportAsPostScript

```csharp
void Datalogics.PDFL.Document.ExportAsPostScript(PrintUserParams userParams, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Exports a PDF document or pages from a PDF document as PostScript allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### ExportXFAFormsData

```csharp
bool Datalogics.PDFL.Document.ExportXFAFormsData(string fileName, XFAFormExportType exportType)
```

**Parameters**

- `fileName` (`string`): The path on disk of the file the XFA form data is exported to.
- `exportType` ([`XFAFormExportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/XFAFormExportType.md)): The format type the XFA data should be exported to. The supported types are XDP, XML, and XFD.

**Returns:** `bool`

true indicates exporting succeeded and false indicates an error occurred

Export the XFA Forms data.

XFA forms data is exported into a format that can later be imported into another XFA document.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### FindBookmark

```csharp
Bookmark Datalogics.PDFL.Document.FindBookmark(string title)
```

**Parameters**

- `title` (`string`): The title of the bookmark for which to search.

**Returns:** [`Bookmark`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Bookmark.md)

The bookmark within the document's bookmark tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.

Find bookmark by its title, searching within the document's entire bookmark tree.

### FindBookmark

```csharp
Bookmark Datalogics.PDFL.Document.FindBookmark(string title, int maxDepth)
```

**Parameters**

- `title` (`string`): The title of the bookmark for which to search.
- `maxDepth` (`int`): If supplied (with a value greater than or equal to 0), declares the number of levels below this bookmark to search. (If omitted, the entire subtree is searched.)

**Returns:** [`Bookmark`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Bookmark.md)

The bookmark within the document's bookmark tree that has the supplied title. Returns NULL if there is no bookmark with the supplied title.

Find bookmark by its title, searching within the document's bookmark tree to a depth determined by maxDepth (e.g., 0 = root bookmark only and not any of its children, 1 = search one level below root bookmark level, etc. Omit to search entire bookmark tree.)

### FindLabelForPageNum

```csharp
string Datalogics.PDFL.Document.FindLabelForPageNum(int pageIndex)
```

**Parameters**

- `pageIndex` (`int`): Index of a page in the Document

**Returns:** `string`

The label string for the page

Fetch the label string for a page index, using the current page labels.

### FindPDFObjectByID

```csharp
PDFObject Datalogics.PDFL.Document.FindPDFObjectByID(int ID)
```

**Parameters**

- `ID` (`int`): The object ID number to look up.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

The PDFObject with the specified ID, or null if no such object exists.

Retrieves an indirect PDFObject by its ID number.

Note that direct PDFObjects cannot be retrieved by ID.

### FindPageNumForLabel

```csharp
int Datalogics.PDFL.Document.FindPageNumForLabel(string label)
```

**Parameters**

- `label` (`string`): The label string to look up

**Returns:** `int`

The index of the corresponding page, or -1 if the label could not be matched

Look up a page index based on a label string.

### FlattenAcroFormFields

```csharp
void Datalogics.PDFL.Document.FlattenAcroFormFields()
```

**Returns:** `void`

Flatten a AcroForms document.

Interactive AcroForm fields are flattened into static PDF page content. All AcroForm fields are removed.

NOTE: This method is part of the APDFL Forms Extension that is available separately from APDFL. For more information, please see [https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### FlattenNonFormAnnotations

```csharp
void Datalogics.PDFL.Document.FlattenNonFormAnnotations()
```

**Returns:** `void`

Flatten a Non-Form (no AcroForm, no XFA) document's Annotations.

Annotations are flattened into static PDF page content.

NOTE: This method is part of the APDFL Forms Extension that is available separately from APDFL. For more information, please see [https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### FlattenOptionalContent

```csharp
bool Datalogics.PDFL.Document.FlattenOptionalContent()
```

**Returns:** `bool`

true if the document was successfully flattened, false otherwise.

Flattens optional content in the document.

Every page in the document will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made. All other optional content information will be removed from the document.

The document's default optional content context will be used to determine visibility of optional content.

### FlattenOptionalContent

```csharp
bool Datalogics.PDFL.Document.FlattenOptionalContent(OptionalContentContext occ)
```

**Parameters**

- `occ` ([`OptionalContentContext`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentContext.md)): The optional content context in which content is checked for visibility.

**Returns:** `bool`

true if the document was successfully flattened, false otherwise.

Flattens optional content in the document.

Every page in the document will be replaced with a version that has no optional content. The new version of the page will contain only what was visible on the page when the call was made. All other optional content information will be removed from the document.

### FlattenTransparency

```csharp
int Datalogics.PDFL.Document.FlattenTransparency()
```

**Returns:** `int`

The number of pages that were flattened.

Flattens all transparencies in the document. To flatten specific pages, see Document.FlattenTransparency(params, firstPage, lastPage)

Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

### FlattenTransparency

```csharp
int Datalogics.PDFL.Document.FlattenTransparency(FlattenTransparencyParams params_)
```

**Parameters**

- `params_` ([`FlattenTransparencyParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FlattenTransparencyParams.md))

**Returns:** `int`

The number of pages that were flattened.

Flattens all transparencies in the document. To flatten specific pages, see Document.FlattenTransparency(params, firstPage, lastPage)

Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

### FlattenTransparency

```csharp
int Datalogics.PDFL.Document.FlattenTransparency(FlattenTransparencyParams params_, int firstPage, int lastPage)
```

**Parameters**

- `params_` ([`FlattenTransparencyParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FlattenTransparencyParams.md))
- `firstPage` (`int`): The first page of the range of pages to flatten.
- `lastPage` (`int`): The last page of the range of pages to flatten.

**Returns:** `int`

The number of pages that were flattened.

Flattens transparencies in the document that occur on pages within the specified range. When performing flattening on multiple pages, this method is more efficient than making multiple Page.FlattenTransparency() calls.

Documents are flattened one at a time. In multi-threaded applications, threads that are making simultaneous calls to this method will block and execute the method sequentially.

### FlattenXFAFormFields

```csharp
uint Datalogics.PDFL.Document.FlattenXFAFormFields()
```

**Returns:** `uint`

the number of output pages created in the flattened document.

Flatten a XFA Document (Static or Dynamic).

XFA content is not widely supported by PDF processors, flattening this content transforms into static PDF page content that is part of typical PDF files that can easily be understood by PDF processors. All XFA fields are removed.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### FlattenXFAFormFieldsAsIfPrinted

```csharp
uint Datalogics.PDFL.Document.FlattenXFAFormFieldsAsIfPrinted()
```

**Returns:** `uint`

the number of output pages created in the flattened document.

Flatten a XFA Document (Static or Dynamic) as if it was Printed.

XFA content is not widely supported by PDF processors, flattening this content transforms into static PDF page content that is part of typical PDF files that can easily be understood by PDF processors. All XFA fields are removed.

The Flattened appearance will take into consideration how the document should appear when printed.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### GetFonts

```csharp
System.Collections.Generic.IList< Font > Datalogics.PDFL.Document.GetFonts(int firstPage, int lastPage)
```

**Parameters**

- `firstPage` (`int`): The page number of the first page for which fonts are enumerated. The first page is 0.
- `lastPage` (`int`): The page number of the last page for which fonts are enumerated.

**Returns:** [`System.Collections.Generic.IList< Font >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Font.md)

A list of Font objects found in the specified page range.

Get all the fonts in the specified page range.

This may take a considerable amount of time for a large page range.

### GetInfo

```csharp
string Datalogics.PDFL.Document.GetInfo(string infoname)
```

**Parameters**

- `infoname` (`string`): The name of metadata which value will be obtained.

**Returns:** `string`

The value of the metadata obtained from the PDF file.

Gets the value of metadata information in a PDF file.

### GetNameTree

```csharp
NameTree Datalogics.PDFL.Document.GetNameTree(string nameTreeName)
```

**Parameters**

- `nameTreeName` (`string`): The name of the NameTree to get.

**Returns:** [`NameTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NameTree.md)

The retrieved NameTree.

Retrieves the name tree inside the Names dictionary with the specified key name.

### GetPage

```csharp
Page Datalogics.PDFL.Document.GetPage(int pageNumber)
```

**Parameters**

- `pageNumber` (`int`): The page number of the page to acquire. The first page is 0.

**Returns:** [`Page`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Page.md)

The requested Page object.

Gets a Page from a document.

### GetXMPMetadataArrayItem

```csharp
string Datalogics.PDFL.Document.GetXMPMetadataArrayItem(string namespaceName, string path, int index)
```

**Parameters**

- `namespaceName` (`string`): The XML namespace URI for the schema in which the property is to be found.
- `path` (`string`): The name of the desired simple property.
- `index` (`int`): The index in the metadata property array associated with the property.

**Returns:** `string`

a string containing the XML text of the value of the specified property in the XMP metadata associated with the Document, or an empty string if no such property is found.

Gets the value of an XMP metadata array item, associated with a document, based on an index.

### GetXMPMetadataProperty

```csharp
string Datalogics.PDFL.Document.GetXMPMetadataProperty(string namespaceName, string path)
```

**Parameters**

- `namespaceName` (`string`): The XML namespace URI for the schema in which the property is to be found.
- `path` (`string`): The name of the desired simple property. Note that XMP properties can have an XML substructure; this method can only retrieve values from simple textual properties.

**Returns:** `string`

A string containing the XML text of the value of the specified property, or an empty string if no such property is found.

Gets the value of an XMP metadata property associated with a document.

It returns the XML text of the value of the specified property in the XMP metadata associated with the Document. The XMP metadata can represent all properties in the Document object's Info dictionary, as well as other properties.

### ImportAcroFormsData

```csharp
bool Datalogics.PDFL.Document.ImportAcroFormsData(string fileName, AcroFormImportType importType)
```

**Parameters**

- `fileName` (`string`): The path on disk of the AcroFormsdata file to be imported.
- `importType` ([`AcroFormImportType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/AcroFormImportType.md)): The format type the data type should be imported to. The supported types are XFDF, FDF, and XML.

**Returns:** `bool`

true indicates importing succeeded and false indicates an error occurred

Import the AcroForms data.

AcroForms data is imported from a supported format into the AcroForms document so its existing fields can be populated for example.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### ImportXFAFormsData

```csharp
bool Datalogics.PDFL.Document.ImportXFAFormsData(string fileName)
```

**Parameters**

- `fileName` (`string`): The path on disk of the XFA form data file to be imported, the supported types of data that can be imported are XDP, XML, and XFD.

**Returns:** `bool`

true indicates importing succeeded and false indicates an error occurred

Import the XFA Forms data.

XFA forms data is imported from a supported format into the XFA document so its existing fields can be populated for example.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### InsertPages

```csharp
void Datalogics.PDFL.Document.InsertPages(int mergeAfterThisPage, Document doc2, int startPage, int numPages, PageInsertFlags insertFlags)
```

**Parameters**

- `mergeAfterThisPage` (`int`): The page number in doc after which pages from doc2 are inserted. The first page is 0. If Document.BeforeFirstPage is used, the pages are inserted before the first page in doc. Use Document.LastPage to insert pages after the last page in doc.
- `doc2` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): The document containing the pages that are inserted into doc.
- `startPage` (`int`): The page number of the first page in doc2 to insert into doc. The first page is 0.
- `numPages` (`int`): The number of pages in doc2 to insert into doc. Use Document.AllPages to insert all pages from doc2 into doc.
- `insertFlags` ([`PageInsertFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageInsertFlags.md)): Flags that determine what additional information is copied from doc2 into doc. It is an OR of the following constants: PageInsertFlags.Bookmarks, PageInsertFlags.Threads, PageInsertFlags.All

**Returns:** `void`

Inserts numPages pages from doc2 into doc. All annotations, and anything else associated with the page (such as a thumbnail image) are copied from the doc2 pages to the new pages in doc. This method does not insert pages if doc equals doc2.

The insertFlags parameter controls whether bookmarks and threads are inserted along with the specified pages. Setting this parameter to PageInsertFlags.All has two effects:

The parameters indicating which pages to insert are ignored: all the pages of doc2 are inserted.
In addition to inserting the pages themselves, it also merges other document data from doc2 into doc:Named destinations from doc2 (of PDF 1.1 and later) are copied into doc. If there are named destinations in doc2 with the same name as some named destination in doc, the ones in doc retain their names and the copied named destinations are given new names based on the old ones, with distinguishing digits added. Actions and bookmarks referring to the old names are made to refer to the new names after being copied into doc.
If it is also the case that mergeAfterThisPage denotes the last page of the document, then document metadata is merged, and the optional content properties are merged in a more symmetrical manner than would otherwise be the case.

Document logical structure from doc2 is copied into doc. If less than the whole of doc2 is being inserted, only those structure elements having content on the copied pages, and the ancestors of those elements, are copied into the logical structure tree of doc. The top-level children of the structure tree root of doc2 are copied as new top-level children of the structure tree root of doc; a structure tree root is created in doc if there was none before. The role maps of the two structure trees are merged, with name conflicts resolved in favor of the role mappings present in doc. Attribute objects having scalar values, or values that are arrays of scalar values, are copied. Class map information from doc2 is also merged into that for doc.

### InsertPages

```csharp
void Datalogics.PDFL.Document.InsertPages(int mergeAfterThisPage, Document doc2, int startPage, int numPages, PageInsertFlags insertFlags, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `mergeAfterThisPage` (`int`): The page number in doc after which pages from doc2 are inserted. The first page is 0. If Document.BeforeFirstPage is used, the pages are inserted before the first page in doc. Use Document.LastPage to insert pages after the last page in doc.
- `doc2` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): The document containing the pages that are inserted into doc.
- `startPage` (`int`): The page number of the first page in doc2 to insert into doc. The first page is 0.
- `numPages` (`int`): The number of pages in doc2 to insert into doc. Use Document.AllPages to insert all pages from doc2 into doc.
- `insertFlags` ([`PageInsertFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PageInsertFlags.md)): Flags that determine what additional information is copied from doc2 into doc. It is an OR of the following constants: PageInsertFlags.Bookmarks, PageInsertFlags.Threads, PageInsertFlags.All
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md)): a ProgressMonitor that will receive progress information, may be null
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md)): a CancelProc, which can return true to cancel the operation, may be null

**Returns:** `void`

Inserts numPages pages from doc2 into doc. All annotations, and anything else associated with the page (such as a thumbnail image) are copied from the doc2 pages to the new pages in doc. This method does not insert pages if doc equals doc2.

The insertFlags parameter controls whether bookmarks and threads are inserted along with the specified pages. Setting this parameter to PageInsertFlags.All has two effects:

The parameters indicating which pages to insert are ignored: all the pages of doc2 are inserted.
In addition to inserting the pages themselves, it also merges other document data from doc2 into doc:Named destinations from doc2 (of PDF 1.1 and later) are copied into doc. If there are named destinations in doc2 with the same name as some named destination in doc, the ones in doc retain their names and the copied named destinations are given new names based on the old ones, with distinguishing digits added. Actions and bookmarks referring to the old names are made to refer to the new names after being copied into doc.
If it is also the case that mergeAfterThisPage denotes the last page of the document, then document metadata is merged, and the optional content properties are merged in a more symmetrical manner than would otherwise be the case.

Document logical structure from doc2 is copied into doc. If less than the whole of doc2 is being inserted, only those structure elements having content on the copied pages, and the ancestors of those elements, are copied into the logical structure tree of doc. The top-level children of the structure tree root of doc2 are copied as new top-level children of the structure tree root of doc; a structure tree root is created in doc if there was none before. The role maps of the two structure trees are merged, with name conflicts resolved in favor of the role mappings present in doc. Attribute objects having scalar values, or values that are arrays of scalar values, are copied. Class map information from doc2 is also merged into that for doc.

### IsDynamicXFA

```csharp
bool Datalogics.PDFL.Document.IsDynamicXFA()
```

**Returns:** `bool`

true indicates the Document is Dynamic XFA, false indicates it is not

Indicates if the document is Dynamic XFA.

Dynamic XFA documents can change in appearance in response to changes in the data. They don't contain a meaningful PDF representation. Such XFA content is not widely supported by PDF processors.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### IsStaticXFA

```csharp
bool Datalogics.PDFL.Document.IsStaticXFA()
```

**Returns:** `bool`

true indicates the Document is Static XFA, false indicates it is not

Indicates if the document is Static XFA.

Static XFA documents have a fixed appearance and layout. They usually contain a meaningful PDF representation. Such XFA content is not widely supported by PDF processors.

[https://www.datalogics.com/pdf-form-functions](https://www.datalogics.com/pdf-form-functions).

### LookForKidsInNameTree

```csharp
void Datalogics.PDFL.Document.LookForKidsInNameTree(PDFDict nameTree, System.Collections.Generic.IList< FileAttachment > attachments)
```

**Parameters**

- `nameTree` ([`PDFDict`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFDict.md))
- `attachments` ([`System.Collections.Generic.IList< FileAttachment >`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/FileAttachment.md))

**Returns:** `void`

### MergeXMPKeywords

```csharp
void Datalogics.PDFL.Document.MergeXMPKeywords()
```

**Returns:** `void`

Causes a string produced as by PDDocGetMergedXAPKeywords() to be stored as the new value of the pdf:Keywords property, and the former value of the pdf:Keywords property to be stored as an item in the xmp:Keywords bag of keyword items.

The algorithm used to compute merged keywords lists detects the case in which the keywords lists have already been merged and makes no changes to the XMP metadata in this case.

### MovePage

```csharp
void Datalogics.PDFL.Document.MovePage(int moveToAfterThisPage, int pageToMove)
```

**Parameters**

- `moveToAfterThisPage` (`int`): The new location of the page to move. The first page is 0. It may either be a page number, or the constant Document.BeforeFirstPage.
- `pageToMove` (`int`): The page number of the page to move.

**Returns:** `void`

Moves one page in a document.

### PermRequest

```csharp
bool Datalogics.PDFL.Document.PermRequest(PermissionRequestOperation requestedperm)
```

**Parameters**

- `requestedperm` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionRequestOperation.md)): The document permission which to check

**Returns:** `bool`

a boolean if the permission is set in the document.

Tests if a permission is set on a document

### PermRequest

```csharp
bool Datalogics.PDFL.Document.PermRequest(string password, PermissionRequestOperation perms)
```

**Parameters**

- `password` (`string`): The document password which authorizes the change. Note - if this argument is set to a NULL (""), then the return will be an indicator of whether or not the requested permission is already set in this document, with no changes made to the PDF document.
- `perms` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionRequestOperation.md)): the permissions on the PDF file which is to be set or checked.

**Returns:** `bool`

a boolean if the permission change is successful or if the permission was set.

Request the permissions to be changed on a PDF document. This takes effect immediately

### Print

```csharp
void Datalogics.PDFL.Document.Print(PrintUserParams userParams)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

### Print

```csharp
void Datalogics.PDFL.Document.Print(PrintUserParams userParams, PrintCancelProc printCancelProc)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

### Print

```csharp
void Datalogics.PDFL.Document.Print(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.
- `printProgressProc` ([`PrintProgressProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintProgressProc.md)): A PrintProgressProc, may be null.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

### PrintToFile

```csharp
void Datalogics.PDFL.Document.PrintToFile(PrintUserParams userParams, PrintCancelProc printCancelProc, PrintProgressProc printProgressProc, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.
- `printProgressProc` ([`PrintProgressProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintProgressProc.md)): A PrintProgressProc, may be null.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### PrintToFile

```csharp
void Datalogics.PDFL.Document.PrintToFile(PrintUserParams userParams, PrintCancelProc printCancelProc, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `printCancelProc` ([`PrintCancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintCancelProc.md)): A PrintCancelProc, which can return true to cancel printing, may be null.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### PrintToFile

```csharp
void Datalogics.PDFL.Document.PrintToFile(PrintUserParams userParams, string path)
```

**Parameters**

- `userParams` ([`PrintUserParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PrintUserParams.md)): Parameters to control printing.
- `path` (`string`): The output file to be created.

**Returns:** `void`

Prints a PDF document or pages from a PDF document allowing the caller to specify options such as page size, rotation, and shrink-to-fit.

The output is placed in the specified file.

### RemoveCollection

```csharp
void Datalogics.PDFL.Document.RemoveCollection()
```

**Returns:** `void`

RemoveCollection Removes a collection dictionary from a document.

### RemoveDuplicateOCG

```csharp
void Datalogics.PDFL.Document.RemoveDuplicateOCG()
```

**Returns:** `void`

Removes duplicate optional content group from the document. This does not remove any content associated with the duplicate group,

### RemoveNameTree

```csharp
void Datalogics.PDFL.Document.RemoveNameTree(string nameTreeName)
```

**Parameters**

- `nameTreeName` (`string`): The name of the NameTree to remove.

**Returns:** `void`

Removes the name tree inside the Names dictionary with the specified key name. It does nothing if no object with that name exists.

### RemoveOCG

```csharp
void Datalogics.PDFL.Document.RemoveOCG(OptionalContentGroup ocg)
```

**Parameters**

- `ocg` ([`OptionalContentGroup`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/OptionalContentGroup.md)): The optional content group to remove.

**Returns:** `void`

Removes the specified optional content group from the document. This does not remove any content associated with the specified group, only the group itself.

### ReplacePages

```csharp
void Datalogics.PDFL.Document.ReplacePages(int startPage, Document doc2, int startPageDoc2, int numPages, bool mergeTextAnnots)
```

**Parameters**

- `startPage` (`int`): The first page number in doc to replace. The first page is 0.
- `doc2` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): The document from which pages are copied into doc.
- `startPageDoc2` (`int`): The page number of the first page in doc2 to copy. The first page is 0.
- `numPages` (`int`): The number of pages to replace.
- `mergeTextAnnots` (`bool`): If true, text annotations from doc2 are appended if they are different than all existing annotations on the page in doc. No other types of annotations are copied.

**Returns:** `void`

Replaces the specified range of pages in one document with pages from another. The contents, resources, size and rotation of the pages are replaced. The bookmarks are not copied, because they are attached to the document, not to individual pages.

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags flags, System.IO.Stream stream)
```

**Parameters**

- `flags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.
- `stream` (`System.IO.Stream`): The Stream to which the file is saved.

**Returns:** `void`

Saves a Document to a Stream.

The save is always performed as a full, copy save. The Document remains open with the original file.

If the document was created with Document(), at least one page must be added using CreatePage() or InsertPages() before the Document can be saved.

A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new Cos object number.

If SaveFlags.CloseAfterSave flag has been specified the document will be closed immediately after save and it won't be valid anymore. If one needs this document outside of the stream it has been saved to, one has to reopen the document and recreate all the dependent objects such as Page, Image etc.

If both SaveFlags.FULL and SaveFlags.COPY are used during saving partially or fully compressed document to the stream that SaveFlags.CLOSE_AFTER_SAVE must be specified.

It is advisable to call EmbedFonts before saving a document, in case any fonts were created automatically to support Unicode text.

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags flags, System.IO.Stream stream, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `flags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md))
- `stream` (`System.IO.Stream`)
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md))
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md))

**Returns:** `void`

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags saveFlags)
```

**Parameters**

- `saveFlags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.

**Returns:** `void`

Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to the save file name.

A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags saveFlags, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `saveFlags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md)): a ProgressMonitor that will receive progress information, may be null
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md)): a CancelProc, which can return true to cancel the operation, may be null

**Returns:** `void`

Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to the save file name.

A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags saveFlags, string newPath)
```

**Parameters**

- `saveFlags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.
- `newPath` (`string`): The path to which the file is saved. A path must be specified when either SaveFlags.Full or SaveFlags.Copy are used for saveFlags. If SaveFlags.Incremental is specified in saveFlags, then newPath should be NULL. If SaveFlags.Full is specified and newPath is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to newPath.

**Returns:** `void`

Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to newPath.

If the document was created with Document, at least one page must be added using CreatePage() orInsertPages() before a PDF Viewer can save the document.

A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

### Save

```csharp
void Datalogics.PDFL.Document.Save(SaveFlags saveFlags, string newPath, ProgressMonitor progressMonitor, CancelProc cancelProc)
```

**Parameters**

- `saveFlags` ([`SaveFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.
- `newPath` (`string`): The path to which the file is saved. A path must be specified when either SaveFlags.Full or SaveFlags.Copy are used for saveFlags. If SaveFlags.Incremental is specified in saveFlags, then newPath should be NULL. If SaveFlags.Full is specified and newPath is the same as the file's original path, the new file is saved to a file system-determined temporary path, then the old file is deleted and the new file is renamed to newPath.
- `progressMonitor` ([`ProgressMonitor`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/ProgressMonitor.md)): a ProgressMonitor that will receive progress information, may be null
- `cancelProc` ([`CancelProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/CancelProc.md)): a CancelProc, which can return true to cancel the operation, may be null

**Returns:** `void`

Saves a document to disk. If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to newPath.

If the document was created with Document, at least one page must be added using CreatePage() orInsertPages() before a PDF Viewer can save the document.

A full save with linearization optimizes the PDF file. During optimization, all objects in a PDF file are rearranged, many of them acquiring not only a new file position, but also a new PDFObject number. At the end of the save operation, PDFL flushes its information of the PD layer and below to synchronize its in-memory state with the new disk file just written.

If the document has a signature, it will be saved incrementally regardless of the full save flag. This is required to preserve the exact contents of the document at the time of signing.

### Secure

```csharp
void Datalogics.PDFL.Document.Secure(PermissionFlags permissions, string ownerPassword, string userPassword)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionFlags.md)): an "OR" of the types of PDF document specified by Permissions:
- `ownerPassword` (`string`): optional PDF document owner password; pass null if not used.
- `userPassword` (`string`): optional PDF document user password; pass null if not used.

**Returns:** `void`

Secure the PDF document securely with password(s).

If the document has a security handler, it is retained. If the document does not have a security handler, it is assigned the "Standard" security handler with a 16-bit encryption key length. Access permissions as well as owner and user passwords are assigned to the PDF document. This method by default encrypts PDF's content as well as its metadata. To make selective encryption use appropriate overload of Secure() method.

The document must be saved for the changes to take effect. A full save is required.

### Secure

```csharp
void Datalogics.PDFL.Document.Secure(PermissionFlags permissions, string ownerPassword, string userPassword, EncryptionType encryptionType)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionFlags.md)): an "OR" of the types of PDF document specified by Permissions:
- `ownerPassword` (`string`): optional PDF document owner password; pass null if not used.
- `userPassword` (`string`): optional PDF document user password; pass null if not used.
- `encryptionType` ([`EncryptionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EncryptionType.md)): Encryption type to be used for securing the document.

**Returns:** `void`

Secure the PDF document securely with password(s).

The security handler used for the document depends on the encryption type specified. Access permissions as well as owner and user passwords are assigned to the PDF document. This method by default encrypts PDF's content as well as its metadata. To make selective encryption use appropriate overload of Secure() method.

The document must be saved for the changes to take effect. A full save is required.

### Secure

```csharp
void Datalogics.PDFL.Document.Secure(PermissionFlags permissions, string ownerPassword, string userPassword, EncryptionType encryptionType, bool encryptMetadata)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PermissionFlags.md)): an "OR" of the types of PDF document specified by Permissions:
- `ownerPassword` (`string`): optional PDF document owner password; pass null if not used.
- `userPassword` (`string`): optional PDF document user password; pass null if not used.
- `encryptionType` ([`EncryptionType`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/EncryptionType.md)): Encryption type to be used for securing the document.
- `encryptMetadata` (`bool`): A flag that indicates whether document metadata will be encrypted.

**Returns:** `void`

Secure the PDF document securely with password(s).

The security handler used for the document depends on the encryption type specified. Access permissions as well as owner and user passwords are assigned to the PDF document. This method allows selective encryption. Depending on encryptMetadata parameter, it may or may not encrypt PDF's metadata.

The document must be saved for the changes to take effect. A full save is required.

### SetInfo

```csharp
void Datalogics.PDFL.Document.SetInfo(string infoname, string infovalue)
```

**Parameters**

- `infoname` (`string`): The name of metadata to be set
- `infovalue` (`string`): The value for metadata which will be set

**Returns:** `void`

Sets metadata information in a PDF document.

### SetXMPMetadataArrayItem

```csharp
void Datalogics.PDFL.Document.SetXMPMetadataArrayItem(string namespaceName, string namespacePrefix, string path, int index, string newValue)
```

**Parameters**

- `namespaceName` (`string`): The XML namespace URI for the schema in which the property is to be found.
- `namespacePrefix` (`string`): A brief string to be used as an abbreviation when creating the XML representation of the property. This string must not be empty.
- `path` (`string`): The name of the simple property to be modified.
- `index` (`int`): The index in the metadata property array associated with the property.
- `newValue` (`string`): The new XML text value for the property.

**Returns:** `void`

Sets the value of an XMP metadata array item, associated with a document, based on an index.

### SetXMPMetadataProperty

```csharp
void Datalogics.PDFL.Document.SetXMPMetadataProperty(string namespaceName, string namespacePrefix, string path, string newValue)
```

**Parameters**

- `namespaceName` (`string`): The XML namespace URI for the schema in which the property is to be found.
- `namespacePrefix` (`string`): A brief string to be used as an abbreviation when creating the XML representation of the property. This string must not be empty.
- `path` (`string`): The name of the simple property to be modified.
- `newValue` (`string`): The new XML text value for the property.

**Returns:** `void`

Sets the value of an XMP metadata property associated with a document. The XMP metadata represents all the properties in pdDoc object's Info dictionary, and can also contain properties that are not in the Info dictionary.

### Unsecure

```csharp
void Datalogics.PDFL.Document.Unsecure()
```

**Returns:** `void`

Remove security handler from the PDF document.

If the document has a security handler, it is removed. If the document does not have a security handler, this method does nothing.

To remove the security handler, you must hold the PermissionRequestOperation.Secure permission, which you can obtain via Document.PermRequest. This call will throw an ApplicationException if you do not hold the Secure permission.

The document must be saved for the changes to take effect. A full save is required.

### Watermark

```csharp
void Datalogics.PDFL.Document.Watermark(Page page, WatermarkParams watermarkParams)
```

**Parameters**

- `page` ([`Page`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Page.md)): The page to be added as a watermark.
- `watermarkParams` ([`WatermarkParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WatermarkParams.md)): Structure specifying how the watermark should be added to the document.

**Returns:** `void`

Adds a Page as a watermark to a page range in the given document.

### Watermark

```csharp
void Datalogics.PDFL.Document.Watermark(WatermarkTextParams watermarkTextParams, WatermarkParams watermarkParams)
```

**Parameters**

- `watermarkTextParams` ([`WatermarkTextParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WatermarkTextParams.md)): Structure describing the text-based watermark to be added.
- `watermarkParams` ([`WatermarkParams`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/WatermarkParams.md)): Structure specifying how the watermark should be added to the document.

**Returns:** `void`

Adds a text-based watermark to a page range in the given document.
