Exploring the Blazor Signature Pad Component | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (175).NET Core  (29).NET MAUI  (208)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (220)BoldSign  (15)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (67)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (101)Streamlit  (1)Succinctly series  (131)Syncfusion  (920)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (37)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (151)Chart  (132)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (633)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (41)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (508)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (11)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (597)What's new  (333)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Exploring the Blazor Signature Pad Component

Exploring the Blazor Signature Pad Component

The Blazor Signature Pad component is a graphical interface that allows users to draw smooth signatures as vector outline strokes using variable-width Bezier curve interpolation. You can save signatures as images and vice versa. Also, you can use your finger, a pen, or mouse on desktop and mobile devices to draw your signature.

Parts of the Blazor Signature Pad Component
Parts of the Blazor Signature Pad Component

It supports all the common web standards and functionalities that our other Essential Blazor controls do: web accessibility, right-to-left rendering, keyboard interaction, modular architecture, and responsiveness, all the while being touch-friendly and sporting a lightweight UI.

Let’s explore the Blazor Signature Pad control, its UI design, and available features with code examples.

Use cases

The Blazor Signature Pad component is used to draw realistic and smooth signatures. The most common use case of the Signature Pad is a form within an app, online or off—anywhere you need to capture a signature.

Key features

Key features of the Blazor Signature Pad component are as follow:

  • Customize the stroke and background.
  • Save and load signatures.
  • Draw signatures.
  • Clear, undo, and redo signatures.
  • Utilize keyboard accessibility and responsiveness.

Customize the stroke and background

The stroke width or thickness is calculated based on the MinStrokeWidth, MaxStrokeWidth, Velocity, and drawing speed. We can also customize the stroke color, background color, and background image using the properties available in the Blazor Signature Pad.

You can set the background image by either hosting the image in your local IIS or using an online image.

Refer to the following code example to load the Signature Pad with a background image: 

@using Syncfusion.Blazor.Inputs
 
<div class=”control-section”>
 <div id=”signature-control”>
  <div class=’e-sign-heading’>
   <span id=”signdescription”>Sign below</span>
  </div>
  <div class=’e-sign-content’>
   <SfSignature BackgroundImage="http://localhost:6969/image/MySignature-1.png" style="width: 400px; height: 300px; background-repeat: no-repeat"></SfSignature>
  </div>
 </div>
</div>
 
<style>
  .e-sign-content,
  .e-sign-heading {
        width: 400px;
  }
 
  #signdescription {
        font-size: 14px;
        padding-bottom: 10px;
  }
</style>

Refer to the following image.

Loading the Blazor Signature Pad with a Background Image
Loading the Blazor Signature Pad with a Background Image

To view the hosted images, we have to enable the Directory Browsing option in IIS, which will create the web.config file inside the hosted folder. Include the following code in the web.config file to resolve the CORS issue.

<?xml version=”1.0” encoding=”UTF-8”?>
<configuration>
 <system.webServer>
  <directoryBrowse enabled=”true” />
  <httpProtocol>
   <customHeaders>
    <clear />
    <add name=”Access-Control-Allow-Origin” value=”*” />
   </customHeaders>
  </httpProtocol>
 </system.webServer>
</configuration>

Save and load signatures

In the Signature Pad component, you can draw a signature and save it in Base64, blob, and image formats using the SaveAsync method. This method accepts the file type and file name as parameters and can save the signature in PNG, JPEG, and SVG formats. You can also save the signature with a background color and image using the SaveWithBackground property.

The Blazor Signature Pad enables the users to load a pre-drawn signature as Base64 or a URL using the LoadAsync method. This method accepts the URL or Base 64, height, and width of the signature canvas as parameters. It also supports PNG, JPEG, and SVG image formats.

Refer to the following code example to load the pre-drawn signature in Base64 format.

@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Buttons
 
<div class="control-section">
 <div id="signature-control">
  <div class='e-sign-heading'>
   <span id="signdescription">Sign below</span>
   <span class="e-btn-options">
    <SfButton IsPrimary="true" class="e-sign-load" @OnClick="OnLoadBase64">Reload</SfButton>
   </span>
  </div>
  <div class='e-sign-content'>
   <SfSignature @ref="signature" style="width: 400px; height: 300px;"></SfSignature>
  </div>
 </div>
</div>
@code{
 private SfSignature signature;
 private string sign;
 
 private async Task OnLoadBase64()
 {
   sign = await signature.GetSignatureAsync(); // Get signature as Base 64.
   await signature.ClearAsync();
   await signature.LoadAsync(sign, 400, 300); // Load signature as Base 64.
 }
}
<style>
 .e-sign-content,
 .e-sign-heading {
    width: 400px;
 }
 
 #signdescription {
    font-size: 14px;
    padding-bottom: 10px;
 }
 
 .e-btn-options {
    float: right;
    margin-bottom: 10px;
 }
</style>

Now let’s learn how to load the pre-drawn signature as a URL. This can be done by either hosting the signature in your local IIS or using an online signature image.

@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Buttons
 
<div class="control-section">
 <div id="signature-control">
  <div class='e-sign-heading'>
   <span>
    <SfTextBox @ref="text" Placeholder='Enter the hosted link'></SfTextBox>
   </span>
   <span class="e-btn-options">
    <SfButton IsPrimary="true" class="e-sign-load" @OnClick="OnLoad">Load</SfButton>
   </span>
   <span id="signdescription">Sign below</span>
  </div>
  <div class='e-sign-content'>
   <SfSignature @ref="signature" style="width: 400px; height: 300px;"></SfSignature>
  </div>
 </div>
</div>
@code{
 private SfSignature signature;
 private string sign;
 private SfTextBox text;
 private async Task OnLoad()
 {
   await signature.LoadAsync(text.Value, 400, 400); // To load the Signature as URL.
 }
}
<style>
 .e-sign-content,
 .e-sign-heading {
    width: 400px;
 }
 
 #signdescription {
    font-size: 14px;
    padding-bottom: 10px;
 }
 
 .e-btn-options {
    float: right;
    margin: 10px 0px 10px;
 }
</style>

Refer to the following image.

Loading a Signature as a URL in Blazor Signature Pad
Loading a Signature as a URL in Blazor Signature Pad

Type text as signature

You can easily transform any text into a signature using different font families and font sizes. To do so, use the DrawAsync method, which accepts the signature text, font family, and font size as parameters.

Refer to the following GIF image.

Typed Text as a Signature in Blazor Signature Pad
Typed Text as a Signature in Blazor Signature Pad

Clear, undo, and redo

We can clear the pre-drawn signature using the ClearAsync method, which will clear the entire canvas.

Performing undo and redo actions will undo the last action performed and revert the last undo action performed, respectively, in the Signature Pad component. These can be done by using the UndoAsync and RedoAsync methods.

These actions are handled by saving a snapshot whenever a change occurs in the canvas and maintaining its index value to navigate to when performing undo and redo actions. The index value will be decreased to load the previous action and perform an undo and increased to load the next action and perform a redo.

You can enable or disable the undo and redo buttons using the CanUndoAsync and CanRedoAsync methods. Also, you can easily enable or disable the Clear button using the IsEmptyAsync method.

Refer to the following GIF image.

Clear, Undo and Redo Options in Blazor Signature Pad
Clear, Undo and Redo Options in Blazor Signature Pad

Keyboard accessibility

Also, you can easily interact with the Blazor Signature Pad component using the following keyboard shortcuts:

  • Ctrl+S: Save the signature in the default format (PNG).
  • Ctrl+Z: Undo the previous action.
  • Ctrl+Y: Redo the most recent undo action.

Responsiveness and touch-friendly UI

By default, the Blazor Signature Pad adapts well to all mobile devices based on the screen size. It is a touch-friendly control, so users can easily use their finger, pen, or mouse on both desktop and mobile devices to draw signatures.

References

For more details, refer to our Getting Started with Blazor Signature Pad Component documentation and demos.

Conclusion

Thanks for reading! We hope you enjoyed this quick introduction to the design and features of our Blazor Signature Pad component. Along with what we’ve seen in this blog, the Signature Pad also supports built-in themes like Material, Bootstrap, and more.

The Signature Pad is available in our Angular, Blazor, React, Vue, JavaScript, ASP.NET (Core and MVC) platforms. Try them out and enjoy hassle-free signing!

If you have any questions, please let us know in the comments section below. You can also contact us through our support forumssupport portal, or feedback portal. We are always happy to assist you!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed