# FileAttachment Class

> A file attachment.

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

```cpp
class FileAttachment
```

**Namespace:** `datalogics_interface`

## Description

A file attachment. Any file can be attached to the PDF document.

The class allows to create attachment and manipulate by its content.

**Uses types:** [`AFRelationship`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/AFRelationship.md)

## Constructors

### FileAttachment

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

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The PDF document (reference).
- `file_name` (`const std::string &`): The path to file which will be attached to the document.

Allows to add attachment into the PDF document.

### FileAttachment

```cpp
datalogics_interface::FileAttachment::FileAttachment(Document &doc, const std::string &file_name, const std::string &key_name)
```

*constructor*

**Parameters**

- `doc` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The PDF document (reference).
- `file_name` (`const std::string &`): The path to file which will be attached to the document.
- `key_name` (`const std::string &`)

Allows to add attachment into the PDF document.

### FileAttachment

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

*constructor*

**Parameters**

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

### ~FileAttachment

```cpp
datalogics_interface::FileAttachment::~FileAttachment()
```

*destructor*

## Methods

### get_af_relationship

```cpp
AFRelationship datalogics_interface::FileAttachment::get_af_relationship() const
```

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

The attachment's Associated File relationship.

Gets the attachment's Associated File relationship.

### get_file_name

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

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

The attachment's file name.

Gets the attachment's file name.

### get_file_size

```cpp
size_t datalogics_interface::FileAttachment::get_file_size() const
```

**Returns:** `size_t`

The attachment's size in bytes.

Gets the attachment's file size.

### operator=

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

**Parameters**

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

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

### save_to_file

```cpp
void datalogics_interface::FileAttachment::save_to_file(const std::string &file_name)
```

**Parameters**

- `file_name` (`const std::string &`): The path where attachment will be saved.

**Returns:** `void`

Allows to save attachment to the specified file.

### set_af_relationship

```cpp
void datalogics_interface::FileAttachment::set_af_relationship(AFRelationship relationship)
```

**Parameters**

- `relationship` ([`AFRelationship`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/AFRelationship.md)): The Associated File relationship to set.

**Returns:** `void`

Sets the attachment's Associated File relationship.

### update_from_file

```cpp
void datalogics_interface::FileAttachment::update_from_file(const std::string &file_name)
```

**Parameters**

- `file_name` (`const std::string &`): The path to the file from which attachment will be updated.

**Returns:** `void`

Allows to update attachment from another file.
