Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.

Sign Documents in DevExpress PDF Viewer for .NET MAUI

  • 3 minutes to read

The DevExpress PDF viewer for .NET MAUI allows you to add handwritten signatures to PDF documents. Signatures are embedded to the document as images.

Add Signature in UI

Follow the steps below to add a signature.

  1. Tap the Sign icon in the Edit toolbar.

    DevExpress PDF Viewer for .NET MAUI - Tap Sign icon

  2. In the invoked Signatures bottom sheet, select a signature from the list to insert it or add a new signature.

    DevExpress PDF Viewer for .NET MAUI - List of signatures

  3. The selected signature appears in the center of the page which occupies the most screen space. You can specify the signature’s color, resize it, or move it within the page.

    DevExpress PDF Viewer for .NET MAUI - A signature on the page

  4. To create a new signature, tap Add in the Signatures bottom sheet and free-hand draw the signature in the invoked page.

    DevExpress PDF Viewer for .NET MAUI - Drawing a signature

    Then you can select the newly created signature from the list (See Step 2) to add it on the page.

Add Signature via API

The PDF viewer stores all signatures in the PdfViewer.Signatures collection.

Call the AddSignature method and pass collections of points that compose signature polylines to the method parameters.

<dxp:PdfViewer SignatureColor="Black">
    <!--...-->
</dxp:PdfViewer>

<dx:DXButton Clicked="DXButton_Clicked" .../>
private void DXButton_Clicked(object sender, EventArgs e) {
    // Add signature points.
    // An origin point (0,0) is the page bottom-left corner; 
    // coordinates are in document units.
    PdfPoint point1 = new PdfPoint(100, 100);
    PdfPoint point2 = new PdfPoint(110, 110);
    PdfPoint point3 = new PdfPoint(120, 100);
    PdfPoint point4 = new PdfPoint(130, 110);
    PdfPoint point5 = new PdfPoint(140, 100);
    PdfPoint point6 = new PdfPoint(150, 150);
    PdfPoint[] points = new[] { point1, point2, point3, point4, point5, point6 };

    List<IList<PdfPoint>> inks = new List<IList<PdfPoint>> { points };

    pdfViewer.AddSignature(1, inks);
}

Call the RemoveSignature method to remove a signature:

pdfViewer.RemoveSignature(pdfViewer.Signatures.First());

You can also specify the list of predefined signatures in the Signatures bottom sheet. To do this, add signatures to the PdfViewer.SignatureStorage‘s Signatures collection.

Save Signatures to the Document

The PDF Viewer does not automatically save newly added signatures to the document. Users can save documents in the Share UI. To invoke it, call the PdfViewer.ShareDocumentAsync() method or the PdfViewerCommands.ShareDocument command.

After the document is saved, users cannot edit signatures.

Respond to User Actions

SignatureAdding | SignatureAdded
Occur before/after a newly signature object is added on the page.
SignatureChanged
Occurs if a signature object property value is changed. Signature properties cannot be changed after the document is saved since the signature is embedded to the document as a plain image.
SignatureDeleting | SignatureDeleted
Occur before/after a signature is deleted.
SignatureSelectionChanged
Occur a signature is selected/deselected. Users can select signatures before the document is saved.

Prevent Adding Signatures

To prevent signing documents, you can disable the AllowAddSignature property. This disables the Sign icon in the Edit toolbar and the AddSignature method functionality.