Introduction
This package can
be used in .NET applications (windows or web) for creating RSS and EAN-UCC
composite barcodes. The supported symbologies are:
Sample application
The product include
a simple application which shows you how to generate barcodes, display
them , print them and save them to gif files. You can start the application
by means of the RSSExamples10.exe or RSSExamples11.exe.
The Form Controls
This section explains
how to use the classes in your windows application.
In order to create
a barcode you must create an instance of one of the following classes:
- J4L.RSS.BarCode:
use this class to create EAN8, EAN13, EAN128, UPCE or UPCA symbols.
Use the Symbology property to select the symbology to use.
- J4L.RSS.RSS14:
use this class to create RSS14, RSS stacked, RSS truncated or RSS stacked
omni-directional symbols. Use the RSSFormat property to select
the symbology to use.
- J4L.RSS.RSSLimited:
use this class to create RSS Limited symbols.
- J4L.RSS.RSSExpanded
: use this class to create RSS Expanded or Expanded Stacked symbols.
Use the RSSFormat property to select the stacked or non-stacked
format.
The following example
creates a EAN128 barcode and exports it to a gif file.
[C#]
using J4L.RSS;
.....
//create instance of the object
BarCode r=new BarCode();
//set barcode properties
r.Symbology=BarCode.EAN128;
r.Code="0193812345678901";
r.HumanReadableCode="(01)93812345678901";
// set size and
write to file
r.Size = new System.Drawing.Size(300, 300);
r.saveToFile("barcode.gif","GIF");
[VBNET]
Imports J4L.RSS;
.....
' define variable
Dim r as BarCode
'create instance of the object
r = new BarCode()
' set barcode properties
r.Symbology=BarCode.EAN128
r.Code="0193812345678901"
r.HumanReadableCode="(01)93812345678901"
' set size and write
to file
r.Size = new System.Drawing.Size(300, 300)
r.SaveToFile("barcode.gif","GIF")
If you want to create
a composite symbol you must set the value for the 2D component using the
SecondaryCode property. For example:
[C#]
RSS r=new RSS();
r.Code="0341234567890"; // Note: do not pass the 01 application
identifier to RSS or RSSLimited classes.
r.SecondaryCode="17010200"; // this forces the 2D component
to be created.
r.RSSFormat=RSS.FORMAT_STACKED;
r.Size = new System.Drawing.Size(300, 300);
r.saveToFile("barcode.gif","GIF");
Note that you should not pass the 01 application identifier nor the checksum
character in the Code property of the RSS or RSSLimited classes.
You must however include all application identifiers for EAN128 and RSS
Expanded symbols.
All linear symbols (except EAN128) can be associated with a CC-A or CC-B
2D component. The software will automatically select the correct component
depending on the amount of data you need to encode.
EAN128 can be painted
with a CC-A/B component or a CC-C component. In this case you must select
the desired symbology using the EAN128WithCCC property. If you
select CC-C you must also set the number of columns using CCCColumns
(the default value is 4):
[C#]
BarCode r=new BarCode();
r.Symbology=r.EAN128;
r.Code="0193812345678901";
r.HumanReadableCode="(01)93812345678901";
// create a composite barcode
r.EAN128WithCCC=true;
r.SecondaryCode="10ABCD123456#4103898765432108";
r.Size = new System.Drawing.Size(300, 300);
r.saveToFile("barcode.gif","GIF");
How to create a gif, png or jpg file.
You can export the
barcode to a gif,png or a jpeg file. In order to do this you must use
the following code:
[C#]
using J4L.RSS;
.....
//create instance of the object
BarCode r=new BarCode();
' set barcode properties
.....
// set size and
write to file
r.Size = new System.Drawing.Size(300, 300);
r.saveToFile("barcode.gif","GIF");
r.saveToFile("barcode.jpg","JPG");
r.saveToFile("barcode.png","PNG");
[VBNET]
Imports J4L.RSS;
.....
' define variable
Dim r as BarCode
'create instance of the object
r = new BarCode()
' set barcode properties
.....
' set size and write
to file
r.Size = new System.Drawing.Size(300, 300)
r.SaveToFile("barcode.gif","GIF")
r.SaveToFile("barcode.jpg","JPG")
r.SaveToFile("barcode.png","PNG")
How to create the
barcode in windows form
The classes are a
subclass of Control and can therefore be added to any panel
or form just like any other control. For example:
[C#]
// create a barcode
and add it to a panel in my form
BarCode bc=new BarCode();
myPanel.Controls.Add(this.bc);
How to create the
barcode in a external Graphics object
You can use the paint
method to paint the barcode on any Graphics context. For example, the
following code illustrates how you can paint a barcode in a Bitmap Graphics
context:
// create in memory
image
Bitmap inMemoryImage = new Bitmap( 200,200);
// get graphics object
Graphics g = Graphics.FromImage(inMemoryImage);
// paint barcode
barcode.Size= new Size(200,200);
barcode.paint(g);
List of methods
and properties:
J4L.RSS.BarCode subclass of Control
- BarColor: color of the bars.
- BarHeight: bar height in pixels. If 0 it will
be calculated using H.
- BarHeight2D: bar height of the 2D (composite)
component.
- BackColor:background color.
- CCCColumns: number of columns for the CC-C
symbol. Only
used if EAN128WithCCC is true.
- Code: text to be painted as linear barcode.
Use # for FNC1.
- EAN128WithCCC: if true the EAN128 will be linked
to a CCC barcode, otherwise to a CC-A or CC-B .
- FontColor: color of the human readable text.
- H: height of bars. This a multiplicator of
X. The default is 0.45.
- HumanReadableCode: human readable version
of the code This is the text displayed below the barcode.
- GuardBars: if true (default), guardbars in
EAN and UPC codes will be longer than data bars.
- LeftMargin: image's left margin .
- ProcessTilde: process ~ in code? You can use
the format ~ddd if you want to specify the ascii code of the
character to be encoded. For example ~065 will encode the character
A.
- SecondaryCode: value for the 2D (composite)
barcode . Use # for FNC1.
- SupSeparation: Separation between the barcode
and the supplement (as multiplier of X)
- SupHeight: height of the supplement. This is
a multiplicator of the height of the code. The default is 0.8 (80%).
- Supplement: supplement for EAN or UPC barcode
- Symbology: Symbology to be used, EAN13, EAN8,
UPCE, UPCA or EAN128 .
- TextFont: font of the human readable text.
- TopMargin: image's top margin
- UPCEANSupplement2: create 2 digit supplement
for EAN or UPC codes.
- UPCEANSupplement5: create 5 digit supplement
for EAN or UPC codes.
- UPCESytem: system to be used in UPCE. It can
be "0" or "1". The default is "1".
- X: size in pixels of modules (narrow bars or
spaces).
- paint(System.Drawing.Graphics):
Paints the barcode on the given Graphics.
- saveToFile(System.String,System.String):
Saves the current barcode to a graphics file (gif , png or jpeg). The
format can be "GIF", "PNG", "JPG" or "JPEG".
J4L.RSS.RSS14 subclass of BarCode
(all properties
and methods are inherited from BarCode)
- RSSformat: which format to use. Valid values
are RSS14.FORMAT_REGULAR (default) , RSS14.FORMAT_LIMITED, RSS14.FORMAT_TRUNCATED,
RSS14.FORMAT_EXPANDED, RSS14.FORMAT_STACKED, RSS14.FORMAT_EXPANDED_STACKED,
RSS14.FORMAT_STACKED_OMNIDIRECTIONAL.
- Symbology: will automatically be set to RSS14.
J4L.RSS.RSSLimited subclass of RSS14
(all properties
and methods are inherited from RSS14)
- Symbology: will automatically be set to RSSLIMITED.
J4L.RSS.RSSExpanded subclass
of RSSLimited
(all properties
and methods are inherited from RSSLimited)
- Symbology: will automatically be set to RSSEXPANDED.
- StackedRowWidth: number of segment pairs in
each row if using the stacked format. The default value is 2. Allowed
values are 1 to 10.
Web Control
The class J4L.RSS.RSSWeb
is a subclass of WebControl and can be used in your web applications to
create rss and ean-ucc composite barcodes.
This class is just
a wrapper for a RSSExpanded object. The properties of the WebControl are
the same as those for Barcode, RSS and RSSExpanded. Furthermore you can
use the getBarCode() method to get a reference to the underlying RSSExpanded
class.
The Web Control can
be used in 2 ways:
- Include the control
in a asp.net page so that it creates a barcode and the HTML code for
it. This approach will create a physical image file on your server.
In order to use this approach you must only add the rss11.dll ( or rss10.dll
if you use .NET 1.0) assembly to your favorite IDE and drop our components
on your form. The resulting code will look like this.
<%@ Page Language="C#"
%>
<%@ Register TagPrefix="n0" Namespace="J4L.RSS"
Assembly="RSS10" %>
<script runat="server">
// Insert page
code here
//
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<n0:RSSWeb id="RSSWeb1" runat="server" Code="1234567809670"
ImageRetainTime="30" UPCEANSupplement2="False"
getBarHeight="30" UPCEANSupplement5="False"
Symbology="2" SupplementTopMargin="0" BarHeight2D="4"
FontColor="Black" ImageFile="j4l10050.gif" getEANUPCPrintFlag="True"
TextFont="Arial, 8pt" LeftMargin="0" Width="287px"
TopMargin="30" sizeX="1" Height="162px"
UPCESytem="1" GuardBars="True" ProcessTilde="False"
CCCColumns="4" BarColor="Black" sizeH="0.45"
SupSeparation="10" EAN128WithCCC="False" SupHeight="0.8"></n0:RSSWeb>
<!-- Insert content here -->
</form>
</body>
</html>
The web control
can be configured with the following properties:
- ImageRetainTime:
(in minutes). Temporary barcode image files will be deleted after
this time.
- LocalImageDirectory:
directory where the barcode images will be created.
-ImageHTMLPrefix:
directory where the barcode images will be created, from the browser's
point of view.
- ImageFile:
name of the created image file.
- Use it in a aspx
page to create a image on the fly. Your html page should contain a tag
like this:
<img SRC=barcode.aspx
ALT=Barcode BORDER=0>
which defines
a image that must be read from barcode.aspx. The barcode.aspx page
must then generate the barcode image in the following way:
[C#]
<%@ Page language="c#"
AutoEventWireup="false" Trace="false" Debug="false"
%>
<%@Import Namespace="System.Drawing" %>
<%@Import Namespace="System.IO" %>
<%@Import Namespace="System.Drawing.Imaging" %>
<%@Import Namespace="J4L.RSS" %>
<%@ OutputCache Duration="100" VaryByParam="none"
%>
<%
// define variable
RSSWeb bc;
// create instance of the object
bc = new RSSWeb();
// set barcode
properties
bc.Code="123456789012";
bc.Symbology=RSS.EAN13;
// create in memory image
Bitmap inMemoryImage = new Bitmap( 200,200);
Graphics g = Graphics.FromImage(inMemoryImage);
// paint barcode
bc.getBarCode().Size= new Size(200,200);
bc.getBarCode().paint(g);
MemoryStream
tempStream = new MemoryStream();
// output image
to the memory stream in gif format
inMemoryImage.Save(tempStream,ImageFormat.Gif);
Response.ClearContent();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "image/gif";
Response.BinaryWrite(tempStream.ToArray());
Response.End();
%>
[VBNET]
<%@ Page
language="VB" AutoEventWireup="false" Trace="false"
Debug="false" %>
<%@Import Namespace="System.Drawing" %>
<%@Import Namespace="System.IO" %>
<%@Import Namespace="System.Drawing.Imaging" %>
<%@Import Namespace="J4L.RSS" %>
<%@ OutputCache Duration="100" VaryByParam="none"
%>
<%
' define variable
dim bc as RSSWeb = new RSSWeb()
' set barcode
properties
bc.Code="123456789012"
bc.Symbology=RSS.EAN13
' create in memory
image
dim inMemoryImage as Bitmap= new Bitmap( 200,200)
dim g as Graphics = Graphics.FromImage(inMemoryImage)
' paint barcode
bc.getBarCode().Size=new Size(200,200)
bc.getBarCode().paint(g)
dim tempStream
as MemoryStream = new MemoryStream()
' output image
to the memory stream in gif format
inMemoryImage.Save(tempStream,ImageFormat.Gif)
Response.ClearContent()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "image/gif"
Response.BinaryWrite(tempStream.ToArray())
Response.End()
%>
Important Note:
In order to property
print a barcode embeded in a HTML page you must use the <IMG> tag.
Note that you will need to use the attibutes height
and width in order to achieve the correct
size of the barcode on the printed page.
This is a simple
HTML page that contains a barcode:
<HTML>
<HEAD>
<TITLE>Servlet Example META http-equiv=Content-Type
content="text/html; charset=windows-1252">
</HEAD>
<BODY bgColor=#ffffff>
This is your Barcode:
<IMG height=100 width=100
src="barcode.aspx" >
</BODY>
</HTML>
|