This is an ionic 4 plugin to input signature based on wulfsolter repository. It's HTML5 canvas based and uses variable width Bézier curve interpolation based on Smoother Signatures post by Square. It works in all modern desktop and mobile browsers and doesn't depend on any external libraries.
This project was tested in ionic 4.0.0-beta.15 for my personal purposes
- Install the plugin
npm install ionicsignaturepad
- Import and add in app.module.ts
....
import { IonicSignaturePadModule,IonicsignaturepadProvider } from 'ionicsignaturepad';
....
- In app.module.ts, add the module and provider to imports and providers sections
imports {
....
IonicSignaturePadModule,
....
}
providers [
....
IonicsignaturepadProvider,
....
]
- In component.module.ts, import and export the component
...
import { IonicSignaturePadModule, IonicsignaturepadComponent } from 'ionicsignaturepad';
...
imports:[
IonicSignaturePadModule
]
...
exports: [
...
IonicsignaturepadComponent,
...
]
- Use it in respective html like this:
<ion-signaturepad [(ngModel)]="signature"></ion-signature>
//Base 64 image of the signature
<p>{{signature}}</p>
- You can also use it with optional options:
<ion-signaturepad [(ngModel)]="signature" [canvasWidth]="300" [canvasHeight]="300" [backgroundColor]="#ffffff"></ion-signature>
//Base 64 image of the signature
<p>{{signature}}</p>