Getting Started with EJ2 JavaScript Signature
21 Nov 20263 minutes to read
This section explains the steps required to create a simple Essential® JS 2 Signature and demonstrate the basic usage of the Signature control in a JavaScript application.
Dependencies
The list of dependencies required to use the Signature component in your application is given below:
|-- @syncfusion/ej2-inputs
|-- @syncfusion/ej2-baseSetup for local environment
Refer to the following steps to set up your local environment.
Step 1: Create a root folder named my-app for your application.
Step 2: Create a my-app/resources folder to store local scripts and styles files.
Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Signature control.
Control Initialization
The Essential® JS 2 JavaScript controls can be initialized by using below css styles and Scripts
Add Syncfusion® Signature CSS Styles and Scripts
Include the following CSS and JavaScript files from CDN in the <head> section of the index.html file. The ej2-base scripts are required dependency packages for the Signature component.
Styles(CSS):
https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/signature/index.cssScripts (javascript):
https://cdn.syncfusion.com/ej2/35.1.37/ej2-base/dist/global/ej2-base.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-inputs/dist/global/ej2-inputs.min.jsAdding Signature component to the application
Add the HTML canvas tag with the id attribute as signature to your index.html file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Essential JS 2 - Signature</title>
<!-- Essential JS 2 Signature's dependent bootstrap5.3 theme -->
<link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/signature/index.css" rel="stylesheet" />
<!-- Essential JS 2 Signature's dependent scripts -->
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
<!-- Essential JS 2 Signature's global script -->
<script src="https://cdn.syncfusion.com/ej2/35.2.12/ej2-inputs/dist/global/ej2-inputs.min.js" type="text/javascript"></script>
<!--style reference from app-->
<link href="index.css" rel="stylesheet" />
</head>
<body>
<h4>Sign here</h4>
<!--element which is going to render-->
<div id="signature-control">
<canvas id="signature"></canvas>
</div>
</body>
<script>
var signature = new ej.inputs.Signature({}, '#signature');
</script>
</html>#container {
visibility: hidden;
padding-left: 5%;
width: 100%;
}
#loader {
color: #008cff;
font-family: 'Helvetica Neue','calibiri';
font-size: 14px;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
#signature {
border: 1px solid lightgray;
height: 100%;
width: 100%;
}
#signature-control {
height: 300px;
width: 550px;
}