/ Signature / Customization
Search results

Customization in Angular Signature component

21 Dec 2022 / 3 minutes to read

The Signature component draws stroke/path using moveTo() and lineTo() methods to connect one or more points while drawing in canvas. The stroke width can be modified by using its color and width. And the background can be modified by using its background color and background image.

Stroke Width

The variable stroke width is based on the values of maxStrokeWidth, minStrokeWidth and velocity for smoother and realistic signature. The default value of minimum stroke width is set as 0.5, maximum stroke width is set as 2.5 and velocity is set as 0.7.

In the following example, minimum stroke width is set as 0.5, maximum stroke width is set as 3 and velocity is set as 0.7.

Copied to clipboard
import { Component } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';

enableRipple(true);

@Component({
selector: 'app-root',
template: `<h4>Sign here</h4>
        <!-- To Render Signature. -->
        <canvas ejs-signature #signature id="signature" [maxStrokeWidth]="3" [minStrokeWidth]="0.5" [velocity]="0.7"></canvas>`
})
export class AppComponent {}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,FormsModule
    ],
    declarations: [AppComponent, SignatureComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

Stroke Color

Color of the stroke can be specified by using strokeColor property and it accepts hexadecimal code, RGB, and text. The default value of this property is “#000000”.

Copied to clipboard
import { Component, ViewChild } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';

enableRipple(true);

@Component({
selector: 'app-root',
template: `<div id="input">
            <input type="text" id="text" placeholder="Enter the Stroke Color Value" >
            <button ejs-button cssClass="e-primary" (click)="setColor()">Set Stroke Color</button>
        </div>
        <div id="signature-control">
        <canvas ejs-signature #signature id="signature"></canvas>
        </div>`
})
export class AppComponent {
@ViewChild('signature')
public signature: SignatureComponent;
setColor(): void {
    let color = document.getElementById('text').value;
    this.signature.strokeColor = color;
}
}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,FormsModule,ButtonModule
    ],
    declarations: [AppComponent, SignatureComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

Background Color

Background color of a signature can be specified by using backgroundColor property and it accepts hexadecimal code, RGB, and text. The default value of this property is “#ffffff”.

Copied to clipboard
import { Component, ViewChild } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';

enableRipple(true);

@Component({
selector: 'app-root',
template: `<div id="input">
            <input type="text" id="text" placeholder="Enter the Background Color Value" >
            <button ejs-button cssClass="e-primary" (click)="setBgColor()">Set Background Color</button>
        </div>
        <div id="signature-control">
        <canvas ejs-signature #signature id="signature"></canvas>
        </div>`
})
export class AppComponent {
@ViewChild('signature')
public signature: SignatureComponent;
setBgColor(): void {
    let bgColor = document.getElementById('text').value;
    this.signature.backgroundColor = bgColor;
}
}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,FormsModule,ButtonModule
    ],
    declarations: [AppComponent, SignatureComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

Background Image

Background image of a signature can be specified by using backgroundImage property. The background image can be set by either hosting the image in our local IIS or online image.

Copied to clipboard
import { Component, ViewChild } from '@angular/core';
import { enableRipple } from '@syncfusion/ej2-base';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';

enableRipple(true);

@Component({
selector: 'app-root',
template: `<div id="input">
            <input type="text" id="text" placeholder="Enter the URL of the background Image" >
            <button ejs-button cssClass="e-primary" (click)="setBgImage()">Set Background Image</button>
        </div>
        <div id="signature-control">
        <canvas ejs-signature #signature id="signature"></canvas>
        </div>`
})
export class AppComponent {
@ViewChild('signature')
public signature: SignatureComponent;
setBgImage(): void {
    let bgImage = document.getElementById('text').value;
    this.signature.backgroundImage = bgImage;
}
}
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { SignatureComponent } from '@syncfusion/ej2-angular-inputs';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,FormsModule,ButtonModule
    ],
    declarations: [AppComponent, SignatureComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

See Also