# SignDoc Class

> Implementation of the PDF SignDoc function.

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

```cpp
class SignDoc
```

**Namespace:** `datalogics_interface`

## Description

Implementation of the PDF SignDoc function.

Use the SignDoc object to digitally sign a document

**Uses types:** [`CredentialDataFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialDataFormat.md), [`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md), [`DigestCategory`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/DigestCategory.md), [`DisplayTraits`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/DisplayTraits.md), [`Rect`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Rect.md), [`SignatureFieldID`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SignatureFieldID.md), [`SignatureType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SignatureType.md)

## Constructors

### SignDoc

```cpp
datalogics_interface::SignDoc::SignDoc()
```

*constructor*

Creates an empty SignDoc object and initializes memory for its parameters.

### SignDoc

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

*constructor*

**Parameters**

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

### ~SignDoc

```cpp
datalogics_interface::SignDoc::~SignDoc()
```

*destructor*

## Methods

### add_digital_signature

```cpp
void datalogics_interface::SignDoc::add_digital_signature(Document &document)
```

**Parameters**

- `document` ([`Document &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Document.md)): The Document to be digitally signed.

**Returns:** `void`

Adds a digital signature using the specified credentials.

If the document has not been previously signed, signs and saves the entire document. If the document has been previously signed, signs and saves only the portions of the document that have changed. If the document has been previously signed and the path to which the file is saved is NULL or the same as the path specified by the parameter, doc, signs and copies the document, saving only the portions of the document that have changed.

### add_sig_policy

```cpp
int datalogics_interface::SignDoc::add_sig_policy(const std::string &oid)
```

**Parameters**

- `oid` (`const std::string &`): - Object Identifier (OID) of the signature policy to add.

**Returns:** `int`

- The number of signature policies added to the signature.

Add a signature policy to the PAdES signature being generated. Signature policies may be applied to PAdES signatures, only. The signature type must be set to PADES prior to adding a policy.

### add_sig_policy_qualifier_uri

```cpp
void datalogics_interface::SignDoc::add_sig_policy_qualifier_uri(const std::string &uri)
```

**Parameters**

- `uri` (`const std::string &`): - URI pointing to the signature policy document.

**Returns:** `void`

Qualify an existing signature policy with a Signature Policy URI (SPuri) qualifier. A policy must be added via AddSigPolicy prior to calling this method. A signature policy may be qualified by no more than one policy qualifier.

### add_sig_policy_qualifier_user_notice

```cpp
void datalogics_interface::SignDoc::add_sig_policy_qualifier_user_notice(const std::string &display_text, const std::string &org, const std::vector< std::int64_t > &notice_nos)
```

**Parameters**

- `display_text` (`const std::string &`): - Text to display to the user when the signature is verified.
- `org` (`const std::string &`): - Organization that prepared the notice.
- `notice_nos` (`const std::vector< std::int64_t > &`): - Group of integers that identify textual statements prepared by the organization.

**Returns:** `void`

Qualify an existing signature policy with a Signature Policy UserNotice (SPUserNotice) qualifier. A policy must be added via AddSigPolicy prior to calling this method. A signature policy may be qualified by no more than one policy qualifier. The displayText and org attributes can be defined independent of each other. However, a valid org attribute must be defined in order to qualify a PAdES signature policy with the noticeNos attribute.

### get_credential_data_format

```cpp
CredentialDataFormat datalogics_interface::SignDoc::get_credential_data_format() const
```

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

- Format of user-credentials used to sign the document.

Get the value of the credential data format option.

### get_digest_category

```cpp
DigestCategory datalogics_interface::SignDoc::get_digest_category() const
```

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

- Member of the enumeration DigestCategory, which option to set.

Get the value of the digest category.

### get_field_id

```cpp
SignatureFieldID datalogics_interface::SignDoc::get_field_id() const
```

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

- SignatureFieldID choice currently set

Get the field identifier used to determine the form field that will contain the digital signature.

### get_field_name

```cpp
std::string datalogics_interface::SignDoc::get_field_name() const
```

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

- Fully qualified field name. May return NULL based on the SignatureFieldID attribute defined by the user.

Get the form field fully qualified name of the form field that contains the digital signature.

### get_output_path

```cpp
std::string datalogics_interface::SignDoc::get_output_path() const
```

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

Get Output Path The path to which the file is saved. A path must be specified in case a full save (PDSaveFull) is needed. In case of an incremental save (PDSaveIncremental), newPath should be set to NULL. If a full save (PDSaveFull) is performed and newPath is the same as the file's original path, the new file is saved to a file system determined temporary path. The old file is then deleted and the new file is renamed to newPath.

### get_signature_box_page_number

```cpp
unsigned int datalogics_interface::SignDoc::get_signature_box_page_number() const
```

**Returns:** `unsigned int`

- The page number on which signature field's widget annotation is created. A value of zero is returned if page number was not set.

Get the page number on which the widget annotation of the signature field is created.

### get_signature_box_rectangle

```cpp
Rect datalogics_interface::SignDoc::get_signature_box_rectangle() const
```

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

- Dimension of the annotation rectangle of the signature field being created. A value of {0,0,0,0} is returned if annotation rectangle dimension was not set.

Get the dimension of the annotation rectangle of the signature field being created.

### get_signature_type

```cpp
SignatureType datalogics_interface::SignDoc::get_signature_type() const
```

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

- Member of the enumeration CSignatureType set in a document.

Get the type of signature added to a document.

### operator=

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

**Parameters**

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

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

### set_credential_data_format

```cpp
void datalogics_interface::SignDoc::set_credential_data_format(CredentialDataFormat format)
```

**Parameters**

- `format` ([`CredentialDataFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialDataFormat.md)): - Encoding format of credentials used to sign a document.

**Returns:** `void`

Set the value of the credential data format option.

### set_digest_category

```cpp
void datalogics_interface::SignDoc::set_digest_category(DigestCategory category)
```

**Parameters**

- `category` ([`DigestCategory`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/DigestCategory.md)): - Cryptographic hash function to use for generating message digests.

**Returns:** `void`

Set the value of the digest category.

### set_field_id

```cpp
void datalogics_interface::SignDoc::set_field_id(SignatureFieldID id)
```

**Parameters**

- `id` ([`SignatureFieldID`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SignatureFieldID.md)): - Identifier to determine the form field that will contain the digital signature.

**Returns:** `void`

Set the field identifier used to determine the form field that will contain the digital signature.

### set_field_name

```cpp
void datalogics_interface::SignDoc::set_field_name(const std::string &name)
```

**Parameters**

- `name` (`const std::string &`): - Fully qualified name of the form field that will contain the digital signature.

**Returns:** `void`

Set the form field fully qualified name option.

### set_field_object

```cpp
void datalogics_interface::SignDoc::set_field_object(int a_value, int b_value)
```

**Parameters**

- `a_value` (`int`): - a value of the CosObject.
- `b_value` (`int`): - b value of the CosObject.

**Returns:** `void`

Set the form field CosObject option.

### set_non_pfx_passphrase

```cpp
void datalogics_interface::SignDoc::set_non_pfx_passphrase(const std::string &passphrase, unsigned int passphrase_size, CredentialStorageFormat storage_format)
```

**Parameters**

- `passphrase` (`const std::string &`): - Passphrase used to encrypt Non-PFX private key. Should be set to NULL if unencrypted.
- `passphrase_size` (`unsigned int`): - Passphrase size in bytes. Shall be set to 0 if private key is unencrypted or passphrase is stored on disk.
- `storage_format` ([`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md)): - Storage format for passphrase.

**Returns:** `void`

Set the passphrase used to decrypt Non-PFX credentials.

Note: The passphrase provided must use the exact same character encoding used to encrypt the private key. The application makes no effort whatsoever to re-encode the same.

### set_non_pfx_private_key

```cpp
void datalogics_interface::SignDoc::set_non_pfx_private_key(const std::string &private_key, unsigned int key_size, CredentialStorageFormat storage_format)
```

**Parameters**

- `private_key` (`const std::string &`): - Private key.
- `key_size` (`unsigned int`): - Size of private key in bytes. Shall be set to 0 if key is stored on disk.
- `storage_format` ([`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md)): - Storage format for private key.

**Returns:** `void`

Set the private key for Non-PFX credentials..

### set_non_pfx_signer_cert

```cpp
void datalogics_interface::SignDoc::set_non_pfx_signer_cert(const std::string &signer_cert, unsigned int cert_size, CredentialStorageFormat storage_format)
```

**Parameters**

- `signer_cert` (`const std::string &`): - Signer certificate
- `cert_size` (`unsigned int`): - Size of signer certificate in bytes. Shall be set to 0 if certificate is stored on disk.
- `storage_format` ([`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md)): - Storage format for the signer certificate.

**Returns:** `void`

Set the signer certificate for Non-PFX credentials.

### set_output_path

```cpp
void datalogics_interface::SignDoc::set_output_path(const std::string &path)
```

**Parameters**

- `path` (`const std::string &`): output Path The path to which the file is saved. A path must be specified in case a full save (PDSaveFull) is needed....

**Returns:** `void`

Set Output Path The path to which the file is saved. A path must be specified in case a full save (PDSaveFull) is needed. In case of an incremental save (PDSaveIncremental), newPath should be set to NULL. If a full save (PDSaveFull) is performed and newPath is the same as the file's original path, the new file is saved to a file system determined temporary path. The old file is then deleted and the new file is renamed to newPath.

### set_pfx_credentials

```cpp
void datalogics_interface::SignDoc::set_pfx_credentials(const std::string &credentials, CredentialStorageFormat storage_format)
```

**Parameters**

- `credentials` (`const std::string &`): - Credentials in PFX/PKCS#12 file format.
- `storage_format` ([`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md)): - Storage format for the signer certificate. (Only OnDisk is allowed for this option)

**Returns:** `void`

Set PFX/PKCS#12 credentials.

### set_pfx_passphrase

```cpp
void datalogics_interface::SignDoc::set_pfx_passphrase(const std::string &passphrase, unsigned int size, CredentialStorageFormat storage_format)
```

**Parameters**

- `passphrase` (`const std::string &`): - Passphrase used to encrypt PFX/PKCS#12 credentials. Shall be set to NULL if credentials are unencrypted.
- `size` (`unsigned int`): - Passphrase size in bytes. Shall be set to 0 if PFX credentials are unencrypted or passphrase is stored on disk.
- `storage_format` ([`CredentialStorageFormat`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/CredentialStorageFormat.md)): - Storage format for PFX/PKCS#12 credentials.

**Returns:** `void`

Set the passphrase used to decrypt PFX/PKCS#12 credentials. Note: The passphrase provided must use the exact same character encoding used to encrypt the PFX credentials. The application makes no effort whatsoever to re-encode the same.

### set_signature_box_page_number

```cpp
void datalogics_interface::SignDoc::set_signature_box_page_number(unsigned int page)
```

**Parameters**

- `page` (`unsigned int`): - Page number on which to create the widget annotation.

**Returns:** `void`

Set the page number on which the widget annotation of the signature field is created.

### set_signature_box_rectangle

```cpp
void datalogics_interface::SignDoc::set_signature_box_rectangle(const Rect &rect)
```

**Parameters**

- `rect` ([`const Rect &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/struct/Rect.md)): - Dimension of the annotation rectangle of the signature field.

**Returns:** `void`

Set the dimension of the annotation rectangle of the signature field being created.

### set_signature_type

```cpp
void datalogics_interface::SignDoc::set_signature_type(SignatureType type)
```

**Parameters**

- `type` ([`SignatureType`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/SignatureType.md)): - Member of the enumeration CSignatureType to be added to a document.

**Returns:** `void`

Set the type of signature to be added to a document.

### set_signer_info

```cpp
void datalogics_interface::SignDoc::set_signer_info(const std::string &logo_file_path, float logo_opacity, const std::string &name, const std::string &location, const std::string &reason, const std::string &contact_info, DisplayTraits display_traits)
```

**Parameters**

- `logo_file_path` (`const std::string &`): - Image to display as part of signature appearance.
- `logo_opacity` (`float`): - Opacity of image to display as part of signature appearance.
- `name` (`const std::string &`): - Name of the person or authority signing the document.
- `location` (`const std::string &`): - CPU host name or physical location of the signing.
- `reason` (`const std::string &`): - Reason for signing the document.
- `contact_info` (`const std::string &`): - Information provided by the signer to enable recipients to contact signer for signature verification.
- `display_traits` ([`DisplayTraits`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/enum/DisplayTraits.md)): - Fields to display as part of signature appearance.

**Returns:** `void`
