ionic framework Making a Signature Drawpad
Ionic Framework Making a Signature Drawpad today discussed this task is Recently I was working on some app and wanted an opportunity for the user to write something down. As I was working with the html5 canvas, I found a very good looking library which I want to show you today: The signature pad. This library allows to draw on your device, with not just a normal bold line but with a quite realistic appeal. Let’s make a simple app to test it!
Setup a simple App
ionic start devdactic-signature blank
cd devdactic-signature
bower install --save signature_pad
I like to install those packages whenever possible through bower, as it makes managing those dependencies a lot easier. As bower will install our libs always to the same folder, we can go ahead and include the js file at the top of our index.html file:
<script src='lib/signature_pad/signature_pad.js'></script>
Include the Signature Pad functionalities
To use the library, we must define a canvas element inside our index.html which will be the area for the user to draw his signature (or anything else). For this tutorial, we will just have a tiny area at the top, which has the signatureCanvas id so we can get it later in our controller. Additionally I created 2 buttons, which can clear the area or save the current content of the area. Below we have a image, which will show our last saved signature from the canvas. So go ahead and replace everything inside the body with this:
<body ng-app='starter' ng-controller='SignatureCtrl'>
<ion-pane>
<ion-header-bar class='bar-calm'>
<h1 class='title'>Devdactic Signature Drawpad</h1>
</ion-header-bar>
<ion-content class='has-header padding' scroll='false'>
<canvas id='signatureCanvas' width='300' height='180' style='border: 1px solid black;'></canvas>
<div class='button-bar'>
<a class='button button-energized' ng-click='clearCanvas()'>Clear</a>
<a class='button button-balanced' ng-click='saveCanvas()'>Save</a>
</div>
<br>
<img ng-src='{{signature}}'/>
</ion-content>
</ion-pane>
</body>
.controller('SignatureCtrl', function($scope) {
var canvas = document.getElementById('signatureCanvas');
var signaturePad = new SignaturePad(canvas);
$scope.clearCanvas = function() {
signaturePad.clear();
}
$scope.saveCanvas = function() {
var sigImg = signaturePad.toDataURL();
$scope.signature = sigImg;
}
})
First of all, we get our canvas element through our defined id. Afterwards, we create a new SignaruePad from our canvas element. Now we can simply call functions on this element, thats all! Our clearCanvas() will, well, obviously just clear the canvas drawing area, and our saveCanvas() function gets the image data from the canvas by calling the toDataURL() on our signature pad. This info can be directly used to update our image below.
These are just some simple functions, there are some more things you can edit, which include:
- dotSize – Size of dot
- minWidth – Minimum size of a line
- maxWidth – Maximum sizw of a line
- backgroundColor – Color used when the canvas is cleared
- penColor – Color of your line
- onBegin & onEnd – Callback functions
15 comments
commentsHi, thanks for your great tutorial. Now I can draw and save the signature into file. But I don't know how to add textfield that allows signer to input their full name and drag it under their signature. Like the "Markup" feature on iOS. Any suggestion much appreciated. Thanks.
Replyhow anyone can perform undo() operation on canvas
Reply
ReplyGood Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
ionic training in chennai
Great Article
ReplyB.Tech Final Year Projects for CSE in Angularjs
Project Centers in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai
instagram takipçi satın al - instagram takipçi satın al - tiktok takipçi satın al - instagram takipçi satın al - instagram beğeni satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - instagram beğeni satın al - instagram beğeni satın al - polen filtresi - google haritalara yer ekleme - btcturk güvenilir mi - binance hesap açma - kuşadası kiralık villa - tiktok izlenme satın al - instagram takipçi satın al - sms onay - paribu sahibi - binance sahibi - btcturk sahibi - paribu ne zaman kuruldu - binance ne zaman kuruldu - btcturk ne zaman kuruldu - youtube izlenme satın al - torrent oyun - google haritalara yer ekleme - altyapısız internet - bedava internet - no deposit bonus forex - erkek spor ayakkabı - webturkey.net - minecraft premium hesap - karfiltre.com - tiktok jeton hilesi - tiktok beğeni satın al - microsoft word indir - misli indir
Replyyoutube abone satın al
Replytrendyol indirim kodu
cami avizesi
cami avizeleri
avize cami
no deposit bonus forex 2021
takipçi satın al
takipçi satın al
takipçi satın al
takipcialdim.com/tiktok-takipci-satin-al/
instagram beğeni satın al
instagram beğeni satın al
btcturk
tiktok izlenme satın al
sms onay
youtube izlenme satın al
no deposit bonus forex 2021
tiktok jeton hilesi
tiktok beğeni satın al
binance
takipçi satın al
uc satın al
sms onay
sms onay
tiktok takipçi satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
instagram beğeni satın al
tiktok beğeni satın al
twitter takipçi satın al
trend topic satın al
youtube abone satın al
takipcialdim.com/instagram-begeni-satin-al/
perde modelleri
instagram takipçi satın al
instagram takipçi satın al
takipçi satın al
instagram takipçi satın al
betboo
marsbahis
sultanbet
instagram takipçi satın al
Replyinstagram takipçi satın al
takipçi satın al
instagram takipçi satın al
takipçi satın al
aşk kitapları
tiktok takipçi satın al
instagram beğeni satın al
youtube abone satın al
twitter takipçi satın al
tiktok beğeni satın al
tiktok izlenme satın al
twitter takipçi satın al
tiktok takipçi satın al
youtube abone satın al
tiktok beğeni satın al
instagram beğeni satın al
trend topic satın al
trend topic satın al
youtube abone satın al
beğeni satın al
tiktok izlenme satın al
sms onay
youtube izlenme satın al
tiktok beğeni satın al
sms onay
sms onay
perde modelleri
instagram takipçi satın al
takipçi satın al
tiktok jeton hilesi
pubg uc satın al
sultanbet
marsbahis
betboo
betboo
betboo
takipçi satın al
Replyinstagram takipçi satın al
https://www.takipcikenti.com
marsbahis
Replybetboo
sultanbet
marsbahis
betboo
sultanbet
Thank you for the blog. It is very informative.
ReplyJava Training Institute in Chennai
Learn Java Online
Java Training Institutes in Bangalore
Nice Post!!! gratitude for imparting this post to us.
ReplyAndroid Training in Chennai
Android Course Online
Android Training in Bangalore
Gread post, keep sharing.
ReplyIBM Jobs
IBM Careers
Great post. keep sharing such a worthy information.
ReplyDOT NET Training in Chennai
Nice blog, Share more like this.
ReplyAWS Training In Chennai
AWS Online Training
AWS Training In Coimbatore
Nice Post!!! Thank you for sharing
ReplyPHP Training in Chennai
PHP Online Course
PHP Training in Bangalore