> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/ios/digital-signature/sign-pdf.md).

# Sign a PDF document on iOS

Learn how to digitally sign PDF files with the Apryse SDK, ensuring authenticity and security. Get a full code sample for adding approval signatures to PDF documents using a Digital Certificate. The A

To sign an existing approval signature field in a PDF Document:

{% tabs %}
{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTPDFDoc* doc = [[PTPDFDoc alloc] initWithFilepath: docpath];

// Retrieve the unsigned approval signature field.
PTField* found_approval_field = [doc GetField: approval_field_name];
PTDigitalSignatureField* approval_digsig_field = [[PTDigitalSignatureField alloc] initWithIn_field: found_approval_field];

// (OPTIONAL) Add more information to the signature dictionary.
[approval_digsig_field SetLocation: @"Vancouver, BC"];
[approval_digsig_field SetReason: @"Document approval."];
[approval_digsig_field SetContactInfo: @"www.apryse.com"];

// (OPTIONAL) Add an appearance to the signature field.
PTImage* img = [PTImage CreateWithFile: [doc GetSDFDoc] filename: appearance_img_path encoder_hints: [[PTObj alloc]init]];
PTSignatureWidget* approval_signature_widget = [[PTSignatureWidget alloc] initWithD: [found_approval_field GetSDFObj]];
[approval_signature_widget CreateSignatureAppearance: img];

// Prepare the signature and signature handler for signing.
[approval_digsig_field SignOnNextSave: private_key_file_path in_password: keyfile_password];

// The actual approval signing will be done during the following incremental save operation.
[doc SaveToFile: outpath flags: e_ptincremental];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let doc: PTPDFDoc = PTPDFDoc(filepath: in_docpath)

// Retrieve the unsigned approval signature field.
let found_approval_field: PTField = doc.getField(in_approval_field_name)
let found_approval_signature_digsig_field: PTDigitalSignatureField = PTDigitalSignatureField(in_field: found_approval_field)

// (OPTIONAL) Add more information to the signature dictionary.
found_approval_signature_digsig_field.setLocation("Vancouver, BC")
found_approval_signature_digsig_field.setReason("Document certification.")
found_approval_signature_digsig_field.setContactInfo("www.apryse.com")

// (OPTIONAL) Add an appearance to the signature field.
let img: PTImage = PTImage.create(withFile: doc.getSDFDoc(), filename: in_appearance_img_path, encoder_hints: PTObj())
let found_approval_signature_widget: PTSignatureWidget = PTSignatureWidget(d: found_approval_field.getSDFObj())
found_approval_signature_widget.createSignatureAppearance(img)

// Prepare the signature and signature handler for signing.
found_approval_signature_digsig_field.sign(onNextSave: in_private_key_file_path, in_password: in_keyfile_password)

// The actual approval signing will be done during the following incremental save operation.
doc.save(toFile: in_outpath, flags: e_ptincremental.rawValue)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Digitally sign PDF files](/ios/get-started/samples.md#digitalsignatures) Full code sample which demonstrates using the digital signature API to digitally sign and/or certify PDF documents.

## About Adding An Approval Signature to a PDF Document

The Apryse SDK enables approval signatures in PDF documents using a Digital Certificate, in accordance with the latest PDF specification. By leveraging [public key infrastructure (PKI)](https://en.wikipedia.org/wiki/Public_key_infrastructure) technology, with a certificate issued by a trusted [certificate authority (CA)](https://en.wikipedia.org/wiki/Certificate_authority), a signer can use a certificate-based digital ID to guarantee the authenticity of a signature. Placement of a digital signature using a certificate can also guarantee that a document was not modified since the signature was placed, ensuring the authenticity of the document.

![](https://4149080208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgY6xtY9ZQd9XMpvWlGM0%2Fuploads%2Fgit-blob-51c4b698c1ec2efcc0d46686d1342347626f1a9d%2F8130e2be0155c3a56bbf8548f836090a8beb0ac2-299x658.png?alt=media)

Image taken from Apryse WebViewer

Above is an example of a document containing a certified signature, guaranteed by a certificate generated by Apryse.com.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/ios/digital-signature/sign-pdf.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
