# Library Class

> Used to create a new instance of a library object or change properties.

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

```cpp
class Library
```

**Namespace:** `datalogics_interface`

## Description

Used to create a new instance of a library object or change properties.

A Library object can be used to create a new instance of a library or change the properties of an existing library.

Threading: per-thread. Each thread that touches the SDK must construct its own `Library` before creating any `Document`, `Page`, or `PDFObject`, and that `Library` must outlive every object it backs. Do not share a `Library` instance across threads. See `datalogics_interface.hpp` for the full threading model.

**Uses types:** [`ColorProfile`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ColorProfile.md), [`LibraryFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/LibraryFlags.md), [`LogParams`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/LogParams.md), [`TempStoreType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/TempStoreType.md)

## Constructors

### Library

```cpp
datalogics_interface::Library::Library()
```

*constructor*

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### Library

```cpp
datalogics_interface::Library::Library(const std::vector< std::string > &font_paths)
```

*constructor*

**Parameters**

- `font_paths` (`const std::vector< std::string > &`)

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### Library

```cpp
datalogics_interface::Library::Library(const std::vector< std::string > &font_paths, const std::string &cmap_path, const std::string &unicode_path, const std::string &color_profile_path, LibraryFlags flags)
```

*constructor*

**Parameters**

- `font_paths` (`const std::vector< std::string > &`)
- `cmap_path` (`const std::string &`)
- `unicode_path` (`const std::string &`)
- `color_profile_path` (`const std::string &`)
- `flags` ([`LibraryFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/LibraryFlags.md))

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### Library

```cpp
datalogics_interface::Library::Library(const std::vector< std::string > &font_paths, const std::string &cmap_path, const std::string &unicode_path, LibraryFlags flags)
```

*constructor*

**Parameters**

- `font_paths` (`const std::vector< std::string > &`)
- `cmap_path` (`const std::string &`)
- `unicode_path` (`const std::string &`)
- `flags` ([`LibraryFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/LibraryFlags.md))

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### Library

```cpp
datalogics_interface::Library::Library(const std::vector< std::string > &font_paths, LibraryFlags flags)
```

*constructor*

**Parameters**

- `font_paths` (`const std::vector< std::string > &`)
- `flags` ([`LibraryFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/LibraryFlags.md))

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### Library

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

*constructor*

**Parameters**

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

### Library

```cpp
datalogics_interface::Library::Library(LibraryFlags flags)
```

*constructor*

**Parameters**

- `flags` ([`LibraryFlags`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/LibraryFlags.md))

Initialize the PDF Library on this thread. Note that each thread needs its own instance of the library.

Multiple Library objects can be created on a thread, but they all refer to the same underlying instantiation of the library.

### ~Library

```cpp
datalogics_interface::Library::~Library()
```

*destructor*

Destroy this handle to the PDF Library. Also terminate the library if this is the last Library object on this thread.

## Methods

### change_working_space_cmyk

```cpp
void datalogics_interface::Library::change_working_space_cmyk(ColorProfile profile)
```

**Parameters**

- `profile` ([`ColorProfile`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ColorProfile.md)): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current CMYK working space to the specified ICC profile.

### change_working_space_cmyk

```cpp
void datalogics_interface::Library::change_working_space_cmyk(const std::string &profile_path)
```

**Parameters**

- `profile_path` (`const std::string &`): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current CMYK working space to the specified ICC profile.

### change_working_space_gray

```cpp
void datalogics_interface::Library::change_working_space_gray(ColorProfile profile)
```

**Parameters**

- `profile` ([`ColorProfile`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ColorProfile.md)): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current Gray working space to the specified ICC profile.

### change_working_space_gray

```cpp
void datalogics_interface::Library::change_working_space_gray(const std::string &profile_path)
```

**Parameters**

- `profile_path` (`const std::string &`): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current Gray working space to the specified ICC profile.

### change_working_space_rgb

```cpp
void datalogics_interface::Library::change_working_space_rgb(ColorProfile profile)
```

**Parameters**

- `profile` ([`ColorProfile`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/ColorProfile.md)): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current RGB working space to the specified ICC profile.

### change_working_space_rgb

```cpp
void datalogics_interface::Library::change_working_space_rgb(const std::string &profile_path)
```

**Parameters**

- `profile_path` (`const std::string &`): The path on disk of the Color Profile to be used.

**Returns:** `void`

Sets the current RGB working space to the specified ICC profile.

### enable_licensed_behavior

```cpp
static bool datalogics_interface::Library::enable_licensed_behavior(const std::string &key)
```

*static*

**Parameters**

- `key` (`const std::string &`): A base64-encoded string containing the encrypted license key.

**Returns:** `bool`

true if the licensed behavior has been successfully enabled.

This is used to turn on licensed behaviors in DLE.

The function parameter is a base64-encoded string containing the encrypted licensed key.

**Note:** When using the Render bypass key, this requires you also set the BypassCopyPerm property to true of the DrawParams or PageImageParams classes for it to work.

### get_allow_opening_xfa

```cpp
bool datalogics_interface::Library::get_allow_opening_xfa() const
```

**Returns:** `bool`

Allow opening PDF files that contain XFA forms. By default, an exception will be raised when attempting to open this type of document.

### get_allow_relaxed_syntax

```cpp
bool datalogics_interface::Library::get_allow_relaxed_syntax() const
```

**Returns:** `bool`

true if these minor errors are ignored.

Check to see if minor parsing errors are ignored while opening PDF files.

### get_apdfl_version

```cpp
static std::string datalogics_interface::Library::get_apdfl_version()
```

*static*

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

The version of the C/C++ SDK, as reported in legacy versions of APDFL.

E.g., 21.0.0P1a

### get_default_temp_path

```cpp
std::string datalogics_interface::Library::get_default_temp_path() const
```

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

string with current default directory for temporary files, or null if none was set by the user.

Gets the default temporary directory.

### get_default_temp_store

```cpp
TempStoreType datalogics_interface::Library::get_default_temp_store() const
```

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

current temporary storage type.

Gets default temporary storage. PDFL uses Disk storage type by default.

### get_default_temp_store_mem_limit

```cpp
int datalogics_interface::Library::get_default_temp_store_mem_limit() const
```

**Returns:** `int`

current memory limit. It returns zero value for cases when unlimited memory amount is used or when current storage type is Disk. Call DefaultTempStore to get the exact meaning of the zero value

Gets current memory limit.

### get_forms_extension_version

```cpp
static std::string datalogics_interface::Library::get_forms_extension_version()
```

*static*

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

The Forms Extension Version

### get_install_location

```cpp
static std::string datalogics_interface::Library::get_install_location()
```

*static*

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

the installation location as a UTF-8 path.

The installation location.

This is inferred from the location of the native code and returned as a UTF-8 path.

### get_license_key

```cpp
static std::string datalogics_interface::Library::get_license_key()
```

*static*

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

A string containing a license key, as an alternative to using a license file. Only applicable to License-Managed versions.

### get_log_params

```cpp
LogParams datalogics_interface::Library::get_log_params() const
```

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

The LogParams object which contains currently used logging settings.

Gets LogParams object with preferences for logging.

### get_resource_directory

```cpp
static std::string datalogics_interface::Library::get_resource_directory()
```

*static*

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

the resource directory as a UTF-8 path

The resource directory.

### get_version

```cpp
static std::string datalogics_interface::Library::get_version()
```

*static*

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

The version of the SDK, as reported in legacy versions of APDFL.

E.g., 21.0.0.0

### initialized

```cpp
static bool datalogics_interface::Library::initialized()
```

*static*

**Returns:** `bool`

true if the PDF Library is initialized on this thread

Check to see if the library is initialized

### is_forms_extension_available

```cpp
bool datalogics_interface::Library::is_forms_extension_available()
```

**Returns:** `bool`

true if the Forms Extension dependencies are present, and false if they are not.

Validate the Forms Extension dependencies are present. Indicates if all of the necessary dependencies are present for the Forms extension.

### operator=

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

**Parameters**

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

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

### set_allow_opening_xfa

```cpp
void datalogics_interface::Library::set_allow_opening_xfa(bool allow)
```

**Parameters**

- `allow` (`bool`): true to allow opening PDF files that contain XFA forms; false to throw an exception on such files.

**Returns:** `void`

Allow opening PDF files that contain XFA forms. By default, an exception will be raised when attempting to open this type of document.

### set_allow_relaxed_syntax

```cpp
void datalogics_interface::Library::set_allow_relaxed_syntax(bool allow)
```

**Parameters**

- `allow` (`bool`): the ignore minor parsing errors while opening PDF files. By default, exceptions are raised when such errors occur

**Returns:** `void`

Ignore minor parsing errors while opening PDF files. By default, exceptions are raised when such errors occur.

### set_default_temp_path

```cpp
void datalogics_interface::Library::set_default_temp_path(const std::string &path)
```

**Parameters**

- `path` (`const std::string &`): the default temporary path to the directory indicated by the specified path name

**Returns:** `void`

Sets the default temporary path to the directory indicated by the specified path name.

Pass null as the path to use the system default temporary file directory.

### set_default_temp_store

```cpp
void datalogics_interface::Library::set_default_temp_store(TempStoreType type)
```

**Parameters**

- `type` ([`TempStoreType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/TempStoreType.md)): temporary storage type.

**Returns:** `void`

Allows to switch between different types of temporary storages.

Use Disk type to turn off in-memory file system usage. Use Memory type to turn on in-memory file system with unlimited RAM amount by default.

### set_default_temp_store_mem_limit

```cpp
void datalogics_interface::Library::set_default_temp_store_mem_limit(int limit_kb)
```

**Parameters**

- `limit_kb` (`int`)

**Returns:** `void`

Sets memory limit for Memory storage type.

Accepts any positive integer to set threshold for using RAM in kilobytes. When occupied memory exceeds specified threshold, temporary files creation will be redirected to physical disk.

Throws an exception if current storage type is Disk. Throws an exception if input value less than 0;

### set_license_key

```cpp
static void datalogics_interface::Library::set_license_key(const std::string &key)
```

*static*

**Parameters**

- `key` (`const std::string &`): a string containing a license, as an alternative to using a license file. Only applicable to License-Managed versions

**Returns:** `void`

A string containing a license, as an alternative to using a license file. Only applicable to License-Managed versions.

### set_log_params

```cpp
void datalogics_interface::Library::set_log_params(const LogParams &params)
```

**Parameters**

- `params` ([`const LogParams &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/LogParams.md)): the new parameters for logging.

**Returns:** `void`

Sets LogParams object with preferences for logging.

### terminate

```cpp
void datalogics_interface::Library::terminate()
```

**Returns:** `void`

Terminate the library with regard to this handle. (Note that if there are other Library objects in this thread, they may keep the library initialized.
