# Document Class

> The underlying PDF representation of a document.

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

```cpp
class Document
```

**Namespace:** `datalogics_interface`

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

Threading: single-thread use. A `Document` is bound to the `Library` active on the thread where it was constructed. Do not share `Document` instances across threads. See `datalogics_interface.hpp` for the full threading model.

**Referenced by:** [`ConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/ConvertResult.md), [`WebConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/WebConvertResult.md)

**Uses types:** [`AcroFormExportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/AcroFormExportType.md), [`AcroFormImportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/AcroFormImportType.md), [`Bookmark`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md), [`Collection`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Collection.md), [`ConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/ConvertResult.md), [`EncryptionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/EncryptionType.md), [`Font`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Font.md), [`NameTree`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md), [`PDFAConvertType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PDFAConvertType.md), [`PDFDict`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md), [`PDFObject`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md), [`PDFXConvertType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PDFXConvertType.md), [`Page`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Page.md), [`PageInsertFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PageInsertFlags.md), [`PageLabel`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PageLabel.md), [`PageMode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PageMode.md), [`PermissionFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionFlags.md), [`PermissionRequestOperation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionRequestOperation.md), [`SaveFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SaveFlags.md), [`StructTreeRoot`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/StructTreeRoot.md), [`WebConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/WebConvertResult.md), [`XFAFormExportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/XFAFormExportType.md)

## Constructors

### Document

```cpp
datalogics_interface::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

```cpp
datalogics_interface::Document::Document(const std::string &file_name)
```

*constructor*

**Parameters**

- `file_name` (`const std::string &`)

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

```cpp
datalogics_interface::Document::Document(const std::string &file_name, const std::string &password, bool do_repair=false)
```

*constructor*

**Parameters**

- `file_name` (`const std::string &`)
- `password` (`const std::string &`)
- `do_repair` (`bool`)

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

```cpp
datalogics_interface::Document::Document(const std::string &xps_file, XPSConvertParams &params)
```

*constructor*

**Parameters**

- `xps_file` (`const std::string &`)
- `params` ([`XPSConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/XPSConvertParams.md))

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

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

*constructor*

**Parameters**

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

### Document

```cpp
datalogics_interface::Document::Document(std::istream &input_stream)
```

*constructor*

**Parameters**

- `input_stream` (`std::istream &`)

Open a document from an input stream. The stream must remain valid for the lifetime of the Document.

### Document

```cpp
datalogics_interface::Document::Document(std::istream &input_stream, const std::string &password, bool do_repair=false)
```

*constructor*

**Parameters**

- `input_stream` (`std::istream &`)
- `password` (`const std::string &`)
- `do_repair` (`bool`)

Open a password-protected document from an input stream.

### ~Document

```cpp
datalogics_interface::Document::~Document()
```

*destructor*

Closes that document and releases its resources. Changes are not saved. You must use Save() to save any modifications before destroying this object.

## Fields

### all_pages

```cpp
static int datalogics_interface::Document::all_pages
```

*static*

All pages sentinel.

### before_first_page

```cpp
static int datalogics_interface::Document::before_first_page
```

*static*

Before first page sentinel.

### last_page

```cpp
static int datalogics_interface::Document::last_page
```

*static*

Last page sentinel.

## Methods

### apply_redactions

```cpp
bool datalogics_interface::Document::apply_redactions()
```

**Returns:** `bool`

Apply redactions to the document.

### apply_redactions

```cpp
bool datalogics_interface::Document::apply_redactions(Redaction &redaction)
```

**Parameters**

- `redaction` ([`Redaction &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Redaction.md)): the redaction to apply, or NULL to apply all redactions in the document.

**Returns:** `bool`

Apply redactions to the document.

### clone_as_pdfa_document

```cpp
ConvertResult datalogics_interface::Document::clone_as_pdfa_document(PDFAConvertType type, const PDFAConvertParams &params)
```

**Parameters**

- `type` ([`PDFAConvertType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PDFAConvertType.md)): The type of PDF/A conversion to perform
- `params` ([`const PDFAConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFAConvertParams.md)): A PDFAConvertParams object specifying options for the conversion

**Returns:** [`ConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/ConvertResult.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 "1" and "4" respectively. This is required for PDF/A compliance.

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

### clone_as_pdfx_document

```cpp
ConvertResult datalogics_interface::Document::clone_as_pdfx_document(PDFXConvertType type, const PDFXConvertParams &params)
```

**Parameters**

- `type` ([`PDFXConvertType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PDFXConvertType.md)): The type of PDF/X conversion to perform
- `params` ([`const PDFXConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFXConvertParams.md)): A PDFXConvertParams object specifying options for the conversion

**Returns:** [`ConvertResult`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/ConvertResult.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 "1" and "4" respectively. This is required for PDF/X compliance.

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

### close

```cpp
void datalogics_interface::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.

### color_convert_pages

```cpp
bool datalogics_interface::Document::color_convert_pages(const ColorConvertParams &params)
```

**Parameters**

- `params` ([`const ColorConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorConvertParams.md)): the color conversion parameters specifying the ICC profile to apply.

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

### convert_to_excel

```cpp
static bool datalogics_interface::Document::convert_to_excel(const std::string &input_path, const std::string &output_path)
```

*static*

**Parameters**

- `input_path` (`const std::string &`): The PDF file path to convert.
- `output_path` (`const std::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.

**Note:** Only available on Windows. Throws std::runtime_error on other platforms.

### convert_to_powerpoint

```cpp
static bool datalogics_interface::Document::convert_to_powerpoint(const std::string &input_path, const std::string &output_path)
```

*static*

**Parameters**

- `input_path` (`const std::string &`): The PDF file path to convert.
- `output_path` (`const std::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.

**Note:** Only available on Windows. Throws std::runtime_error on other platforms.

### convert_to_word

```cpp
static bool datalogics_interface::Document::convert_to_word(const std::string &input_path, const std::string &output_path)
```

*static*

**Parameters**

- `input_path` (`const std::string &`): The PDF file path to convert.
- `output_path` (`const std::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.

**Note:** Only available on Windows. Throws std::runtime_error on other platforms.

### convert_xfa_to_acroform

```cpp
int datalogics_interface::Document::convert_xfa_to_acroform()
```

**Returns:** `int`

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.

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

### count_xmp_metadata_array_items

```cpp
int datalogics_interface::Document::count_xmp_metadata_array_items(const std::string &ns, const std::string &path) const
```

**Parameters**

- `ns` (`const std::string &`): The XML namespace URI for the schema in which the property is to be found.
- `path` (`const std::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.

### create_collection

```cpp
void datalogics_interface::Document::create_collection()
```

**Returns:** `void`

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

### create_name_tree

```cpp
std::unique_ptr< NameTree > datalogics_interface::Document::create_name_tree(const std::string &name)
```

**Parameters**

- `name` (`const std::string &`): The name of the NameTree to create.

**Returns:** [`std::unique_ptr< NameTree >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

### create_page

```cpp
Page datalogics_interface::Document::create_page(int after_page_num, const Rect &media_box)
```

**Parameters**

- `after_page_num` (`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.
- `media_box` ([`const Rect &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Rect.md)): A rectangle specifying the page's media box, specified in user space coordinates.

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

The newly created page.

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

### create_struct_tree_root

```cpp
StructTreeRoot datalogics_interface::Document::create_struct_tree_root()
```

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

Creates a StructTreeRoot in the catalog; throws std::logic_error if one already exists. Also sets /MarkInfo {/Marked true} in the catalog.

### delete_pages

```cpp
void datalogics_interface::Document::delete_pages(int first_page, int last_page)
```

**Parameters**

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

**Returns:** `void`

Deletes the specified pages.

### embed_fonts

```cpp
void datalogics_interface::Document::embed_fonts()
```

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

### embed_ocr_fonts

```cpp
void datalogics_interface::Document::embed_ocr_fonts()
```

**Returns:** `void`

Embed fonts that were used in creating OCR text.

This is also done automatically when saving.

### export_acro_forms_data

```cpp
bool datalogics_interface::Document::export_acro_forms_data(const std::string &path, AcroFormExportType type)
```

**Parameters**

- `path` (`const std::string &`): The path on disk of the file the AcroForms data is exported to.
- `type` ([`AcroFormExportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

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

### export_as_postscript

```cpp
void datalogics_interface::Document::export_as_postscript(PrintUserParams &params, const std::string &path)
```

**Parameters**

- `params` ([`PrintUserParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PrintUserParams.md)): Parameters to control printing.
- `path` (`const std::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.

### export_xfa_forms_data

```cpp
bool datalogics_interface::Document::export_xfa_forms_data(const std::string &path, XFAFormExportType type)
```

**Parameters**

- `path` (`const std::string &`): The path on disk of the file the XFA form data is exported to.
- `type` ([`XFAFormExportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

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

### find_bookmark

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Document::find_bookmark(const std::string &title)
```

**Parameters**

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

**Returns:** [`std::unique_ptr< Bookmark >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.)

### find_bookmark

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Document::find_bookmark(const std::string &title, int max_depth)
```

**Parameters**

- `title` (`const std::string &`): - The title of the bookmark for which to search.
- `max_depth` (`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:** [`std::unique_ptr< Bookmark >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.)

### find_label_for_page_num

```cpp
std::string datalogics_interface::Document::find_label_for_page_num(int page_index) const
```

**Parameters**

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

**Returns:** `std::string`

The label string for the page

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

### find_page_num_for_label

```cpp
int datalogics_interface::Document::find_page_num_for_label(const std::string &label) const
```

**Parameters**

- `label` (`const std::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.

### find_pdf_object_by_id

```cpp
std::unique_ptr< PDFObject > datalogics_interface::Document::find_pdf_object_by_id(int id) const
```

**Parameters**

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

**Returns:** [`std::unique_ptr< PDFObject >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

### flatten_acro_form_fields

```cpp
void datalogics_interface::Document::flatten_acro_form_fields()
```

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

### flatten_transparency

```cpp
int datalogics_interface::Document::flatten_transparency()
```

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

### flatten_transparency

```cpp
int datalogics_interface::Document::flatten_transparency(const FlattenTransparencyParams &params)
```

**Parameters**

- `params` ([`const FlattenTransparencyParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

### flatten_transparency

```cpp
int datalogics_interface::Document::flatten_transparency(const FlattenTransparencyParams &params, int first_page, int last_page)
```

**Parameters**

- `params` ([`const FlattenTransparencyParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/FlattenTransparencyParams.md))
- `first_page` (`int`)
- `last_page` (`int`)

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

### flatten_xfa_form_fields

```cpp
int datalogics_interface::Document::flatten_xfa_form_fields()
```

**Returns:** `int`

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.

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

### for_each_indirect_object

```cpp
void datalogics_interface::Document::for_each_indirect_object(const std::function< bool(PDFObject &)> &callback) const
```

**Parameters**

- `callback` (`const std::function< bool(PDFObject &)> &`): 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:** `void`

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

Enumerate every indirect PDF object in this document. The callback receives a reference to each indirect object in turn and should return true to continue or false to stop enumeration. Order is undefined and may differ between calls. 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.

### from_html_file

```cpp
static WebConvertResult datalogics_interface::Document::from_html_file(const std::string &path, const WebConvertParams &params)
```

*static*

**Parameters**

- `path` (`const std::string &`)
- `params` ([`const WebConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WebConvertParams.md))

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

Render a local HTML file. Relative asset references are resolved against the file's directory. Throws WebConvertError on read/render failure. Throws OperationCancelledException if the progress callback returns false. On platforms where the WebToPDF plugin is not supported, throws WebConvertError(Category::PluginUnavailable). See the threading note above this declaration. Render a local HTML file. Forwards to FromWebUrl with a "file://" scheme prepended to path. Same platform-unsupported behavior and same return- shape semantics as FromWebUrl.

### from_web_url

```cpp
static WebConvertResult datalogics_interface::Document::from_web_url(const std::string &url, const WebConvertParams &params)
```

*static*

**Parameters**

- `url` (`const std::string &`)
- `params` ([`const WebConvertParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WebConvertParams.md))

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

Render a live web page (http/https) and produce a Document. Throws WebConvertError on fetch/render failure. Throws OperationCancelledException if the progress callback returns false. On platforms where the WebToPDF plugin is not supported, throws WebConvertError(Category::PluginUnavailable). See the threading note above this declaration. Render a URL (http/https or [file://](file://)) into a Document. Calls CWebToPDFLifecycle::EnsureReady() first; rethrows CWebConvertError on any plugin failure. info_out is populated on success.

Returns a heap-allocated CDocument (same pattern as the PDF/A and PDF/X clone paths) so the Document::Impl adopting ctor can take ownership without invoking CDocument's copy ctor, which is known to error in post- terminate teardown states. The caller owns the returned pointer.

The returned CDocument carries the backing temp PDF's lifetime: it is removed in CDocumentImpl::Dispose() right after the file handle closes necessary on Windows where APDFL's open handle holds an exclusive lock and prevents remove() from succeeding before the document is destroyed.

On platforms where the WebToPDF plugin is not supported this throws CWebConvertError(Category::PluginUnavailable, ...) immediately (translated to WebConvertError(Category::PluginUnavailable) by the api layer).

### get_attachments

```cpp
std::vector< std::shared_ptr< FileAttachment > > datalogics_interface::Document::get_attachments()
```

**Returns:** [`std::vector< std::shared_ptr< FileAttachment > >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/FileAttachment.md)

The list of attached files.

Gets all attached files from the PDF document.

### get_author

```cpp
std::string datalogics_interface::Document::get_author() const
```

**Returns:** `std::string`

The author of the PDF document.

### get_base_uri

```cpp
std::string datalogics_interface::Document::get_base_uri() const
```

**Returns:** `std::string`

The Base URI of the PDF document.

### get_bookmark_root

```cpp
std::unique_ptr< Bookmark > datalogics_interface::Document::get_bookmark_root()
```

**Returns:** [`std::unique_ptr< Bookmark >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Bookmark.md)

The document's root bookmark.

Gets the root of the document's bookmark tree.

The return value is valid even if the document's bookmark tree is empty (meaning that there is no Outlines key in the underlying PDF file).

### get_collection

```cpp
std::unique_ptr< Collection > datalogics_interface::Document::get_collection() const
```

**Returns:** [`std::unique_ptr< Collection >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Collection.md)

collection object if collection exists in the Document or NULL otherwise.

GetCollection allows to retrieve collection from the PDF document.

### get_compression_level

```cpp
int datalogics_interface::Document::get_compression_level() const
```

**Returns:** `int`

The compression level of the document.

The compression level can be one of three values returned by this property:

0 - No compression. All objects are available without inflation. 1 - Partial compression. Objects related to logical structure are stored in object streams and must be inflated. 2 - Full compression. All objects are compressed and must be inflated.

### get_creator

```cpp
std::string datalogics_interface::Document::get_creator() const
```

**Returns:** `std::string`

The creator of the PDF file.

### get_delete_on_close

```cpp
bool datalogics_interface::Document::get_delete_on_close() const
```

**Returns:** `bool`

The DeleteOnClose property.

The document is based on a temporary file that must be deleted when the document is closed or saved.

### get_file_name

```cpp
std::string datalogics_interface::Document::get_file_name() const
```

**Returns:** `std::string`

The filename associated with this Document.

Get the filename associated with this Document, if it has a representation on disk.

### get_fonts

```cpp
std::vector< Font > datalogics_interface::Document::get_fonts(int first_page, int last_page) const
```

**Parameters**

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

**Returns:** [`std::vector< Font >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

### get_has_signature

```cpp
bool datalogics_interface::Document::get_has_signature() const
```

**Returns:** `bool`

If the Document has a Digital Signature.

The document contains a Digital Signature.

### get_info

```cpp
std::string datalogics_interface::Document::get_info(const std::string &key) const
```

**Parameters**

- `key` (`const std::string &`): The name of metadata which value will be obtained.

**Returns:** `std::string`

The value of the metadata obtained from the PDF file.

Gets the value of metadata information in a PDF file.

### get_info_dict

```cpp
std::unique_ptr< PDFDict > datalogics_interface::Document::get_info_dict() const
```

**Returns:** [`std::unique_ptr< PDFDict >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

The Info dictionary of the document as a PDFObject.

### get_instance_id

```cpp
std::vector< unsigned char > datalogics_interface::Document::get_instance_id() const
```

**Returns:** `std::vector< unsigned char >`

Get the instance ID for this document.

### get_is_linearized

```cpp
bool datalogics_interface::Document::get_is_linearized() const
```

**Returns:** `bool`

The IsLinearized property

The document is linearized (optimized) for page-served remote (network) access. This flag is get only.

### get_is_modified

```cpp
bool datalogics_interface::Document::get_is_modified() const
```

**Returns:** `bool`

The IsModified property.

The document has been modified slightly (for example, bookmarks or text annotations have been opened or closed), but not in a way that warrants saving.

This flag is get only.

### get_is_optimized

```cpp
bool datalogics_interface::Document::get_is_optimized() const
```

**Returns:** `bool`

The IsOptimized property

The document is optimized. If this flag is cleared, the Adobe PDF Library does not save the file optimized. You can, therefore, linearize a PDF file without optimizing it. Optimizing without linearizing is not allowed, however. This flag can only be set, never cleared.

### get_keywords

```cpp
std::string datalogics_interface::Document::get_keywords() const
```

**Returns:** `std::string`

The keywords of the PDF file.

### get_loaded_fonts

```cpp
std::vector< Font > datalogics_interface::Document::get_loaded_fonts() const
```

**Returns:** [`std::vector< Font >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Font.md)

Enumerates all the fonts that have been encountered so far. A font is loaded when a page that uses it is processed. This typically happens when a page is drawn or its thumbnail image is created.

### get_major_version

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

**Returns:** `int`

The major PDF version number of the document.

The major PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version.

### get_minor_version

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

**Returns:** `int`

The minor PDF version number of the document.

The minor PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version.

Please note: Setting the minor version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new minor version.

The new minor version number will appear in the file header once the document is saved.

### get_name_tree

```cpp
std::unique_ptr< NameTree > datalogics_interface::Document::get_name_tree(const std::string &name)
```

**Parameters**

- `name` (`const std::string &`): The name of the NameTree to get.

**Returns:** [`std::unique_ptr< NameTree >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NameTree.md)

The retrieved NameTree.

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

### get_needs_save

```cpp
bool datalogics_interface::Document::get_needs_save() const
```

**Returns:** `bool`

The NeedsSave property.

The document has been modified and needs to be saved.

### get_num_pages

```cpp
int datalogics_interface::Document::get_num_pages() const
```

**Returns:** `int`

The number of pages in the document. Remember to subtract 1 from this value if you are going to pass it to a Page method that takes a zero-based page number.

Gets the number of pages in a document.

### get_optional_content_groups

```cpp
std::vector< OptionalContentGroup > datalogics_interface::Document::get_optional_content_groups() const
```

**Returns:** [`std::vector< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/OptionalContentGroup.md)

A list of COptionalContentGroup objects.

Gets the optional-content groups for the document.

The order of the groups is not guaranteed to be the creation order, and is not the same as the display order (see PDOCConfigGetOCGOrder()).

### get_page

```cpp
Page datalogics_interface::Document::get_page(int page_number)
```

**Parameters**

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

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

The requested Page object.

Gets a Page from a document.

### get_page_labels

```cpp
std::vector< PageLabel > datalogics_interface::Document::get_page_labels() const
```

**Returns:** [`std::vector< PageLabel >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PageLabel.md)

The list of PageLabel objects used in the document.

PageLabels are always stored in page index order; if two PageLabels start on the same page index, the last PageLabel appearing in the list will be used.

### get_page_mode

```cpp
PageMode datalogics_interface::Document::get_page_mode() const
```

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

The PageMode of the PDF document.

### get_permanent_id

```cpp
std::vector< unsigned char > datalogics_interface::Document::get_permanent_id() const
```

**Returns:** `std::vector< unsigned char >`

Get the permanent ID for this document.

### get_permission_flags

```cpp
PermissionFlags datalogics_interface::Document::get_permission_flags() const
```

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

flags that have been set

Allows to obtain security flags for the document.

### get_producer

```cpp
std::string datalogics_interface::Document::get_producer() const
```

**Returns:** `std::string`

The producer of the PDF file.

### get_requires_full_save

```cpp
bool datalogics_interface::Document::get_requires_full_save() const
```

**Returns:** `bool`

The RequiresFullSave property.

The document cannot be saved incrementally; when it is saved using Document.Save(), the SaveFlags.Full flag must be specified.

This flag can only be set, never cleared.

### get_root

```cpp
std::unique_ptr< PDFDict > datalogics_interface::Document::get_root() const
```

**Returns:** [`std::unique_ptr< PDFDict >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFDict.md)

The Catalog of the document as a PDFObject.

### get_struct_tree_root

```cpp
std::optional< StructTreeRoot > datalogics_interface::Document::get_struct_tree_root()
```

**Returns:** [`std::optional< StructTreeRoot >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/StructTreeRoot.md)

Returns the StructTreeRoot if present, nullptr otherwise.

### get_subject

```cpp
std::string datalogics_interface::Document::get_subject() const
```

**Returns:** `std::string`

The subject of the PDF document.

### get_suppress_errors

```cpp
bool datalogics_interface::Document::get_suppress_errors() const
```

**Returns:** `bool`

The SuppressErrors property

Do not display errors.

### get_title

```cpp
std::string datalogics_interface::Document::get_title() const
```

**Returns:** `std::string`

The title of the PDF document.

### get_version_string

```cpp
std::string datalogics_interface::Document::get_version_string() const
```

**Returns:** `std::string`

A string containing the PDF version number of the document.

The PDF version of the document, which is specified in the header of a PDF file in the string "%PDF-xx.yy" where xx is the major version and yy is the minor version.

Note that this returns a string containing both the major and minor versions. For version comparisons, use MajorVersion and MinorVersion.

### get_was_repaired

```cpp
bool datalogics_interface::Document::get_was_repaired() const
```

**Returns:** `bool`

The WasRepaired property.

The document was repaired when it was opened.

This flag is get only.

### get_xmp_metadata

```cpp
std::string datalogics_interface::Document::get_xmp_metadata() const
```

**Returns:** `std::string`

The XMP metadata associated with a document.

The XMP metadata returned always represents all the properties in the Document's Info dictionary, and can also contain properties not present in the Info dictionary. This call is preferred to GetInfo, which only returns properties that are in the Info dictionary (although the older function is supported for compatibility).

### get_xmp_metadata_array_item

```cpp
std::string datalogics_interface::Document::get_xmp_metadata_array_item(const std::string &ns, const std::string &path, int index) const
```

**Parameters**

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

**Returns:** `std::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.

### get_xmp_metadata_property

```cpp
std::string datalogics_interface::Document::get_xmp_metadata_property(const std::string &ns, const std::string &path) const
```

**Parameters**

- `ns` (`const std::string &`): The XML namespace URI for the schema in which the property is to be found.
- `path` (`const std::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:** `std::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.

### import_acro_forms_data

```cpp
bool datalogics_interface::Document::import_acro_forms_data(const std::string &path, AcroFormImportType type)
```

**Parameters**

- `path` (`const std::string &`): The path on disk of the AcroFormsdata file to be imported.
- `type` ([`AcroFormImportType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

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

### import_xfa_forms_data

```cpp
bool datalogics_interface::Document::import_xfa_forms_data(const std::string &path)
```

**Parameters**

- `path` (`const std::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.

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

### insert_pages

```cpp
void datalogics_interface::Document::insert_pages(int merge_after, const Document &source, int start_page, int num_pages, PageInsertFlags flags)
```

**Parameters**

- `merge_after` (`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.
- `source` ([`const Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The document containing the pages that are inserted into doc.
- `start_page` (`int`): The page number of the first page in doc2 to insert into doc. The first page is 0.
- `num_pages` (`int`): The number of pages in doc2 to insert into doc. Use Document.AllPages to insert all pages from doc2 into doc.
- `flags` ([`PageInsertFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.

### move_page

```cpp
void datalogics_interface::Document::move_page(int move_to_after, int page_to_move)
```

**Parameters**

- `move_to_after` (`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.
- `page_to_move` (`int`): The page number of the page to move.

**Returns:** `void`

Moves one page in a document.

### operator=

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

**Parameters**

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

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

### perm_request

```cpp
bool datalogics_interface::Document::perm_request(const std::string &password, PermissionRequestOperation operation)
```

**Parameters**

- `password` (`const std::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.
- `operation` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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

### perm_request

```cpp
bool datalogics_interface::Document::perm_request(PermissionRequestOperation operation)
```

**Parameters**

- `operation` ([`PermissionRequestOperation`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionRequestOperation.md)): - 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.

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

```cpp
void datalogics_interface::Document::print(PrintUserParams &params)
```

**Parameters**

- `params` ([`PrintUserParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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_to_file

```cpp
void datalogics_interface::Document::print_to_file(PrintUserParams &params, const std::string &path)
```

**Parameters**

- `params` ([`PrintUserParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PrintUserParams.md)): Parameters to control printing.
- `path` (`const std::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.

### remove_collection

```cpp
void datalogics_interface::Document::remove_collection()
```

**Returns:** `void`

RemoveCollection Removes a collection dictionary from a document.

### remove_name_tree

```cpp
void datalogics_interface::Document::remove_name_tree(const std::string &name)
```

**Parameters**

- `name` (`const std::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.

### replace_pages

```cpp
void datalogics_interface::Document::replace_pages(int start_page, const Document &source, int start_page_source, int num_pages, bool merge_text_annots)
```

**Parameters**

- `start_page` (`int`): The first page number in doc to replace. The first page is 0.
- `source` ([`const Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The document from which pages are copied into doc.
- `start_page_source` (`int`): The page number of the first page in doc2 to copy. The first page is 0.
- `num_pages` (`int`): The number of pages to replace.
- `merge_text_annots` (`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.

**Note:** Annotations in the replaced pages are not replaced and remain with the page. Use DeletePages to remove annotations.

### save

```cpp
void datalogics_interface::Document::save(SaveFlags flags)
```

**Parameters**

- `flags` ([`SaveFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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 newPath.

If the document was created with Document, at least one page must be added using CreatePage() or InsertPages() 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

```cpp
void datalogics_interface::Document::save(SaveFlags flags, const std::string &path)
```

**Parameters**

- `flags` ([`SaveFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SaveFlags.md)): A bit field composed of an OR of the SaveFlags values.
- `path` (`const std::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() or InsertPages() 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

```cpp
void datalogics_interface::Document::save(SaveFlags flags, std::ostream &output_stream)
```

**Parameters**

- `flags` ([`SaveFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SaveFlags.md))
- `output_stream` (`std::ostream &`)

**Returns:** `void`

Save the document to an output stream.

### secure

```cpp
void datalogics_interface::Document::secure(PermissionFlags permissions, const std::string &owner_password, const std::string &user_password)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionFlags.md)): - an "OR" of the types of PDF document specified by Permissions:
- `owner_password` (`const std::string &`): - optional PDF document owner password; pass null if not used.
- `user_password` (`const std::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

```cpp
void datalogics_interface::Document::secure(PermissionFlags permissions, const std::string &owner_password, const std::string &user_password, EncryptionType encryption_type)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionFlags.md)): - an "OR" of the types of PDF document specified by Permissions:
- `owner_password` (`const std::string &`): - optional PDF document owner password; pass null if not used.
- `user_password` (`const std::string &`): - optional PDF document user password; pass null if not used.
- `encryption_type` ([`EncryptionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/EncryptionType.md))

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

```cpp
void datalogics_interface::Document::secure(PermissionFlags permissions, const std::string &owner_password, const std::string &user_password, EncryptionType encryption_type, bool encrypt_metadata)
```

**Parameters**

- `permissions` ([`PermissionFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PermissionFlags.md)): - an "OR" of the types of PDF document specified by Permissions:
- `owner_password` (`const std::string &`): - optional PDF document owner password; pass null if not used.
- `user_password` (`const std::string &`): - optional PDF document user password; pass null if not used.
- `encryption_type` ([`EncryptionType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/EncryptionType.md))
- `encrypt_metadata` (`bool`)

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

### set_author

```cpp
void datalogics_interface::Document::set_author(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the author of the PDF document

**Returns:** `void`

The author of the PDF document.

### set_base_uri

```cpp
void datalogics_interface::Document::set_base_uri(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the Base URI of the PDF document

**Returns:** `void`

The Base URI of the PDF document.

### set_creator

```cpp
void datalogics_interface::Document::set_creator(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the creator of the PDF document

**Returns:** `void`

The creator of the PDF document.

### set_delete_on_close

```cpp
void datalogics_interface::Document::set_delete_on_close(bool value)
```

**Parameters**

- `value` (`bool`): The DeleteOnClose property

**Returns:** `void`

The document is based on a temporary file that must be deleted when the document is closed or saved.

### set_info

```cpp
void datalogics_interface::Document::set_info(const std::string &key, const std::string &value)
```

**Parameters**

- `key` (`const std::string &`): The name of metadata to be set
- `value` (`const std::string &`): The value for metadata which will be set

**Returns:** `void`

Sets metadata information in a PDF document.

### set_is_optimized

```cpp
void datalogics_interface::Document::set_is_optimized(bool value)
```

**Parameters**

- `value` (`bool`): The IsOptimized property

**Returns:** `void`

The document is optimized. If this flag is cleared, the Adobe PDF Library does not save the file optimized. You can, therefore, linearize a PDF file without optimizing it. Optimizing without linearizing is not allowed, however. This flag can only be set, never cleared.

### set_keywords

```cpp
void datalogics_interface::Document::set_keywords(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the keywords of the PDF document

**Returns:** `void`

The keywords of the PDF document.

### set_major_version

```cpp
void datalogics_interface::Document::set_major_version(int version)
```

**Parameters**

- `version` (`int`): The new major version number to be set in the document's file header.

**Returns:** `void`

The major PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-x.y" where x is the major version and y is the minor version. For example, version 1.2 has the string "%PDF-1.2". See Section I.2 in the PDF Reference.

Please note: Setting the major version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new major version.

The new major version number will appear in the file header once the document is saved.

### set_minor_version

```cpp
void datalogics_interface::Document::set_minor_version(int version)
```

**Parameters**

- `version` (`int`): The new minor version number to be set in the document's file header.

**Returns:** `void`

The minor PDF version number of the document. The PDF version is specified in the header of a PDF file in the string "%PDF-xx. yy" where xx is the major version and yy is the minor version. For example, version 1.2 has the string "%PDF-1 .2".

Please note: Setting the minor version on a document only changes the version number in the document's file header. It will NOT actually change the PDF's contents and it will NOT alter the PDF to conform to the standard of the new minor version.

The new minor version number will appear in the file header once the document is saved.

### set_needs_save

```cpp
void datalogics_interface::Document::set_needs_save(bool value)
```

**Parameters**

- `value` (`bool`): The NeedSave property

**Returns:** `void`

The document has been modified and needs to be saved.

### set_page_labels

```cpp
void datalogics_interface::Document::set_page_labels(const std::vector< PageLabel > &labels)
```

**Parameters**

- `labels` ([`const std::vector< PageLabel > &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PageLabel.md)): when a page label has an unknown numbering style

**Returns:** `void`

The list of PageLabel objects used in the document.

### set_page_mode

```cpp
void datalogics_interface::Document::set_page_mode(PageMode mode)
```

**Parameters**

- `mode` ([`PageMode`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/PageMode.md)): the pagemode to apply to the Document

**Returns:** `void`

The PageMode of the PDF document.

The default PageMode for a new Document is PageMode.NoPreference .

### set_producer

```cpp
void datalogics_interface::Document::set_producer(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the producer of the PDF document

**Returns:** `void`

The producer of the PDF document.

### set_requires_full_save

```cpp
void datalogics_interface::Document::set_requires_full_save(bool value)
```

**Parameters**

- `value` (`bool`): The RequiresFullSave property

**Returns:** `void`

The document cannot be saved incrementally; when it is saved using Document.Save(), the SaveFlags.Full flag must be specified. This flag can only be set, never cleared.

### set_subject

```cpp
void datalogics_interface::Document::set_subject(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the subject of the PDF document

**Returns:** `void`

The subject of the PDF document.

### set_suppress_errors

```cpp
void datalogics_interface::Document::set_suppress_errors(bool value)
```

**Parameters**

- `value` (`bool`): The SuppressErrors property

**Returns:** `void`

Do not display errors.

### set_title

```cpp
void datalogics_interface::Document::set_title(const std::string &value)
```

**Parameters**

- `value` (`const std::string &`): the title of the PDF document

**Returns:** `void`

The title of the PDF document.

### set_xmp_metadata

```cpp
void datalogics_interface::Document::set_xmp_metadata(const std::string &metadata)
```

**Parameters**

- `metadata` (`const std::string &`): the XMP metadata associated with a document

**Returns:** `void`

The XMP metadata associated with a document.

The XMP metadata returned always represents all the properties in the Document's Info dictionary, and can also contain properties not present in the Info dictionary. This call is preferred to GetInfo, which only returns properties that are in the Info dictionary (although the older function is supported for compatibility).

### set_xmp_metadata_array_item

```cpp
void datalogics_interface::Document::set_xmp_metadata_array_item(const std::string &ns, const std::string &ns_prefix, const std::string &path, int index, const std::string &value)
```

**Parameters**

- `ns` (`const std::string &`): The XML namespace URI for the schema in which the property is to be found.
- `ns_prefix` (`const std::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` (`const std::string &`): The name of the simple property to be modified.
- `index` (`int`): The index in the metadata property array associated with the property.
- `value` (`const std::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.

### set_xmp_metadata_property

```cpp
void datalogics_interface::Document::set_xmp_metadata_property(const std::string &ns, const std::string &ns_prefix, const std::string &path, const std::string &value)
```

**Parameters**

- `ns` (`const std::string &`): The XML namespace URI for the schema in which the property is to be found.
- `ns_prefix` (`const std::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` (`const std::string &`): The name of the simple property to be modified.
- `value` (`const std::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

```cpp
void datalogics_interface::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

```cpp
void datalogics_interface::Document::watermark(Page &page, WatermarkParams &params)
```

**Parameters**

- `page` ([`Page &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Page.md)): The page to be added as a watermark.
- `params` ([`WatermarkParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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

```cpp
void datalogics_interface::Document::watermark(WatermarkTextParams &text_params, WatermarkParams &params)
```

**Parameters**

- `text_params` ([`WatermarkTextParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/WatermarkTextParams.md)): The page to be added as a watermark.
- `params` ([`WatermarkParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/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.
