Skip to content

How to Add Electronic Signatures to PDF Documents Using .NET MAUI PDF Viewer #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Videos/Signature/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Electronic Signatures in .NET MAUI PDF Viewer

This repository provides an example of how to add electronic signatures in a PDF document using the Syncfusion .NET MAUI PDF Viewer. It demonstrates how users can interactively insert handwritten, image-based, and freehand signatures into a PDF file.

## Process behind PDF signature integration

The sample showcases how different types of signatures can be programmatically added to a loaded PDF document. Users can enable signature mode for freehand input, insert predefined handwritten signatures using ink points, and embed image-based signatures at specific locations. These features allow for flexible and interactive signing experiences within the application.

Signature types supported in this sample:
- **Handwritten Signature**: A predefined ink stroke rendered on the PDF.
- **Image Signature**: A signature image embedded at a specified location.
- **Freehand Signature**: User-drawn signature using touch or mouse input.

## Steps to use the sample

1. Run the application to load a sample PDF document embedded in the project.
2. Use the toolbar buttons to perform signature actions:
- **Add Signature**: Enables freehand signature mode for user input.
- **Add Handwritten Signature**: Inserts a predefined ink signature on a specified page.
- **Add Image Signature**: Embeds a signature image at a defined location on the PDF.

This sample demonstrates how to integrate electronic signature capabilities into your .NET MAUI application using Syncfusion's PDF Viewer control.
24 changes: 24 additions & 0 deletions Videos/Signature/Signature.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Signature", "Signature\Signature.csproj", "{C0ADA15D-EEAE-461A-B1DE-F383458E184D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Release|Any CPU.Build.0 = Release|Any CPU
{C0ADA15D-EEAE-461A-B1DE-F383458E184D}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Videos/Signature/Signature/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Signature"
x:Class="Signature.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions Videos/Signature/Signature/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Signature
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
}
15 changes: 15 additions & 0 deletions Videos/Signature/Signature/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Signature.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Signature"
Shell.FlyoutBehavior="Disabled"
Title="Signature">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
10 changes: 10 additions & 0 deletions Videos/Signature/Signature/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Signature
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
Binary file not shown.
Binary file added Videos/Signature/Signature/Assets/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions Videos/Signature/Signature/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:syncfusion="clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Signature.MainPage">

<ContentPage.Content>
<Grid>
<!-- Define layout with two rows: one for header/buttons, one for PDF viewer -->
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<!-- Top row: Header and action buttons -->
<Grid Grid.Row="0" ColumnDefinitions="Auto,*">
<!-- Title label for the PDF viewer -->
<Label Text="PDF Viewer"
FontSize="16"
VerticalOptions="Center"
Grid.Column="0"
Margin="10,0,0,0" />

<!-- Scrollable horizontal layout for signature action buttons -->
<ScrollView Orientation="Horizontal"
HorizontalScrollBarVisibility="Never"
HorizontalOptions="End"
Grid.Column="1">
<HorizontalStackLayout Spacing="10" Padding="0,0,15,0">
<!-- Button to enable signature drawing mode -->
<Button Text="Add Signature"
Clicked="OnAddSignatureClicked" />

<!-- Button to add a predefined handwritten signature -->
<Button Text="Add Handwritten Signature"
Clicked="OnAddHandwrittenSignatureClicked" />

<!-- Button to add an image-based signature -->
<Button Text="Add Image Signature"
Clicked="OnAddImageSignatureClicked" />
</HorizontalStackLayout>
</ScrollView>
</Grid>

<!-- Main content: PDF viewer control without toolbars -->
<syncfusion:SfPdfViewer x:Name="PdfViewer"
ShowToolbars="False"
Grid.Row="1" />
</Grid>
</ContentPage.Content>
</ContentPage>
Loading