Signature"

From Documentation
 
(46 intermediate revisions by 7 users not shown)
Line 2: Line 2:
  
 
= Signature =
 
= Signature =
 +
{{versionSince| 8.6.0}}
 +
{{ZK EE}}
  
*Demonstration: [http://www.zkoss.org/zkdemo/input/signature Signature]
 
 
*Java API: <javadoc>org.zkoss.zkmax.zul.Signature</javadoc>
 
*Java API: <javadoc>org.zkoss.zkmax.zul.Signature</javadoc>
*JavaScript API: <javadoc directory="jsdoc">zkmax.inp.Slider</javadoc>
+
*JavaScript API: <javadoc directory="jsdoc">zkmax.wgt.Signature</javadoc>
*Style Guide: [[ZK_Style_Guide/XUL_Component_Specification/Signature | Signature]]
+
 
 +
= Browser Support =
 +
*This component supports IE10+ and modern browsers.
  
 
= Employment/Purpose =
 
= Employment/Purpose =
A Signature component represents a signature pad which can let user to take a signature on zk. It supports the desktop and touch-panel device. The Signature widget provides save, undo and clear API, you can save undo and clear the SignaturePad with this API. And Signature also provide a build-in tool bar to control the API.
+
Signature components support signature pad on the desktop and mobile browsers. User can customize pen size, pen color, background color etc., it also provides undo, save and clear methods.
  
 
= Example =
 
= Example =
[[Image:Signaturezkoss.jpg]]
+
[[File:Signature.png]]
  
 
<source lang="xml" >
 
<source lang="xml" >
  <signature id="s" height="100px" width="400px" style="border: 1px solid black;"'/>
+
<signature width="600px" height="300px" penColor="white" backgroundColor="#AED6F1" penSize="6"/>
 
</source>
 
</source>
  
= Undo Save Clear =
+
== Buttons ==
  [Since 8.6.0]
+
 
 +
There are 3 buttons when you hover on this component: (from left to right)
 +
 
 +
# '''undo''': to remove the last step that was drawn on the signature pad.
 +
# '''save''': to save the signature image to the server, a user can get the image by listening onSave event.
 +
# '''clear''': to clear signature pad.
 +
 
 +
= toolbarVisible =
  
There are some of APIs to control the Signature widget. Undo is removing the last step which was drawn on the signature pad. Save is saving the signature data to the server side as a base64 data type, user can get the image data by getImage() or getSignatureBase64(). Clear is to clear signature pad, and the signature pad would reset to empty.
+
The toolbar contains 3 buttons: undo button, clear button, and save button. They are visible by default. If you can hide them:
  
= Toolbar =
+
<source lang="xml">
 +
<signature toolbarVisible="false"/>
 +
</source>
  
The attribute of the tool bar is a boolean value, it controls the visibility of the tool bar, if the value is true, the user can use and see the tool bar, if not, they won't. And the user can customize css by using less, to reset the toolbar's position, size and some other features.
+
The toolbar buttons only contain icons by default. If you want to show message after icons on the buttons, we provide three attributes: <code>undoLabel</code>, <code>clearLabel</code>, and <code>saveLabel</code>.
  
= penSize penColor backgroundColor =
+
Default:
  [Since 8.6.0]
 
  There are some attributes to control the basic properties of the signature pad. The penSize is the pen size of the signature pad, the penColor is the pen color of the signature pad, and the backgroundColor is the backgroundColor of the signature pad.
 
  
= Knob Mold =
+
[[File:Signature toolbar.png]]
  [Since 8.6.0]
 
Set the mold property to "knob" will enable knob slider. So the slider can act as a normal knob. The knob can controlled by wheel, drag, click and enter a value to the input element.
 
  
[[File:knob360.png]]
+
Customized:
  
<source lang="xml" >
+
[[File:Signature toolbar2.png]]
  <slider mold="knob" mold="knob" minpos="0.0" maxpos="100.0" curpos="40.0" step="1"/>
+
<source lang="xml">
 +
<signature undoLabel="Undo" clearLabel="Clear" saveLabel="Save"/>
 
</source>
 
</source>
  
 +
= Style Attributes =
 +
 +
There are some attributes to adjust the signature style:
  
= AngelArc & strokeWidth=
+
== penSize==  
  [Since 8.6.0]
+
the width of a line on the signature, the default is 1.
AngelArc & strokeWidth are properties only for knob mold. Set the angelArc property with a double for the angle of the knob slider. Set the strokeWidth property with a double for the stroke width of the knob.
 
  
[[File:knob270.png]]
+
== penColor ==
 +
Can be any color format accepted by context.fillStyle(canvas), defaults to black.
  
<source lang="xml" >
+
== backgroundColor==  
  <slider mold="knob" mold="knob" minpos="0.0" maxpos="100.0" curpos="40.0" step="1" strokeWidth="20" angelArc="270"/>
+
Can be any color format accepted by context.fillStyle(canvas), defaults to white.
</source>
+
 
 +
== backgroundImage==  
 +
{{versionSince| 9.6.0}}
 +
Can be any image format accepted by context.drawImage(canvas), defaults to null.
  
=Supported Events=
+
= BackgroundIncluded =
 +
{{versionSince |9.6.0}}
  
{| border="1" | width="100%"
+
The background color and image will be saved by default.  If you don't want to save the background color and image, please use the following setting.
! <center>Name</center>
+
<source lang="xml">
! <center>Event Type</center>
+
<signature backgroundIncluded="false"/>
|-
+
</source>
| <center>onScroll</center>
 
| '''Event:''' <javadoc>org.zkoss.zk.ui.event.ScrollEvent</javadoc>
 
Denotes the content of a scrollable component has been scrolled by the user.  
 
|-
 
| <center>onScrolling</center>
 
| '''Event:''' <javadoc>org.zkoss.zk.ui.event.ScrollEvent</javadoc>
 
Denotes that the user is scrolling a scrollable component. Notice that the component's content (at the server) won't be changed until onScroll is received. Thus, you have to invoke the <tt>getPos</tt> method in the ScrollEvent class to retrieve the temporary position.
 
|}
 
*Inherited Supported Events: [[ZK_Component_Reference/Base_Components/XulElement#Supported_Events | XulElement]]
 
  
=Supported Molds=
+
== Scanned Paper Form==
Available molds of a component are defined in lang.xml embedded in zul.jar.
+
You can load a scanned paper form as a background and save it with a signature.
{| border="1" | width="100%"
+
[[File:Paper-form.jpg|center]]
! <center>Name</center>
 
! <center>Snapshot</center>
 
|-
 
| <center>default</center>
 
|[[Image:slider_mold_default.png ]]
 
|-
 
| <center>sphere</center>
 
|[[Image:slider_mold_sphere.png ]]
 
|-
 
| <center>scale</center>
 
|[[Image:slider_mold_scale.png ]]
 
|-
 
| <center>knob</center>
 
|[[Image:knob360.png ]][[Image:knob270.png ]]
 
|}
 
  
[Since 7.0.0]  [mold knob Since 8.6.0]
+
= Saves Signature Image =
  
the scale mold is deprecated because designs are changed.
+
After clicking "Save" button, the component will upload the signature to a server. You can listen <code>onSave</code> to get the uploaded signature and show it with [https://www.zkoss.org/wiki/ZK_Component_Reference/Essential_Components/Image Image]:
  
=Supported Children=
+
<source lang="xml">
 +
<signature onSave="image.setContent(event.getMedia())"/>
 +
<image id="image"/>
 +
</source>
  
*None
+
== File Size Limit ==
 +
If you see <code>SizeLimitExceededException</code>, you can adjust max uploading file size by
 +
[[ZK_Configuration_Reference/zk.xml/The_system-config_Element/The_max-upload-size_Element | file-size-threshold]].
  
=Use Cases=
+
=Supported Events=
  
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
! Version !! Description !! Example Location
+
! <center>Name</center>
 +
! <center>Event Type</center>
 
|-
 
|-
| &nbsp;
+
| <center>onSave</center>
| &nbsp;
+
| '''Event:''' <javadoc>org.zkoss.zk.ui.event.UploadEvent</javadoc>
| &nbsp;
+
When user invoke the save method, the event would be triggered.
 +
|-
 +
| <center>onClear</center>
 +
| '''Event:''' <javadoc>org.zkoss.zk.ui.event.Event</javadoc>
 +
When user invoke the clear method, the event would be triggered.
 
|}
 
|}
  
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-
| 5.0.4
+
| 8.6.0
| August 2010
+
| August 2018
| <javadoc method="setPageIncrement(int)">org.zkoss.zul.Slider</javadoc> is supported.
+
|
|-
 
| 5.0.4
 
| August 2010
 
| Slider support for clicking to increment or decrement
 
|-
 
| 7.0.1
 
| January 2014
 
| [http://tracker.zkoss.org/browse/ZK-2085 Slider support minimal position and decimal mode]
 
 
|}
 
|}
  
 
{{ZKComponentReferencePageFooter}}
 
{{ZKComponentReferencePageFooter}}

Latest revision as of 10:15, 19 September 2022

Signature

Since 8.6.0

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ee.png

Browser Support

  • This component supports IE10+ and modern browsers.

Employment/Purpose

Signature components support signature pad on the desktop and mobile browsers. User can customize pen size, pen color, background color etc., it also provides undo, save and clear methods.

Example

Signature.png

<signature width="600px" height="300px" penColor="white" backgroundColor="#AED6F1" penSize="6"/>

Buttons

There are 3 buttons when you hover on this component: (from left to right)

  1. undo: to remove the last step that was drawn on the signature pad.
  2. save: to save the signature image to the server, a user can get the image by listening onSave event.
  3. clear: to clear signature pad.

toolbarVisible

The toolbar contains 3 buttons: undo button, clear button, and save button. They are visible by default. If you can hide them:

<signature toolbarVisible="false"/>

The toolbar buttons only contain icons by default. If you want to show message after icons on the buttons, we provide three attributes: undoLabel, clearLabel, and saveLabel.

Default:

Signature toolbar.png

Customized:

Signature toolbar2.png

<signature undoLabel="Undo" clearLabel="Clear" saveLabel="Save"/>

Style Attributes

There are some attributes to adjust the signature style:

penSize

the width of a line on the signature, the default is 1.

penColor

Can be any color format accepted by context.fillStyle(canvas), defaults to black.

backgroundColor

Can be any color format accepted by context.fillStyle(canvas), defaults to white.

backgroundImage

Since 9.6.0 Can be any image format accepted by context.drawImage(canvas), defaults to null.

BackgroundIncluded

Since 9.6.0

The background color and image will be saved by default. If you don't want to save the background color and image, please use the following setting.

<signature backgroundIncluded="false"/>

Scanned Paper Form

You can load a scanned paper form as a background and save it with a signature.

Paper-form.jpg

Saves Signature Image

After clicking "Save" button, the component will upload the signature to a server. You can listen onSave to get the uploaded signature and show it with Image:

	<signature onSave="image.setContent(event.getMedia())"/>
	<image id="image"/>

File Size Limit

If you see SizeLimitExceededException, you can adjust max uploading file size by file-size-threshold.

Supported Events

Name
Event Type
onSave
Event: UploadEvent

When user invoke the save method, the event would be triggered.

onClear
Event: Event

When user invoke the clear method, the event would be triggered.

Version History

Last Update : 2022/09/19


Version Date Content
8.6.0 August 2018



Last Update : 2022/09/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.