DEV Community

Cover image for How to Digitally Sign PDFs in Android Apps with .NET MAUI
Calvince Moth for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

How to Digitally Sign PDFs in Android Apps with .NET MAUI

TL;DR: Need secure PDF signing in Android apps with .NET MAUI? This hands-on guide walks through digitally signing new and existing PDFs using a PFX certificate, customizing visible signatures, adding timestamps, tracking revisions, and managing signature fields, all with production-ready, developer-friendly APIs.

Why digital signatures matter for Android PDFs

As mobile apps increasingly handle contracts, approvals, and sensitive documents, ensuring document integrity and authenticity is critical.

Digital signatures play a key role by providing:

  • Integrity: Ensures the document hasn’t been altered.
  • Authenticity: Verifies the signer’s identity.
  • Non-repudiation: Prevents signers from denying their actions.
  • Role in mobile workflows: They enable quick, secure approvals and document exchanges directly from Android devices, ensuring compliance and trust.

Unlike electronic signatures (simple images or consent marks), *digital signatures rely on cryptographic certificates , making them suitable for compliance-driven and security-sensitive workflows.

However, developers often struggle with:

  • Managing certificates securely
  • Customizing signature appearance
  • Implementing standards-compliant signing in mobile apps

This is where a .NET MAUI-based PDF solution significantly simplifies the process. The Syncfusion ®.NET PDF Library supports digital signatures in Android through .NET MAUI, making it easy to add secure signatures to PDF documents. It offers APIs for certificate-based signing, appearance customization, timestamping, and validation, all within your application.

In this blog post, we’ll walk through using the Syncfusion .NET PDF Library with .NET MAUI to sign new and existing PDFs and implement advanced features such as timestamping, deferred signing, and revision tracking.

By the end, you’ll have a clear roadmap to integrate secure, professional digital signing into your Android MAUI apps.

Implement digital signatures in Android with Syncfusion .NET MAUI PDF Library

The Syncfusion .NET PDF Library simplifies implementing digital signatures in Android apps built with .NET MAUI.

Key features include:

  • Easy-to-use APIs for adding, validating, and managing signatures.
  • Support for visible signatures with custom images and metadata.
  • Compliance with global standards like PAdES and X.509.

With these capabilities, creating secure and professional signing experiences on mobile is effortless.

Set up a .NET MAUI project for Android

  1. Create a new .NET MAUI App in Visual Studio 2022 and ensure the latest .NET MAUI workload is installed.
  2. Install Syncfusion PDF Library
    • In Solution Explorer, right-click your project and select Manage NuGet Packages.
    • Search for Syncfusion.Pdf.Net and install it.

<alt-text>


Installing Syncfusion PDF Library via NuGet in Visual Studio

Note: Run the sample using an Android Emulator or connect a physical Android device for testing.

Curious about creating a .NET MAUI sample using Syncfusion PDF Library? Explore our official documentation for a complete walkthrough.

Add digital signatures to your PDFs in Android using .NET MAUI

Adding a digital signature to a PDF ensures the PDF’s authenticity and legal validity. The process involves creating or loading a document, applying a certificate-based signature, and saving the signed file.

If you’re wondering how to add a digital signature to a PDF on Android, this step-by-step guide will help you integrate it seamlessly.

Step 1: Create and sign a new PDF document

You can create a new PDF from scratch and sign it using a digital certificate. The signing process typically includes:

  • Creating the PDF document
  • Adding a page
  • Loading a certificate (PFX)
  • Applying a signature field
  • Customizing signer metadata and appearance

Example code: Create and sign a new PDF

//Creates a new PDF document.
PdfDocument document = new PdfDocument();

//Adds a new page.
PdfPageBase page = document.Pages.Add();

//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;

//Creates a certificate instance from a PFX file with a private key.
FileStream certificateStream = new FileStream("PDF.pfx", FileMode.Open, FileAccess.Read);
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "password123");

//Creates a digital signature.
PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");

//Sets an image for the signature field.
FileStream imageStream = new FileStream("signature.jpg", FileMode.Open, FileAccess.Read);

//Sets an image for the signature field.
PdfBitmap signatureImage = new PdfBitmap(imageStream);

//Sets signature information.
signature.Bounds = new RectangleF(new PointF(0, 0), signatureImage.PhysicalDimension);
signature.SignedName = "Syncfusion";
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am the author of this document.";

//Draws the signature image.
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, 0, 0);

//Saves the PDF to the memory stream.
using MemoryStream ms = new();
document.Save(ms);

//Close the PDF document
document.Close(true);
ms.Position = 0;#

//Saves the memory stream as a file.
SaveService saveService = new();
saveService.SaveAndView("Result.pdf", "application/pdf", ms);
Enter fullscreen mode Exit fullscreen mode

Step 2: Sign an existing PDF document

To sign an existing PDF:

  • Load the document
  • Access the required page and signature field
  • Apply a certificate-based signature

Syncfusion PDF Library makes this process smooth through APIs that handle field detection and signing.

Example Code: Sign an existing PDF

Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
string basePath = "CreatePdfDemoSample.Resources.Data.";
Stream inputStream = assembly.GetManifestResourceStream(basePath + "PdfDocument.pdf");
Stream pfxStream = assembly.GetManifestResourceStream(basePath + "PDF.pfx");
Stream signStream = assembly.GetManifestResourceStream(basePath + "signature.png");

PdfLoadedDocument lDoc = new PdfLoadedDocument(inputStream);
PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage;
PdfLoadedSignatureField signField = lDoc.Form.Fields[6] as PdfLoadedSignatureField;

//Creates a certificate instance from PFX file with private key.
PdfCertificate pdfCert = new PdfCertificate(pfxStream, "password123");

//Creates a digital signature.
PdfSignature signature = new PdfSignature(lDoc, page, pdfCert, "Signature", signField);

//Sets an image for the signature field. 
PdfBitmap signatureImage = new PdfBitmap(signStream);

//Sets signature information.
signature.Bounds = signField.Bounds;
signature.SignedName = "Syncfusion";
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am the author of this document.";

//Create appearance for the digital signature.
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, 60, 35));

//Saves the PDF to the memory stream.
using MemoryStream ms = new();
lDoc.Save(ms);

//Close the PDF document
lDoc.Close(true);
ms.Position = 0;

//Saves the memory stream as a file.
SaveService saveService = new();
saveService.SaveAndView("Result.pdf", "application/pdf", ms);
Enter fullscreen mode Exit fullscreen mode

This article was originally published at Syncfusion.com.

Top comments (0)