We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to digitally sign PDF with certificate in Xamarin Forms?

Platform: Xamarin.Forms |
Control: PDF

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can digitally sign a PDF with certificate in Xamarin Forms.

Steps to digitally sign a PDF with certificate programmatically:

  1. Create a new C# Xamarin.Forms application project. Create Xamarin Forms application project
  2. Select a project template and required platforms to deploy the application. In this application, to share the portable assemblies across multiple platforms, the .NET Standard code sharing strategy has been selected. For more details about code sharing, refer here.

    If .NET Standard is not available in the code sharing strategy, the Portable Class Library (PCL) can be selected.

Project template screenshot

  1. Install the Syncfusion.Xamarin.Pdf NuGet package as reference to your .NET Framework application from NuGet.org. NuGet package reference
  2. Add new Forms XAML page in portable project if there is no XAML page is defined in the App class. Otherwise, proceed to the next step.
  • To add the new XAML page, right-click the project and select Add>New Items and add a Forms XAML page from the list. Name it as MainPage.
  • In the App class of portable project (App.cs), replace the existing constructor of App class with the following code snippet, which invokes the MainPage.


public App ()
    //The root page of your application
    MainPage = new MainPage();


  1. In the MainPage.Xaml, add new button as follows.
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
        <StackLayout VerticalOptions="Center">
            <Button Text="Generate Document" Clicked="OnButtonClicked" HorizontalOptions="Center"/>


  1. Include the following namespaces in the MainPage.xmal.cs file.


using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Security;
using Syncfusion.Drawing;


  1. Use the following code snippet in the click event method in MainPage.Xaml.cs to digitally sign a PDF with certificate and save it in a stream.


//Creates a new PDF document
PdfDocument document = new PdfDocument();
//Adds a new page
PdfPageBase page = document.Pages.Add();
PdfGraphics graphics = page.Graphics;
graphics.DrawString("Signature", new PdfStandardFont(PdfFontFamily.Helvetica, 10, PdfFontStyle.Bold), PdfBrushes.Black, new PointF(10,30));
//Creates a certificate instance from PFX file with private key
Stream certificateStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("DigitalSignatureSample.Assets.PDF.pfx");
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "syncfusion");
//Creates a digital signature
PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");
//Sets an image
Stream imageStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("DigitalSignatureSample.Assets.signature.jpg");
PdfBitmap signatureImage = new PdfBitmap(imageStream);
//Sets signature information
signature.Bounds = new RectangleF(new PointF(100, 30), new SizeF(100,30));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Draws the signature image
graphics.DrawImage(signatureImage, 100, 30,100,30);
//Save the PDF document to stream
MemoryStream stream = new MemoryStream();
//Closes the document
//Save the stream into PDF file
Xamarin.Forms.DependencyService.Get<ISave>().SaveAndView("DigitalSignature.pdf", "application/pdf", stream);


  1. Download the helper files from this link and add them into the mentioned project. These helper files saves the stream as a physical file and open the file for viewing.


File Name


Portable project


Represent the base interface for save operation.

iOS Project


Save implementation for iOS device.


Helper class for viewing the PDF file in iOS device.

Android project


Save implementation for Android device.

WinPhone project


Save implementation for Windows phone device.

UWP project


Save implementation for UWP device.

Windows(8.1) project


Save implementation for WinRT device.


  1. Compile and execute the application. This creates a digitally signed PDF document.

By executing the program, you will get the PDF document as follows. Output PDF document

Download the complete work sample from DigitalSignatureSample.zip.

Take a moment to peruse the documentation, where you can find other options like adding a digital signature using stream, signing an existing document, adding a timestamp in digital signature and features like redacting PDF document and protect PDF document with code examples.

Refer here to explore the rich set of Syncfusion Essential PDF features.

See Also:

Create a digitally signed PDF file in Windows Forms


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Jordan Capa
Apr 23, 2019

thanks for the information! for the beginners and want to save time, I found zetpdf.com i heard a lot of this. I suggest it because it's the fastest pdf SKD for .NET applications.


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile