Ril.BlazorSignatureCanvas 0.1.0-alpha

This is a prerelease version of Ril.BlazorSignatureCanvas.
dotnet add package Ril.BlazorSignatureCanvas --version 0.1.0-alpha
                    
NuGet\Install-Package Ril.BlazorSignatureCanvas -Version 0.1.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ril.BlazorSignatureCanvas" Version="0.1.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ril.BlazorSignatureCanvas" Version="0.1.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Ril.BlazorSignatureCanvas" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ril.BlazorSignatureCanvas --version 0.1.0-alpha
                    
#r "nuget: Ril.BlazorSignatureCanvas, 0.1.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ril.BlazorSignatureCanvas@0.1.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ril.BlazorSignatureCanvas&version=0.1.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Ril.BlazorSignatureCanvas&version=0.1.0-alpha&prerelease
                    
Install as a Cake Tool

Ril.BlazorSignatureCanvas

A Blazor wrapper component for the Signature Pad JavaScript library, by Szymon Nowak. Thanks go out to Allan Mobley for his work on an earlier project, Blazor.SignaturePad.

Live Demo

Usage

  1. Install the Nuget package

  2. Link the static JavaScript resource. Add the following to your Blazor host page (Index.html, _Host.cshtml, or whatever your case may be):

    <script src="/_content/Ril.BlazorSignatureCanvas/BlazorSignatureCanvas.js"></ script>
    
  3. Use the component. You'll probably want to capture a reference (@ref) to do anything useful such as saving a signature. A bare-bones example may look like this:

    <SignatureCanvas
        class="my-special-styling-class"
        @ref=signatureCanvas
        width="400" height="200"
        />
    
    <button @onclick=HandleClear>Clear Signature</button>
    
    <button @onclick=HandleSave>Save Signature</button>
    
    @code {
        SignatureCanvas signatureCanvas
    
        async Task HandleClear() {
            await signatureCanvas.Clear();
        }
    
        async Task HandleSave() {
            string data = await signatureCanvas.ToDataURL();
            // do something with the data...
        }
    }
    

    Extra unmatched attributes are passed directly to the underlying canvascanvas element.

Tips

Blazor Server Message Size

The returned value from any JSInterop call needs to be asynchronously sent back to the SignatureCanvas component (which, for Blazor Server apps, lives on the server) via a SignalR message. It is quite possible for a DataURL to exceed the maximum 32kb SignalR message size for signatures of sufficient size and/or complexity, resulting in a disconnected circuit and the dreaded "reconnecting to server" message. Happily, this is not an issue for Blazor WebAssembly apps.

If you encounter this issue, the simplest fix is to use JPEG in place of PNG, which is a tiny fraction of the size. Calling .ToDataURL("image/jpeg") will achieve this.

If JPEG is not an option, or you are still experiencing issues, the maximum SignalR message size can be configured in your Program.js file as follows:

builder.Services
    .AddServerSideBlazor()
    .AddHubOptions(config =>
    {
        config.MaximumReceiveMessageSize = 1024 * 200; // increase maximum to 200kb
    });
    
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Ril.BlazorSignatureCanvas:

Repository Stars
dotnet/maui-samples
Samples for .NET Multi-Platform App UI (.NET MAUI)
Version Downloads Last Updated
0.1.0-alpha 19,687 2/1/2022
0.0.6-alpha 435 1/31/2022
0.0.5-alpha 878 1/31/2022
0.0.4-alpha 433 1/31/2022
0.0.2-alpha 416 1/31/2022
0.0.1-alpha 422 1/31/2022