Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 2.06 KB

README.md

File metadata and controls

37 lines (28 loc) · 2.06 KB

#Signature to Image .Net License: BSD License Version: 2.0 (2012-02-11) Requirements: .NET 4.0

A supplemental class for Signature Pad (https://github.com/thomasjbradley/signature-pad) that generates an image of the signature's JSON output server-side using C#. Alternately, you can provide a name and generate an image that resembles a signature from a font. Similar to Signature to Image PHP (https://github.com/thomasjbradley/signature-to-image)

##Creating image based on Json If you want to regenerate the signature based on the Json generated by Signature Pad you just need to call the SigJsonToImage method like so:

var sigToImg = new SignatureToImage();
var signatureImage = sigToImg.SigJsonToImage(signatureJson);

##Creating image based on name Similar to using Json, if the user typed their name instead of using the pen, just pass in their name to the SigNameToImage method and it will use a font to regenerate the signature:

var sigToImg = new SignatureToImage();
var signatureImage = sigToImg.SigNameToImage("Sir John A. Macdonald");

By default, the font "Journal" will be used. You probably already have the font file in your project as Signature Pad required it. If you do not have the Journal font installed on your server you can pass in the absolute path to the font file as an optional parameter:

var sigToImg = new SignatureToImage();
var signatureImage = sigToImg.SigNameToImage("Sir John A. Macdonald", fontPath: HttpContext.Current.Request.PhysicalApplicationPath + @"Resources\journal.ttf");

##Properties The default values are shown below, but you can change any or all of them as you wish (PenWidth, FontSize, and FontName only apply to SigNameToImage):

var sigToImg = new SignatureToImage({
    BackgroundColor = System.Drawing.Color.White,
    PenColor = System.Drawing.Color.FromArgb(20, 83, 148),
    CanvasWidth = 198,
    CanvasHeight = 45,
    PenWidth = 2,
    FontSize = 24,
    FontName = "Journal"
});
var signatureImage = sigToImg.SigNameToImage("Sir John A. Macdonald");