About this project

Signature Pad is a JavaScript library for drawing smooth signatures in the browser. It is based on the HTML5 canvas element and uses variable-width Bézier curve interpolation, an approach described in Square's "Smoother Signatures" article. The library has no external dependencies and is intended to work in modern desktop and mobile browsers. Installation is available through npm (`npm install --save signature_pad`) or Yarn, and it can also be loaded directly with a script tag from a CDN. It is distributed as both UMD and ES6 module builds. Core API: after creating a `SignaturePad` instance on a canvas element, you can export the drawing with `toDataURL()` as PNG, JPEG (with optional quality) or SVG data URL, or get raw SVG markup with `toSVG()`. Signatures can be loaded back with `fromDataURL()`, or represented as an array of point groups via `toData()` and restored with `fromData()`. Other methods include `redraw()`, `clear()`, `isEmpty()`, `off()` and `on()` for unbinding and rebinding event handlers. Options include `dotSize`, `minWidth`, `maxWidth`, `throttle`, `minDistance`, `backgroundColor`, `penColor`, `velocityFilterWeight` and `canvasContextOptions`. They can be set at initialization or changed at runtime. Events include `beginStroke` (cancelable), `endStroke`, `beforeUpdateStroke` and `afterUpdateStroke`, registered through `addEventListener`. The README also documents practical topics: handling high-DPI screens by scaling the canvas with `devicePixelRatio`, dealing with browser-initiated canvas clearing on resize, decoding data URI images on the server side (with Ruby, PHP and C# examples), trimming empty space around a signature, and drawing over an existing image. The project is released under the MIT License.