Ril.BlazorSignatureCanvas
0.1.0-alpha
dotnet add package Ril.BlazorSignatureCanvas --version 0.1.0-alpha
NuGet\Install-Package Ril.BlazorSignatureCanvas -Version 0.1.0-alpha
<PackageReference Include="Ril.BlazorSignatureCanvas" Version="0.1.0-alpha" />
<PackageVersion Include="Ril.BlazorSignatureCanvas" Version="0.1.0-alpha" />
<PackageReference Include="Ril.BlazorSignatureCanvas" />
paket add Ril.BlazorSignatureCanvas --version 0.1.0-alpha
#r "nuget: Ril.BlazorSignatureCanvas, 0.1.0-alpha"
#:package Ril.BlazorSignatureCanvas@0.1.0-alpha
#addin nuget:?package=Ril.BlazorSignatureCanvas&version=0.1.0-alpha&prerelease
#tool nuget:?package=Ril.BlazorSignatureCanvas&version=0.1.0-alpha&prerelease
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.
Usage
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>
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
canvas
canvas 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 | Versions 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. |
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.1)
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 |