> 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/xamarin/digital-signature/sign-pdf.md).

# Sign a PDF document in Xamarin

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

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

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

```csharp
using (PDFDoc doc = new PDFDoc(docpath))
{
  // Retrieve the unsigned approval signature field.
  Field found_approval_field = doc.GetField(approval_field_name);
  DigitalSignatureField approval_digsig_field = new DigitalSignatureField(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.
  Image img = Image.Create(doc, appearance_img_path);
  SignatureWidget approval_signature_widget = new SignatureWidget(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, keyfile_password);

  // The actual approval signing will be done during the following incremental save operation.
  doc.Save(outpath, SDFDoc.SaveOptions.e_incremental);
}
```

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

[Digitally sign PDF files](/xamarin/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://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
