Imager Meta Tag

PocketBrowser 3.x API

The Imager Meta Tag is an action tag which controls the imager functions and navigates to a URL or calls a JavaScript function in reponse to an HTTP image transfer executed by the tag.

Imager (META Tag) Syntax
<META HTTP-Equiv="imager" content="[parameter>
<META HTTP-Equiv="imager" content="ImagerEvent:url('jsFunction or url')">

<META HTTP-Equiv="imager" content="ImagerEnumEvent:url('jsFunction or url')">


Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.

Name Description
Default Value
Enabled enables the imager device and shows the viewer window N/A
Disabled disables the imager device and hides the viewer window N/A
Capture captures the current image and sends the file N/A
Enumerate Return a list of imagers available on the device using ImagerEnumEvent. This tag will be actioned immediately N/A
Copy methods template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript

Items listed in this section indicate parameters, or attributes which can be set.

Name Possible Values Description
Default Value
Enabled:[Value] enables referenced Imager. Imager IDs can be obtained via ImagerEnumEvent enables the referenced imager device and shows the viewer window N/A
Left:[Value] numeric Value (0-ScreenWidth) Sets the top left horizontal position of the viewer window in pixels 0
Top:[Value] Numeric values (0-ScreenHeight) Sets the top left vertical position of the viewer window in pixels 0
Width:[Value] Numeric values (0-ScreenWidth) Sets the width of the viewer window in pixels ScreenWidth
Height:[Value] Numeric values (0-ScreenHeight) Sets the height of the viewer window in pixels 0
Lamp:[Value] ON/OFF switches the lamp ON or OFF OFF
Aim:[Value] ON/OFF switches the imager's aim ON or OFF OFF
Username:[Value] http or ftp server user name username for the http or ftp server if required N/A
Password:[Value] http or ftp server password password for the http or ftp server if required N/A
Sound:[Value] wav file name specifies the wave file to play when capturing an image N/A
Destination:[Value] http,ftp or file path the path of the destination N/A
Copy parameters template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript

Modules return information back to their web pages via retrieval tags, for example the scanner has a retrieval tag called 'DecodeEvent' which is called whenever it decodes a barcode. To register to receive a retrieval tag call the module as follows:

<META HTTP-Equiv="[Module]" content="[RetrievalTag]:url('[URI]')">
So to register to retrieve the Scanner's DecodeEvent the following syntax would be used:
<META HTTP-Equiv="Scanner" content="DecodeEvent:url('Javascript:doScan('%6', '%s', %3, '%2');')">

Retrieval tags return information by replacing the text in place holders, defined as '%s' or '%<number>'. Each place holder represents 1 return value with '%s' being populated sequentially or '%<number>' providing direct acces to the desired value.

If the content for the Scanner's DecodeEvent is:

"url('Javascript:doScan('%6', '%s', %3, '%2');')"

The function would be called as follows:
"Javascript:doScan('Decode', '5449000053879', 0x35, 'SCN:EAN13');"


Imagerevent

ID Name Description
1 Response In response to an upload to an HTTP site, the reply from the web server will be returned.
Copy this return value template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript


imagerEnumevent

ID Name Description
1 ImagerArray Two dimensional array of imagers present on the device
Copy this return value template to clipboard: Copy META Tag template to clipboard META Tags Copy Javascript template to clipboard Javascript



The following example sets up the imager to capture an image and transfer it to an ftp site:

<meta http-equiv="Imager" content="width:100">
<meta http-equiv="Imager" content="height:100">
<meta http-equiv="Imager" content="left:120">
<meta http-equiv="Imager" content="Destination:software.zebra.com">
<meta http-equiv="Imager" content="username:pbtest">
<meta http-equiv="Imager" content="password:pb30">
<meta http-equiv="Imager" content="sound:\windows\alarm2.wav">
<meta http-equiv="Imager" content="aim:on">
<meta http-equiv="Imager" content="lamp:off">
<meta http-equiv="Imager" content="FTP">
<meta http-equiv="Imager" content="imagerevent:url('javascript:alert('%s');')">
<meta http-equiv="Imager" content="enabled">
<meta http-equiv="onkey0x0d" content="KeyEvent:url('javascript:doCapture(0);')">

<SCRIPT>
var objGeneric = new ActiveXObject("PocketBrowser.Generic");

function doCapture()
{
objGeneric.InvokeMETAFunction('imager', 'capture');
}
</SCRIPT>
Copy example to clipboard Copy example to clipboard

The following example sets up the imager to capture an image when the Javascript function 'doCapture' is called:


<meta HTTP-Equiv="Imager" Content="enabled;left:30;top:50;width:160;height:100;aim:off;lamp:off">
<meta HTTP-Equiv="Imager" Content="destination:url('http://ds-laptop/PHTest/Received/HTTP/Upload.aspx')">
<meta http-equiv="Imager" content="sound:\windows\alarm2.wav">
<meta http-equiv="Imager" content="imagerevent:url('javascript:alert('%s');')">

<script>
var objGeneric = new ActiveXObject("PocketBrowser.Generic");

function doCapture()
{
objGeneric.InvokeMETAFunction('imager', 'capture');
}
</script>

Copy example to clipboard Copy example to clipboard

The following ASP.NET example recieves a file from the imager and saves it in a new filename:

<%@ Import namespace="System.Web.UI.HtmlControls" %>
<%@ Import namespace="System.IO" %>
<script runat="server" language="C#">
//called when the file is submitted    
protected void Page_Load(object o, EventArgs e) 
{
//check we have submitted a file
if( spbImagerFile.PostedFile != null )
{
// Get a reference to PostedFile object
HttpPostedFile myFile = spbImagerFile.PostedFile;

// Get size of uploaded file
int nFileLen = myFile.ContentLength; 

// make sure the size of the file is > 0
if(nFileLen > 0 )
{
//Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];

// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);

// Create a name for the file to store
string strFilename = Path.GetFileName(myFile.FileName);

// Write data into a file
WriteToFile(Server.MapPath(strFilename), ref myData);

// Write a response back to sender
Response.Write("File Received");
}
}
}

// Writes file to current folder
private void WriteToFile(string strPath, ref byte[] Buffer)
{
// Create a file
FileStream newFile = new FileStream(strPath, FileMode.Create);

// Write data to the file
newFile.Write(Buffer, 0, Buffer.Length);

// Close file
newFile.Close();
}
</script>
<form name="spbImagerForm" method="post" action="upload.aspx" id="spbImagerForm" enctype="multipart/form-data">
<input id="spbImagerFile" type="file" runat="server" Visible="false">
</form>
Copy example to clipboard Copy example to clipboard

The following is a useful desktop html file for testing the example above:

<form name="spbImagerForm" method="post" action="upload.aspx" id="spbImagerForm" enctype="multipart/form-data">
<input name="spbImagerFile" id="spbImagerFile" type="file" />
<input type="submit" value="submit">
</form>
Copy example to clipboard Copy example to clipboard

The following example displays the available imagers on screen

<html>
<head>
<meta HTTP-Equiv="imager" Content="imagerEnumEvent:url('Javascript:Enumimagers(%s);')">
<meta HTTP-Equiv="quitbutton" Content="left:200;top:0;visibility:visible">
</head>

<body BGCOLOR="#FFFFEA" TEXT="#0000A0" LINK="#FF0000" VLINK="#808080" ALINK="#008040" onLoad="setImagerEnumTimer();">
<a HREF="./Index.html">Back</a><br>
<div ID="message"></div>
</body>
</html>
<SCRIPT LANGUAGE="JavaScript">
function Enumimagers(imagerArray)
{
//alert(imagerArray);
var imagerInfo = "Imagers On Device: " + imagerArray.length + "<BR>ID  --  Name<BR>" 
//alert(imagerInfo);
for (i=0; i < imagerArray.length; i++)
{
imagerInfo = imagerInfo + imagerArray[i][0] + ' -- ' + imagerArray[i][1] + '<BR>';    
}
message.innerHTML = imagerInfo;   
}
//  We can not call Scanner:Enumerate during page load on WM so give the page 3 seconds to finish loading
function setImagerEnumTimer()
{
//alert('setImagerEnumTimer');
message.innerHTML = "getting data...";
setTimeout("onImagerEnable()", 3000);
}
function onImagerEnable()
{

var Generic = new ActiveXObject("PocketBrowser.Generic");
Generic.InvokeMETAFunction('imager', 'Enumerate');
//alert('onImagerEnable');
}
</SCRIPT>
Copy example to clipboard Copy example to clipboard
ImagerArray attribute
The ImagerArray attribute returned from ImagerEnumevent retrieval tag will enumerate each imager present on the device in a 2D array, associating each Imager's device name with a user friendly name. The device ID can be passed as a parameter to "Imager" "Enabled:<deviceID>", the friendly name is a user readable description of the Imager, e.g: "IMG1", "Imager" "IMG2", "color Camera".

Scanning and Image Capture
Image capture tags cannot be used on the same page as scanner tags due to Hardware Limitations.

Creating a fully qualified URL
The protocol, port number, username (optional) and password (optional) are all derived from the URL string and should be specified in the following manner: [protocol]://[username]:[password@]Server[:Port]FileNameAndPath. FTP Example: ftp://admin:root@192.168.1.1:2500/Folder/file.txt. HTTP Example: http://admin:root@192.168.1.1:8080/Folder/upload.aspx


Supported Platforms Windows CE, Windows Mobile, Windows Mobile SE
Persistence The viewer is page specific but the settings are persistent.
Min. Requirements The device must have an Imager device or Color Camera. To use color Camera you must have installed Cab package to update Imaging driver available with latest version of EMDK.