Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active July 8, 2021 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/f801733f5eb53b0777dd38da9db8366a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/f801733f5eb53b0777dd38da9db8366a to your computer and use it in GitHub Desktop.
Aspose.BarCode for .NET

This Gist contains code snippets for sample code of Aspose.BarCode for .NET

Gists of Aspose.BarCode for .NET
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
public void Save(string fileName, ImageFormat fileFormat)
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an image object inheriting properties from the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
// Load image data from memory stream to the image object
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.MemoryBmp;
image1.ImageInfo.OpenType = Aspose.Pdf.Generator.ImageOpenType.Memory;
image1.ImageScale = 0.5F;
System.IO.BinaryReader reader = new System.IO.BinaryReader(ms);
ms.Position = 0;
image1.ImageInfo.MemoryData = reader.ReadBytes((int)ms.Length);
// Add image to the paragraphs collection of the section and Save the Pdf
sec1.Paragraphs.Add(image1);
pdf1.Save(dataDir +"MyBarCode_out.pdf");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate Excel class that represents an excel file
Workbook excel1 = new Workbook();
// Add the barcode image into the pictures collection of the first worksheet of the excel file in the form of a MemoryStream, ms with upper left row=5 and
// Upper left column=5 and Save the excel file
excel1.Worksheets[0].Pictures.Add(5, 5, ms);
excel1.Save(dataDir + "MyFile_out.xls");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// initialize the BarCodeReader and specify multiple symbology types using bitwise OR operator
BarCodeReader reader = new BarCodeReader(@"MultiBarCodes.bmp", BarCodeReadType.AllSupportedTypes);
<configuration>
<startup>
<requiredRuntime version="v1.0.3705" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
<dependentAssembly>
<assemblyIdentity name="Regcode" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.EnterpriseServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="CustomMarshalers" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Accessibility" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Configuration.Install" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.DirectoryServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ServiceProcess" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Messaging" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IEExecRemote" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IIEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ISymWrapper" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="mscorcfg" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Management" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Remoting" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Formatters.Soap" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mobile" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Vsa.Vb.CodeDOMProcessor" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft_VsaVb" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualBasic.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="cscompmgd" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.JScript" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualBasic" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualC" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate an instance of license and set the license file through its path
Aspose.BarCode.License license = new Aspose.BarCode.License();
license.SetLicense("Aspose.BarCode.lic");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate an instance of license and set the license through a stream
Aspose.BarCode.License license = new Aspose.BarCode.License();
license.SetLicense(myStream);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, "this is some test code text. \n Second line \n third line.");
// Set width and height
generator.Parameters.Barcode.XDimension.Millimeters = 0.6f;
generator.Parameters.Barcode.BarHeight.Millimeters = 1.2f;
// Save the Barcode image in JPEG format
generator.Save(dataDir + "2d-barcode_out.jpg", BarCodeImageFormat.Jpeg);
// Save the Barcode image in TIFF format
generator.Save(dataDir + "2d-barcode_out.tiff", BarCodeImageFormat.Tiff);
// Save the Barcode image in PNG format
generator.Save(dataDir + "2d-barcode_out.png", BarCodeImageFormat.Png);
// Save the Barcode image in BMP format
generator.Save(dataDir + "2d-barcode_out.bmp", BarCodeImageFormat.Bmp);
// Save the Barcode image in GIF format
generator.Save(dataDir + "2d-barcode_out.gif", BarCodeImageFormat.Gif);
// Save the Barcode image in TiffInCmyk format
generator.Save(dataDir + "2d-barcode_out.tiff", BarCodeImageFormat.TiffInCmyk);
// Save the Barcode image in EMF format
generator.Save(dataDir + "2d-barcode_out.emf", BarCodeImageFormat.Emf);
// Save the Barcode image in SVG format
generator.Save(dataDir + "2d-barcode_out.svg", BarCodeImageFormat.Svg);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarCodeBuilder class
// Set the barcode text
// Set the barcode symbology
using (Aspose.BarCode.BarCodeBuilder builder = new Aspose.BarCode.BarCodeBuilder("123456789012", Aspose.BarCode.Generation.EncodeTypes.EAN13))
{
// Generate Barcode image and store it in a Bitmap
using (System.Drawing.Bitmap barcode = builder.GenerateBarCodeImage())
{
// Load the logo/other image as Bitmap
using (System.Drawing.Bitmap picture = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(@"path_to_your_picture.png"))
{
// Create a new empty image with new Calculated height &amp; width
using (System.Drawing.Bitmap output = new System.Drawing.Bitmap(System.Math.Max(barcode.Width, picture.Width), barcode.Height + picture.Height))
{
// Get the Graphics object
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(output))
{
// Clear the canvas
g.Clear(System.Drawing.Color.White);
// Draw the primary image (barcode image) on the canvas
g.DrawImage(picture, new System.Drawing.PointF(0, 0));
// Draw the second image (logo image) on the canvas inside the barcode image
g.DrawImage(barcode, new System.Drawing.PointF(0, picture.Height));
}
output.Save("output.jpg");
}
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Aztec, "123456789");
generator.Save(dataDir + "CreateAztecbarcode_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarCodeBuilder class
// Set the barcode text
// Set the barcode symbology
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.EAN13, "123456789012"))
{
// Generate Barcode image and store it in a Bitmap
using (System.Drawing.Bitmap barcode = generator.GenerateBarCodeImage())
{
// Load the logo/other image as Bitmap
using (System.Drawing.Bitmap picture = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(@"path_to_your_picture.png"))
{
// Create a new empty image with new Calculated height &amp; width
using (System.Drawing.Bitmap output = new System.Drawing.Bitmap(System.Math.Max(barcode.Width, picture.Width), barcode.Height + picture.Height))
{
// Get the Graphics object9
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(output))
{
// Clear the canvas
g.Clear(System.Drawing.Color.White);
// Draw the primary image (barcode image) on the canvas
g.DrawImage(picture, new System.Drawing.PointF(0, 0));
// Draw the second image (logo image) on the canvas inside the barcode image
g.DrawImage(barcode, new System.Drawing.PointF(0, picture.Height));
}
output.Save(dataDir + "output.jpg");
}
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set the barcode text
// Set the barcode symbology
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.EAN13, "123456789012"))
{
// Generate Barcode image and store it in a Bitmap
using (System.Drawing.Bitmap barcode = generator.GenerateBarCodeImage())
{
// Load the logo/other image as Bitmap
using (System.Drawing.Bitmap picture = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(dataDir + "logo.png"))
{
// Create a new empty image with new Calculated height &amp; width
using (System.Drawing.Bitmap output = new System.Drawing.Bitmap(System.Math.Max(barcode.Width, picture.Width), barcode.Height + picture.Height))
{
// Get the Graphics object9
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(output))
{
// Clear the canvas
g.Clear(System.Drawing.Color.White);
// Draw the primary image (barcode image) on the canvas
g.DrawImage(picture, new System.Drawing.PointF(0, 0));
// Draw the second image (logo image) on the canvas inside the barcode image
g.DrawImage(barcode, new System.Drawing.PointF(0, picture.Height));
}
output.Save(dataDir + "output.jpg");
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "output.jpg");
}
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "ABCDEF123456");
// Set the DataMatrix encoding mode to C40
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.C40;
// Save the barcode image
generator.Save(dataDir + "dataMatrixC40.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarCodeBuilder class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "ABCDEF123456");
// Set the DataMatrix encoding mode to C40
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.C40;
// Save the barcode image
generator.Save("dataMatrixC40.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DataMatrix, "ABCDEF123456");
// Set the DataMatrix encoding mode to X12
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.EDIFACT;
// Save the barcode image
generator.Save(dataDir + "EDIFACTdataMatrix.png");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarCodeBuilder class
// Set codetext value and EncodeType
Aspose.BarCode.BarCodeBuilder buidler = new Aspose.BarCode.BarCodeBuilder("ABCDEF123456", Aspose.BarCode.Generation.EncodeTypes.DataMatrix);
// Set the DataMatrix encoding mode to C40
buidler.DataMatrixEncodeMode = Aspose.BarCode.DataMatrixEncodeMode.C40;
// Save the barcode image
buidler.Save("dataMatrixC40.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "This is the data to be encoded");
// Set Data Matrix EncodeMode
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.ASCII;
generator.Save(dataDir + "ManagePDF417Barcode_out.bmp", BarCodeImageFormat.Bmp);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarCodeBuilder class
// Set codetext value and EncodeType
Aspose.BarCode.BarCodeBuilder buidler = new Aspose.BarCode.BarCodeBuilder("abcdef123456", Aspose.BarCode.Generation.EncodeTypes.DataMatrix);
// Set the DataMatrix encoding mode to Text encodation scheme
buidler.DataMatrixEncodeMode = Aspose.BarCode.DataMatrixEncodeMode.Text;
// Save the barcode image
buidler.Save("dataMatrixText.png");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object
BarCodeBuilder barCodeBuilder = new BarCodeBuilder();
// Set Barcode Symbology
barCodeBuilder.SymbologyType = Symbology.DataMatrix;
// Set Data Matrix EncodeMode
barCodeBuilder.DataMatrixEncodeMode = Aspose.BarCode.DataMatrixEncodeMode.ASCII;
// Set CodeText for barcode
barCodeBuilder.CodeText = "This is the data to be encoded";
barCodeBuilder.Save(dataDir + "ManagePDF417Barcode_out.bmp", ImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create array for storing multiple barcodes
const int nSize = 4;
string[] lstCodeText = new[] { "code-1", "code-2", "code-3", "code-4" };
const int strFileId = 1;
// Instantiate barcode object and set CodeText & Barcode Symbology
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.MacroPdf417, "1234567890"))
{
for (int nCount = 1; nCount <= nSize; nCount++)
{
generator.CodeText = lstCodeText[nCount - 1];
// FileID should be same for all the generated bar codes
generator.Parameters.Barcode.Pdf417.Pdf417MacroFileID = strFileId;
// Assign segmentID in increasing order (1,2,3,....) and Set the segments count
generator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentID = nCount;
generator.Parameters.Barcode.Pdf417.Pdf417MacroSegmentsCount = nSize;
try
{
// Save the barcode (fileid_segmentid.png)
generator.Save(dataDir + strFileId + "_" + nCount + "_out.png", BarCodeImageFormat.Png);
Process.Start(dataDir + strFileId + "_" + nCount + "_out.png");
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + strFileId + "_" + nCount + "_out.png");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "123456789");
// Width of each module and Save the Barcode image
generator.Parameters.Barcode.XDimension.Millimeters = 0.6f;
generator.Save(dataDir + "Datamatrixbarcode_out.bmp", BarCodeImageFormat.Bmp);
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "Datamatrixbarcode_out.bmp");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "abcdef123456");
// Set the DataMatrix encoding mode to Text encodation scheme
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.Text;
// Save the barcode image
generator.Save("dataMatrixText.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "abcdef123456");
// Set the DataMatrix encoding mode to Text encodation scheme
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.Text;
// Save the barcode image
generator.Save(dataDir + "dataMatrixText.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create an instance of BarcodeGenerator class
// Set codetext value and EncodeType
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DataMatrix, "ABCDEF123456");
// Set the DataMatrix encoding mode to X12
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.ANSIX12;
// Save the barcode image
generator.Save(dataDir + "X12dataMatrix.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "öäüéà è");
// Set Data Matrix EncodeMode to Custom and CodeText Encoding Property
generator.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.Custom;
generator.Parameters.Barcode.DataMatrix.CodeTextEncoding = Encoding.UTF8;
generator.Save(dataDir + "CustomEncodingModeInDataMatrix_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
try
{
MemoryStream memoryStream = new MemoryStream();
// Instantiate barcode object, Set CodeText, Barcode Symbology and Text Encoding
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "Слово"))
{
generator.Parameters.Barcode.QR.CodeTextEncoding = Encoding.UTF8;
generator.Save(dataDir + "" + memoryStream + "_out.png", BarCodeImageFormat.Png);
}
string fileName = dataDir + "" + memoryStream + "_out.png";
using (BarCodeReader reader = new BarCodeReader(fileName, DecodeType.QR))
{
var detectEnc = reader.DetectEncoding;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine(result.CodeText); //"Слово"
}
}
catch (Exception)
{}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Initialize a BarcodeGenerator class object and Set CodeText & Symbology Type
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "12345TEXT");
// Set encoding mode, Auto for Micro QR, error correction level
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.Auto;
generator.Parameters.Barcode.QR.QrEncodeType = QREncodeType.Auto;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
// Get barcode image Bitmap and Save QR code
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "EncodeMicroQRCode_out.bmp", ImageFormat.Bmp);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Initialize a BarCodeBuilder class object
BarCodeBuilder builder = new BarCodeBuilder();
// Set its Symbology
builder.SymbologyType = Symbology.QR;
// Set encoding mode
builder.QREncodeMode = QREncodeMode.Auto;
// Set ForceQR (default) for standard QR
builder.QREncodeType = QREncodeType.ForceQR;
// Set code text
builder.CodeText = "12345TEXT";
// Set error correction level
builder.QRErrorLevel = QRErrorLevel.LevelL;
// Get barcode image Bitmap
Bitmap lBmp = builder.GenerateBarCodeImage();
// Save QR code
lBmp.Save(dataDir + "EncodeQA_out.bmp", ImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Initialize a BarcodeGenerator class object and Set CodeText & Symbology Type
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "12345TEXT");
// Set ForceQR (default) for standard QR and Code text
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.Auto;
generator.Parameters.Barcode.QR.QrEncodeType = QREncodeType.ForceQR;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
// Get barcode image Bitmap and Save QR code
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "EncodeQA_out.bmp", ImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// initialize a BarcodeGenerator class object and Set its CodeText & Symbology Type
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "12345TEXT");
// Set encoding mode, ForceQR (default) for standard QR, ECI encoding type, error correction level
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ECIEncoding;
generator.Parameters.Barcode.QR.QrEncodeType = QREncodeType.ForceQR;
generator.Parameters.Barcode.QR.QrECIEncoding = ECIEncodings.UTF8;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
// Get barcode image Bitmap & Save QR code
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "EncodeQRCodEInECIMode_out.bmp", ImageFormat.Bmp);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, "1234567890");
// Set Pdf417 Error correction level
generator.Parameters.Barcode.Pdf417.Pdf417ErrorLevel = Pdf417ErrorLevel.Level8;
generator.Save(dataDir + "ManagePDF417Barcode_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create codetext
QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder();
lTextBuilder.AddFNC1FirstPosition();
lTextBuilder.AddPlainCodetext("000%89%%0");
lTextBuilder.AddFNC1GroupSeparator();
lTextBuilder.AddPlainCodetext("12345<FNC1>");
// Generate codetext
string lCodetext = lTextBuilder.GetExtendedCodetext();
// Instantiate barcode object and Set Codetext & SymbologyType
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "1234567890");
// Set encoding mode, error correction level and display text
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ExtendedCodetext;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = "My Text";
// Get barcode image Bitmap and Save QR code
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "FNC1FirstPositionInExtendedMode_out.bmp", ImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create codetext
QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder();
lTextBuilder.AddFNC1SecondPosition("12");
lTextBuilder.AddPlainCodetext("TRUE3456");
// Generate codetext
string lCodetext = lTextBuilder.GetExtendedCodetext();
// Instantiate barcode object and Set its CodeText, encoding mode, error correction level, display text and Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, lCodetext);
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ExtendedCodetext;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = "My Text";
// Get barcode image Bitmap and Save QR code
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "FNC1SecondPositionInExtendedMode_out.bmp", ImageFormat.Bmp);
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128))
{
generator.Parameters.Resolution = 144;
generator.Parameters.RotationAngle = 90;
generator.Save(dataDir + "rotated_dpi144.png");
}
// if you don't have required size, you can use AutoSizeMode = None and set all generator parameters by yourself
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "Aspose.BarCode sample"))
{
generator.Parameters.Barcode.XDimension.Pixels = 3;
generator.Parameters.Barcode.Padding.Left.Pixels = 20;
generator.Parameters.Barcode.Padding.Right.Pixels = 20;
generator.Save(dataDir + "GenerateBarcodeWithoutRestrictedBarcodeSize_out.png");
}
//If you have restricted requirements of barcode size, then you can set AutoSizeMode = Nearest
//and required barcode size. Barcode generator will calculate all other parameters like
//xDimension, AspectRatio, etc to fit barcode into desired size.
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "Aspose.BarCode sample"))
{
generator.Parameters.AutoSizeMode = AutoSizeMode.Nearest;
generator.Parameters.ImageWidth.Pixels = 200;
generator.Parameters.ImageHeight.Pixels = 200;
generator.Save(dataDir + "GenerateBarcodeWithRestrictedBarcodeSize_out.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code16K))
{
generator.Parameters.AutoSizeMode = AutoSizeMode.Nearest;
generator.Parameters.ImageWidth.Pixels = 100;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
generator.Save(dataDir + "Code16K_Nearest.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "Aspose.BarCode sample"))
{
generator.Parameters.Barcode.XDimension.Pixels = 3;
generator.Parameters.Barcode.QR.AspectRatio = 1.5f;
//generator.RecalculateValues();
Console.WriteLine("Width = " + generator.Parameters.ImageWidth.Pixels);
Console.WriteLine("Height = " + generator.Parameters.ImageWidth.Pixels);
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.AustralianPosteParcel))
{
string codetext = generator.CodeText; //99712345678901234567890103456
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.EAN13))
{
string codetext = generator.CodeText; //590123412345
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR))
{
generator.Parameters.Barcode.QR.QrVersion = QRVersion.Version18;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelM;
generator.Save(dataDir + "qr_out.png");
}
string CODICE = "(90)0843110730<<<<452287005001T8";
string displayedText = "(90)0843" + Environment.NewLine +
"110730<<<<" + Environment.NewLine +
"452287" + Environment.NewLine +
"005001T8" + Environment.NewLine;
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.GS1DataMatrix))
{
generator.CodeText = CODICE;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Above;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = displayedText;
Bitmap barcode = generator.GenerateBarCodeImage();
barcode.Save(dataDir + "Display2DText.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DotCode))
{
generator.Parameters.Barcode.DotCode.DotCodeMask = 2;
Bitmap barcode = generator.GenerateBarCodeImage();
barcode.Save(dataDir + "DotCode.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix))
{
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
generator.Parameters.ImageWidth.Millimeters = 50;
generator.Parameters.ImageHeight.Inches = 1.3f;
Bitmap barcode = generator.GenerateBarCodeImage();
barcode.Save(dataDir + "DataMatrix.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.MaxiCode))
{
generator.Parameters.Barcode.MaxiCode.MaxiCodeEncodeMode = 5;
Bitmap barcode = generator.GenerateBarCodeImage();
barcode.Save(dataDir + "MaxiCode.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.UpcaGs1DatabarCoupon))
{
generator.Save(dataDir + "UpcaGs1DatabarCoupon.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.UpcaGs1Code128Coupon))
{
generator.CodeText = "514141100906(01)88898765432109";
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
generator.Parameters.ImageWidth.Pixels = 500;
generator.Parameters.ImageHeight.Pixels = 200;
generator.Save(dataDir + "UpcaGs1Code128Coupon_Interpolation_500x200.png");
}
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "Aspose.BarCode sample"))
{
generator.Parameters.AutoSizeMode = AutoSizeMode.Nearest;
generator.Parameters.ImageWidth.Millimeters = 20;
generator.Parameters.ImageHeight.Millimeters = 20;
generator.Save(dataDir + "for_display_out.png");
generator.Parameters.Resolution = 300;
generator.Save(dataDir + "for_printer_out.png");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
string codeText = "The quick brown fox jumps over the lazy dog\n" + "The quick brown fox jumps over the lazy dog\n"; ;
// Instantiate barcode object and set CodeText, Symbology , and CodeLocation
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DataMatrix, codeText);
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
generator.Save(dataDir + "HideBarcodeCodeText_out.png", BarCodeImageFormat.Png);
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, "this is some test code text. \n Second line \n third line.");
// Set width and height
generator.Parameters.Barcode.XDimension.Millimeters = 0.6f;
generator.Parameters.Barcode.BarHeight.Millimeters = 1.2f;
string xmlFile = dataDir + "barcode.xml";
generator.ExportToXml(xmlFile);
string xmlFile = dataDir + "barcode.xml";
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = BarcodeGenerator.ImportFromXml(xmlFile);
generator.Save(dataDir + "barcode_xml_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, "1234567890");
// Set Pdf417 Error correction level, Compaction Mode to Text and CodeText for barcode
generator.Parameters.Barcode.Pdf417.Pdf417ErrorLevel = Pdf417ErrorLevel.Level8;
generator.Parameters.Barcode.Pdf417.Pdf417CompactionMode = Pdf417CompactionMode.Text;
generator.CodeText = "1234567890";
generator.Save(dataDir + "ManagePDF417Barcode_out.bmp", BarCodeImageFormat.Bmp);
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "Datamatrixbarcode_out.bmp");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create codetext
QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder();
lTextBuilder.AddECICodetext(ECIEncodings.Win1251, "Will");
lTextBuilder.AddECICodetext(ECIEncodings.UTF8, "Right");
lTextBuilder.AddECICodetext(ECIEncodings.UTF16BE, "Power");
lTextBuilder.AddPlainCodetext(@"t\e\\st");
// Generate codetext
string lCodetext = lTextBuilder.GetExtendedCodetext();
// Initialize a BarcodeGenerator class object, Set CodeText, Symbology, Encoding mode, correction level and display text
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, lCodetext);
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ExtendedCodetext;
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelL;
generator.CodeText = lCodetext;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = "My Text";
Bitmap lBmp = generator.GenerateBarCodeImage();
lBmp.Save(dataDir + "MultiECIModeInExtendedMode_out.bmp", ImageFormat.Bmp);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object
BarCodeBuilder barCodeBuilder = new BarCodeBuilder();
// Set Barcode Symbology
barCodeBuilder.SymbologyType = Symbology.Pdf417;
// Set Pdf417 Compaction Mode to Text
barCodeBuilder.Pdf417CompactionMode = Pdf417CompactionMode.Text;
barCodeBuilder.Save(dataDir + "ManagePDF417Barcode_out.bmp", ImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
string codeText = "The quick brown fox jumps over the lazy dog\n" + "The quick brown fox jumps over the lazy dog\n";
// Instantiate barcode object, Set CodeText, Symbology and CodeLocation
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, codeText);
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
generator.Save(dataDir + "HideBarcodeCodeText_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create instance of BarcodeGenerator class, Set Aspect Ratio to 3:2 or 1.5 and Save the barcode image to disk in PNG format
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, "1234567890");
generator.Parameters.Barcode.Pdf417.AspectRatio = 1.5f;
generator.Save(dataDir + "SetAspectRatio_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// Set the error level
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelQ;
// Set the QR barcode version number
generator.Parameters.Barcode.QR.QrVersion = QRVersion.Version10;
//Save the image
generator.Save("qr_version10_errorQ.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// Set the error level
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelQ;
// Set the QR barcode version number
generator.Parameters.Barcode.QR.QrVersion = QRVersion.Version10;
//Save the image
generator.Save(dataDir + "Setting_QRVersion10_errorQ.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Instantiate barcode object and set Barcode CodeText & Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Aztec, "123456789");
// Set Error Error Correction level and Save the Barcode image
generator.Parameters.Barcode.Aztec.AztecErrorLevel = 10;
generator.Save(dataDir + "UseAztecErrorCorrection_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
string gtin = "898978777776665655";
string uid = "121212121212121212";
string batch = "GH768";
string expDate = "150923";
string textToEncode = gtin + uid + batch + expDate; // Or "(01)"+ gtin + "(..)"+ uid + ...
string textToDisplay = "GTIN:" + gtin + "\nUID:" + uid + "\nBatch:" + batch + "\nExp.Date:" + expDate;
// Instantiate barcode object and set N order to avoid including all the names into the codetext, the property called "Display2DText" should be used.
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "textToEncode");
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = textToDisplay;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below;
// Builder.CodeTextSpace = 0; // Not recommended small space
// Save the Barcode image
generator.Save(dataDir + "codetextRightDisplay_out.png" , BarCodeImageFormat.Png);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Create Pdf document and Add a section to the Pdf document
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes();
// Create a word document object with Aspose.Words
Document doc = new Document();
// Create builder for document object, Insert the barCode image into document and Save the word document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertImage(builder.BarCodeImage);
doc.Save(dataDir + "Myfile_out.doc");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarCodeBuilder builder = new BarCodeBuilder();
builder.CodeText = "1234567";
builder.SymbologyType = Symbology.Code128;
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Create dataset
DataSet ds = new DataSet("DataSet_BarCode");
// Insert datatable
DataTable ImageTable = new DataTable("DataTable_BarCode");
ImageTable.Columns.Add(new DataColumn("CodeText", typeof(string)));
ImageTable.Columns.Add(new DataColumn("BarCodeImage", typeof(System.Byte[])));
ds.Tables.Add(ImageTable);
// Write schema and display it
System.IO.MemoryStream ms = new System.IO.MemoryStream();
ds.WriteXmlSchema(ms);
this.TextBox1.Text = new string(System.Text.ASCIIEncoding.ASCII.GetChars(ms.GetBuffer()));
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
BarCodeReadType symbologyType = reader.GetReadType();
' For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
Dim strCodeText As String = reader.GetCodeText()
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
reader.Read();
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
private void Form1_Load(object sender, EventArgs e)
{
// This line of code loads data into the 'DataSet1.Product' table. You can move, or remove it, as needed.
this.ProductTableAdapter.Fill(this.DataSet1.Product);
// Create an instance of BarCodeBuilder class and Set the symbology type
BarCodeBuilder builder = new BarCodeBuilder();
builder.SymbologyType = Symbology.Code128;
// Loop through all the rows in the datatable
foreach (DataSet1.ProductRow row in DataSet1.Product.Rows)
{
// Set the codetext as value of "ProductNumber" column
builder.CodeText = row.ProductNumber.ToString();
// Generate the barcode and save it in memory stream
MemoryStream ms = new MemoryStream();
builder.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
// Set the value of "BarCode" column to the memory stream. This would show the barcode image
row.BarCode = ms.GetBuffer();
}
this.reportViewer1.RefreshReport();
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Create an instance of BarCodeBuilder
BarCodeBuilder builder = new BarCodeBuilder();
// Set the symbology type, codetext
builder.SymbologyType = Symbology.Code39Standard;
builder.CodeText = "test-123";
// Get the barcode image and Save the image at the specified location
Image img = builder.BarCodeImage;
img.Save(dataDir + txtBarCodeImage.Text, System.Drawing.Imaging.ImageFormat.Bmp);
using (Bitmap lBitmap = new Bitmap(dataDir + "Scan.jpg"))
{
using (BarCodeReader reader = new BarCodeReader())
{
reader.SetBarCodeImage(lBitmap, new Rectangle[] { new Rectangle(0, 0, lBitmap.Width, lBitmap.Height) });
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
}
using (Bitmap lBitmap = new Bitmap(dataDir + "Scan.jpg"))
{
using (BarCodeReader reader = new BarCodeReader())
{
reader.SetBarCodeImage(lBitmap, new Rectangle(0, 0, lBitmap.Width, lBitmap.Height));
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
}
using (FileStream lStream = new FileStream(dataDir + "Scan.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (BarCodeReader reader = new BarCodeReader())
{
reader.SetBarCodeImage(lStream);
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
}
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg", DecodeType.DataMatrix))
{
reader.QualitySettings.AllowInvertImage = true;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg"))
{
//set high quality mode with low speed recognition
reader.QualitySettings = QualitySettings.HighQuality;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg"))
{
//set high performance mode
reader.QualitySettings = QualitySettings.HighPerformance;
//set separate options
reader.QualitySettings.AllowMedianSmoothing = true;
reader.QualitySettings.MedianSmoothingWindowSize = 5;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg"))
{
//default mode is NormalQuality
//set separate options
reader.QualitySettings.AllowMedianSmoothing = true;
reader.QualitySettings.MedianSmoothingWindowSize = 5;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader class by passing barcode file name and barcode type as parameters
using (BarCodeReader reader = new BarCodeReader(dataDir + "datamatrix-stars.png", DecodeType.DataMatrix))
{
//set high performance mode
reader.QualitySettings = QualitySettings.HighPerformance;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType + ": " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader class by passing barcode file name and barcode type as parameters
using (BarCodeReader reader = new BarCodeReader(dataDir + "datamatrix-stars.png", DecodeType.DataMatrix))
{
//set high performance mode
reader.QualitySettings = QualitySettings.HighPerformance;
reader.QualitySettings.AllowDatamatrixIndustrialBarcodes = true;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType + ": " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
try
{
// Instantiate BarCodeReader object
using (BarCodeReader reader = new BarCodeReader(dataDir + "rotatedbarcode.jpg", DecodeType.Code128))
{
// Read Code128 bar code and Detect bar code orientation
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.Write(Environment.NewLine + "Rotaion Angle: " + result.Region.Angle);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
Console.WriteLine(Environment.NewLine + "Barcode recognized from " + dataDir + "rotatedbarcode.jpg");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
using (BarCodeReader reader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code39Standard))
{
//set max barcodes mode, which tries to find all possible barcodes, even incorrect.
//The slowest recognition mode
reader.QualitySettings = QualitySettings.MaxBarCodes;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("BarCode CodeText: " + result.CodeText);
Console.WriteLine("BarCode Type: " + result.CodeType);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Generate barcode (Sample 1) Initialize BarCode builder class object
using(BarcodeGenerator generator1 = new BarcodeGenerator (EncodeTypes.DataMatrix, "BASE-41 ONLY ALPHA, DIGITS AND PUNCTUATION"))
{
// Set ECC level
generator1.Parameters.Barcode.DataMatrix.DataMatrixEcc = DataMatrixEccType.Ecc050;
generator1.Save(dataDir + "SampleBarcode1_out.png");
}
// Generate barcode (Sample 2) Initialize BarCode builder class object and Set ECC level.
using(BarcodeGenerator generator2 = new BarcodeGenerator (EncodeTypes.DataMatrix, "BASE-41 ONLY ALPHA, DIGITS AND PUNCTUATION."))
{
generator2.Parameters.Barcode.DataMatrix.DataMatrixEcc = DataMatrixEccType.Ecc050;
generator2.Save(dataDir + "SampleBarcode2_out.png");
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader object and Call read method
BarCodeReader reader = new BarCodeReader(dataDir + "Barcode2.png", DecodeType.AllSupportedTypes);
// To get all possible barcodes
reader.QualitySettings = QualitySettings.MaxBarCodes;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Display code text, symbology, detected angle, recognition percentage of the barcode
Console.WriteLine("Code Text: " + result.CodeText + " Symbology: " + result.CodeType + " Recognition percentage: " + result.Region.Angle);
// Display x and y coordinates of barcode detected
Point[] point = result.Region.Points;
Console.WriteLine("Top left coordinates: X = " + point[0].X + ", Y = " + point[0].Y);
Console.WriteLine("Bottom left coordinates: X = " + point[1].X + ", Y = " + point[1].Y);
Console.WriteLine("Bottom right coordinates: X = " + point[2].X + ", Y = " + point[2].Y);
Console.WriteLine("Top right coordinates: X = " + point[3].X + ", Y = " + point[3].Y);
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader object and Call read method
using (BarCodeReader reader = new BarCodeReader(dataDir + "Barcode2.png", DecodeType.AllSupportedTypes))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeText + " Type: " + result.CodeType);
double percent = result.ReadingQuality;
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader object and Call read method
BarCodeReader reader = new BarCodeReader(dataDir + "Barcode2.png", DecodeType.AllSupportedTypes);
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeText + " Type: " + result.CodeType);
double percent = result.ReadingQuality;
}
reader.Close();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader class and read barcode file
using (BarCodeReader barCodeReader = new BarCodeReader(dataDir + "Region.png", DecodeType.Code39Standard))
{
// Try to recognize all possible barcodes in the image
foreach (BarCodeResult result in barCodeReader.ReadBarCodes())
{
// Get the region information
var region = result.Region;
if (region != null)
{
// Display x and y coordinates of barcode detected
Point[] point = region.Points;
Console.WriteLine("Top left coordinates: X = " + point[0].X + ", Y = " + point[0].Y);
Console.WriteLine("Top right coordinates: X = " + point[1].X + ", Y = " + point[1].Y);
Console.WriteLine("Bottom right coordinates: X = " + point[2].X + ", Y = " + point[2].Y);
Console.WriteLine("Bottom left coordinates: X = " + point[3].X + ", Y = " + point[3].Y);
}
Console.WriteLine("Codetext: " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader and set image and symbology type to recognize
using (BarCodeReader barCodeReader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code39Standard))
{
// Set grayscale image processing
barCodeReader.QualitySettings = QualitySettings.MaxBarCodes;
// Try to recognize all possible barcodes in the image and Display the codetext
foreach (BarCodeResult result in barCodeReader.ReadBarCodes())
{
Console.WriteLine("Codetext: " + result.CodeText);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
Stopwatch watch = new Stopwatch();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
using (BarCodeReader reader = new BarCodeReader(dataDir + "SymbologyTypebarcode.png", DecodeType.Code128))
{
// Start Stopwatch and Set RecognitionMode, ManualHints
watch.Start();
//reader.RecognitionMode = RecognitionMode.ManualHints;
reader.QualitySettings.AllowMedianSmoothing = true;
reader.QualitySettings.MedianSmoothingWindowSize = 5;
while (reader.Read())
{
Console.WriteLine(reader.GetCodeType() + ": " + reader.GetCodeText());
}
// End Stopwatch
watch.Stop();
Console.WriteLine("Time: " + watch.ElapsedMilliseconds + "ms.");
}
Stopwatch watch = new Stopwatch();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
using (BarCodeReader reader = new BarCodeReader(dataDir + "Code128.jpg", DecodeType.Code128))
{
// Start Stopwatch and Set RecognitionMode, ManualHints
watch.Start();
//reader.RecognitionMode = RecognitionMode.ManualHints;
reader.QualitySettings.AllowMedianSmoothing = true;
reader.QualitySettings.MedianSmoothingWindowSize = 5;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType + ": " + result.CodeText);
}
// End Stopwatch
watch.Stop();
Console.WriteLine("Time: " + watch.ElapsedMilliseconds + "ms.");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader and set image and symbology type to recognize
using (BarCodeReader barCodeReader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code39Standard))
{
int counter = 0;
// Read all the barcodes from the images
foreach (BarCodeResult result in barCodeReader.ReadBarCodes())
{
// Display the symbology type, codetext and Get the barcode region
Console.WriteLine("BarCode Type: " + result.CodeType);
Console.WriteLine("BarCode CodeText: " + result.CodeText);
BarCodeRegionParameters region = result.Region;
if (region != null)
{
// Initialize an object of type Image to get the Graphics object
Image image = Image.FromFile(dataDir + "code39.png");
// Initialize graphics object from the image
Graphics graphics = Graphics.FromImage(image);
// Draw the barcode edges, Save the image and Fill the barcode area with some color
//region.DrawBarCodeEdges(graphics, new Pen(Color.Red, 1f));
image.Save(dataDir + string.Format(@"edge_{0}.png", counter++));
//region.FillBarCodeRegion(graphics, Brushes.Green);
//image.Save(dataDir + string.Format(@"fill_{0}.png", counter++));
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
Stopwatch sw = new Stopwatch();
// Start the stopwatch
sw.Start();
// Define the settings to use all of the processor cores, if not then how many to use.
BarCodeReader.ProcessorSettings.UseAllCores = false;
BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = 4;
// Perform the BarCode recognition task Initialize the BarCodeReader object
using (BarCodeReader reader = new BarCodeReader(dataDir + "code39.png", DecodeType.Code128))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(" Code Text: " + result.CodeText + " Type: " + result.CodeType);
}
}
// Stop the stopwatch
sw.Stop();
// Write the Elapsed time to console
Console.WriteLine("Elapsed: " + sw.Elapsed);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader class and specify an area to look for the barcode
using (BarCodeReader reader = new BarCodeReader(new Bitmap(dataDir + "ReadBarcodefromSpecificRegionofImage.png"), new Rectangle(0, 0, 100, 50), DecodeType.Pdf417))
{
// Read all barcodes in the provided area
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Display the codetext and symbology type of the barcode found
Console.WriteLine("Codetext: " + result.CodeText + " Symbology: " + result.CodeType);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader class and specify an area to look for the barcode
BarCodeReader reader = new BarCodeReader(new Bitmap(dataDir + "ReadBarcodefromSpecificRegionofImage.png"), new Rectangle(0, 0, 100, 50), DecodeType.Pdf417);
// Read all barcodes in the provided area
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Display the codetext and symbology type of the barcode found
Console.WriteLine("Codetext: " + result.CodeText + " Symbology: " + result.CodeType);
}
// Close the reader
reader.Close();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the Bitmap object
Bitmap bitmap = new Bitmap(dataDir + "Region.png");
Rectangle[] areas = new Rectangle[3];
areas[0] = new Rectangle(50, 50, 300, 300);
areas[1] = new Rectangle(400, 40, 350, 350);
areas[2] = new Rectangle(40, 500, 700, 150);
// Initialize the BarCodeReader object and load bitmap object
using (BarCodeReader reader = new BarCodeReader(bitmap, areas, DecodeType.Code39Standard))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType + ": " + result.CodeText);
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
string strFileID = "1";
string[] strFileslist = Directory.GetFiles(dataDir + strFileID + "_*.png");
foreach (string strFile in strFileslist)
{
// We got list of all the files, now read barcodes
BarCodeReader reader = new BarCodeReader(strFile, DecodeType.MacroPdf417);
if (reader.Read() == true)
{
Console.WriteLine("File: " + strFile + " == FileID: " + reader.GetMacroPdf417FileID() + " == SegmentID: " + reader.GetMacroPdf417SegmentID() + " == CodeText: " + reader.GetCodeText());
}
// Close the reader
reader.Close();
}
try
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
string strFileID = "1";
string[] strFileslist = Directory.GetFiles(dataDir + strFileID + "_*.png");
foreach (string strFile in strFileslist)
{
// We got list of all the files, now read barcodes
using (BarCodeReader reader = new BarCodeReader(strFile, DecodeType.MacroPdf417))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("File: " + strFile
+ " == FileID: " + result.Extended.Pdf417.MacroPdf417FileID
+ " == SegmentID: " + result.Extended.Pdf417.MacroPdf417SegmentID
+ " == CodeText: " + result.CodeText);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
try
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create array for storing multiple bar codes file names
string[] files = new string[] { "Barcodefrom.png", "Barcode2.png" };
// Iiterate through the bar code image files
for (int i = 0; i < files.Length; ++i)
{
// Create instance of BarCodeReader class and set symbology
using (BarCodeReader reader = new BarCodeReader(dataDir + files[i], DecodeType.MacroPdf417))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Get code text, file id, segment id and segment count
Console.WriteLine("File Name: " + files[i] + " Code Text: " + result.CodeText);
Console.WriteLine("FileID: " + result.Extended.Pdf417.MacroPdf417FileID);
Console.WriteLine("SegmentID: " + result.Extended.Pdf417.MacroPdf417SegmentID);
Console.WriteLine("Segment Count: " + result.Extended.Pdf417.MacroPdf417SegmentsCount);
}
Console.WriteLine();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
try
{
BaseDecodeType[] objArray = new BaseDecodeType[] { DecodeType.Code39Standard, DecodeType.Pdf417 };
// Initialize the BarCodeReader, Call Read() method in a loop and Display the codetext and symbology type
using (BarCodeReader reader = new BarCodeReader("RecognizingMultipleSymbologies.png", objArray))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Codetext: " + result.CodeText);
Console.WriteLine("Symbology type: " + result.CodeType);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
try
{
// Create instance of BarCodeReader class
using (BarCodeReader reader = new BarCodeReader("Code128.jpg", DecodeType.Code128))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Display code text and Symbology Type
Console.WriteLine("CodeText: " + result.CodeText);
Console.Write("Symbology Type: " + result.CodeType);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from http://wwww.aspose.com/purchase/default.aspx.");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
try
{
// Read file from directory with DecodeType.EAN13
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg", DecodeType.EAN13))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Read symbology type and code text
Console.WriteLine("Symbology Type: " + result.CodeType);
Console.WriteLine("CodeText: " + result.CodeText);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from https://www.aspose.com/purchase/default.aspx.");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create an instance of BarCodeReader and set image and symbology type to recognize
using (BarCodeReader barCodeReader = new BarCodeReader(dataDir + "BarcodeOrientation.png", DecodeType.Code39Standard))
{
// Aspose.BarCode.BarCodeRecognition.RecognitionHints is obsolete: RecognitionHints is depricated
// Barcode orientation is detected automatically
// barCodeReader.OrientationHints = RecognitionHints.Orientation.Rotate90;
// Try to recognize all possible barcodes in the image and Display the codetext
foreach (BarCodeResult result in barCodeReader.ReadBarCodes())
{
Console.WriteLine("Codetext: " + result.CodeText);
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object
BarCodeBuilder barCodeBuilder = new BarCodeBuilder();
// Set border style to solid
barCodeBuilder.BorderDashStyle = Aspose.BarCode.BorderDashStyle.Solid;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader object and Set recognition mode
using (BarCodeReader reader = new BarCodeReader(@"file.tiff", DecodeType.Code128))
{
reader.QualitySettings.AllowOneDWipedBarsRestoration = true;
List<string> lCodetexts = new List<string>();
foreach (BarCodeResult result in reader.ReadBarCodes())
{
lCodetexts.Add(result.CodeText);
Console.WriteLine(result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Create instance of BarCodeReader class and Get code text
using (BarCodeReader reader = new BarCodeReader(dataDir + "Scan.jpg"))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("CodeText: " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageAndOptimizeBarcodeRecognition();
// Initialize the BarCodeReader object and Set recognition mode
using (BarCodeReader reader = new BarCodeReader(dataDir + "datamatrix-barcode.jpg", DecodeType.DataMatrix))
{
reader.QualitySettings = QualitySettings.HighPerformance;
reader.QualitySettings.AllowInvertImage = true;
reader.QualitySettings.AllowIncorrectBarcodes = true;
// Try to recognize all possible barcodes in the image and Display the codetext
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Codetext: " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set Increase the space between code text and barcode to 1 point
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code93Standard);
generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 1.0f;
generator.Save(dataDir + "AddSpaceInBarCodeAndText_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code39Standard, "1234567890");
generator.Parameters.AutoSizeMode = AutoSizeMode.Nearest;
generator.Parameters.ImageHeight.Millimeters = 50;
generator.Parameters.ImageWidth.Millimeters = 120;
generator.Save(dataDir + "barcode-custom-size_out.jpg");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set different properties
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code93Standard);
generator.Parameters.Border.DashStyle = BorderDashStyle.Solid;
generator.Parameters.Barcode.Padding.Top.Millimeters = 2f;
generator.Parameters.Barcode.Padding.Left.Millimeters = 2f;
generator.Parameters.Barcode.Padding.Right.Millimeters = 2f;
generator.Parameters.Barcode.Padding.Bottom.Millimeters = 2f;
generator.Parameters.Border.Width.Millimeters = 0.5f;
generator.Parameters.Border.Visible = true;
generator.Save(dataDir + "barcodeImageborders_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and different properties
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128))
{
generator.CodeText = "1234567890";
generator.Parameters.Barcode.Padding.Left.Millimeters = 0.5f;
generator.Parameters.Barcode.Padding.Right.Millimeters = 0f;
generator.Parameters.Barcode.Padding.Top.Millimeters = 0f;
generator.Parameters.Barcode.Padding.Bottom.Millimeters = 0f;
generator.Save(dataDir + "barcode-image-margins_out.jpeg", BarCodeImageFormat.Jpeg);
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and different properties
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128))
{
generator.CodeText = "1234567890";
generator.Parameters.Barcode.Padding.Left.Millimeters = 0.5f;
generator.Parameters.Barcode.Padding.Right.Millimeters = 0f;
generator.Parameters.Barcode.Padding.Top.Millimeters = 0f;
generator.Parameters.Barcode.Padding.Bottom.Millimeters = 0f;
generator.Save(dataDir + "barcode-image-paddings_out.jpeg", BarCodeImageFormat.Jpeg);
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText, Barcode Symbology and image quality mode to anti alias
BarCodeBuilder barCodeBuilder = new BarCodeBuilder("1234567", EncodeTypes.Code128)
{
ImageQuality = ImageQualityMode.AntiAlias
};
barCodeBuilder.Save(dataDir + "barcode-image-quality_out.jpeg", ImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.CodeText = "1234567";
generator.Parameters.Resolution = 400f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode-image-resolution_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
string dst = dataDir + "colorize-barcode_out.jpg";
// Instantiate barcode object and differnt properties
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128))
{
generator.Parameters.BackColor = Color.Yellow;
generator.Parameters.Barcode.BarColor = Color.Blue;
generator.Parameters.Border.Color = Color.Red;
generator.Parameters.Barcode.CodeTextParameters.Color = Color.Red;
generator.Save(dst, BarCodeImageFormat.Jpeg);
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417))
{
generator.CodeText = "TEXT";
generator.Parameters.Barcode.FilledBars = false;
generator.Save(dataDir + "ControlBarsFillingofOneDBarcodes_out.png");
};
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object and Enable border to be shown in the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code93Standard);
generator.Parameters.Border.Visible = true;
// Get the default Printer Name
PrinterSettings settings = new PrinterSettings();
string printerName = settings.PrinterName;
// Instantiate barcode object and set CodeText & Barcode Symbology
BarCodeBuilder barCodeBuilder = new BarCodeBuilder("1234567890", EncodeTypes.Code128);
// Set printer name
barCodeBuilder.PrinterName = printerName;
barCodeBuilder.Print();
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText, Barcode Symbology and hide code text
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR);
generator.CodeText = "1234567890";
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
generator.Parameters.RotationAngle = 90;
generator.Save(dataDir + "QR-rotate_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText, Barcode Symbology and RotationAngleF
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.CodeText = "1234567";
generator.Parameters.RotationAngle = 180;
generator.Save(dataDir + "barcode-image-rotate_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.CodeText = "1234567";
generator.Save(dataDir + "barcode-image-format_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
// Create a memory stream object that would store barcode image in binary form
MemoryStream mStream = new MemoryStream();
// Call save method of BarCodeImage to store Png barcode image to memory stream
generator.Save(mStream, BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set differnt Properties
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128))
{
generator.CodeText = "1234567";
generator.Parameters.Barcode.CodeTextParameters.Alignment = TextAlignment.Center;
generator.Save(dataDir + "barcode-SetCodeAlignment_out.jpg", BarCodeImageFormat.Jpeg);
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and Set Code text font's type and size
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.CodeText = "Text";
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "Verdana";
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 12f;
generator.Save(dataDir + "SetCodeTextFontFamilyNameAndSize_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object set codeText and location
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.CodeText = "1234567";
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Above;
generator.Save(dataDir + "barcode-SetCodetextLocation_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128);
generator.Parameters.CaptionAbove.Visible = true;
generator.Parameters.CaptionAbove.Text = "Aspose";
generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center;
generator.Parameters.CaptionAbove.TextColor = Color.Red;
generator.Parameters.CaptionAbove.Font.FamilyName = "Pristina";
generator.Parameters.CaptionAbove.Font.Size.Point = 14;
generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center;
generator.Parameters.CaptionBelow.Text = "Aspose.Demo";
generator.Parameters.CaptionBelow.Visible = true;
generator.Parameters.CaptionBelow.Font.FamilyName = "Pristina";
generator.Parameters.CaptionBelow.Font.Size.Point = 14;
generator.Parameters.CaptionBelow.TextColor = Color.OrangeRed;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "SetFontandColorSetting_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set differnt barcode properties
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
generator.Parameters.Barcode.CodeTextParameters.Color = Color.Red;
generator.Save(dataDir + "barcode-SetForeColorText_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.ITF14, "00850006000227");
// Set Different properties
generator.Parameters.AutoSizeMode = AutoSizeMode.Nearest;
generator.Parameters.Barcode.ITF.ItfBorderType = ITF14BorderType.FrameOut;
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "OCR B Std";
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 8;
generator.Parameters.Barcode.XDimension.Millimeters = 0.495f;
generator.Parameters.Barcode.BarHeight.Millimeters = 12.7f;
generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 0.5f;
generator.Save(dataDir + "ITF14_Border_Type_FrameOut_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.ITF14, "00850006000227");
// Set ITF14 Barcode Border Type
generator.Parameters.Barcode.ITF.ItfBorderType = ITF14BorderType.FrameOut;
// Set Font
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "OCR B Std";
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 8;
// Set xDimension
generator.Parameters.Barcode.XDimension.Millimeters = 0.495f;
// Set Bars Height
generator.Parameters.Barcode.BarHeight.Millimeters = 12.7f;
// Specify space between characters
generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 0.5f;
// Define resolution
generator.Parameters.Resolution = 1200.0f;
generator.Save(dataDir + "ITF14_Border_Type_Frame_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567"))
{
// Set the bar height to 3 points and measuring unit of barcode to point
generator.Parameters.Barcode.BarHeight.Point = 3.0f;
generator.Save(dataDir + "barcode-size-unit_out.jpeg", BarCodeImageFormat.Jpeg);
};
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object
BarCodeBuilder barCodeBuilder = new BarCodeBuilder();
// Set the Code text, symbology type, supplement data for the barcode
barCodeBuilder.CodeText = "123456789123";
barCodeBuilder.SymbologyType = Symbology.EAN13;
barCodeBuilder.SupplementData = "12345";
// Set space between the supplemental barcode and main barcode
barCodeBuilder.SupplementSpace = 2.0f;
barCodeBuilder.Save("SetSupplementData_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.ITF14, "00850006000227");
// Set ITF Barcode Border Type
generator.Parameters.Barcode.ITF.ItfBorderType = ITF14BorderType.FrameOut;
// Set ITF Barcode Border Thickness
generator.Parameters.Barcode.ITF.ItfBorderThickness.Point = 1;
// Set Font
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "OCR B Std";
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 8;
// Set xDimension
generator.Parameters.Barcode.XDimension.Millimeters = 0.495f;
// Set Bars Height
generator.Parameters.Barcode.BarHeight.Millimeters = 12.7f;
// Specify space between characters
generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 0.5f;
// Define resolution
generator.Parameters.Resolution = 1200.0f;
generator.Save(dataDir + "ITF14_Border_Thickness_Out.png", BarCodeImageFormat.Png);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create an instance of BarCodeReader class and load an existing oncecode barcode.
using (BarCodeReader r = new BarCodeReader(dataDir + "onecode.png", DecodeType.OneCode))
{
// Set the ChecksumValidation property to Off.
r.ChecksumValidation = ChecksumValidation.Off;
while (r.Read())
{
Console.WriteLine(r.GetCodeType() + ": " + r.GetCodeText());
Console.WriteLine("CheckSum: " + r.GetCheckSum());
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567");
generator.Parameters.CaptionAbove.Visible = false;
// Set caption above its text and text alignment & also make it visible
generator.Parameters.CaptionAbove.Visible = true;
generator.Parameters.CaptionAbove.Text = "Aspose";
generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center;
generator.Parameters.CaptionAbove.TextColor = Color.Red;
generator.Parameters.CaptionAbove.Font.FamilyName = "Pristina";
generator.Parameters.CaptionAbove.Font.Size.Point = 14;
//space between the barcode and the caption
//generator.Parameters.CaptionAbove.Space.Millimeters = 5;
// Assign caption object to be displayed above the barcode
generator.Parameters.CaptionBelow.Visible = true;
generator.Parameters.CaptionBelow.Text = "Aspose Caption below";
generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center;
generator.Parameters.CaptionBelow.TextColor = Color.OrangeRed;
generator.Parameters.CaptionBelow.Font.Size.Point = 14;
generator.Parameters.CaptionBelow.Font.FamilyName = "Pristina";
//space between the barcode and the caption
//generator.Parameters.CaptionBelow.Space.Millimeters = 5;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode-caption_out.jpg",BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
//Initialize reader object
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader("error5.jpg", Aspose.BarCode.BarCodeRecognition.DecodeType.EAN13))
{
while (reader.Read())
{
//Get code text by passing TRUE to get the Barcode along with checksum value
System.Console.WriteLine("{0}: {1}", reader.GetCodeType(), reader.GetCodeText(true));
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
//Initialize reader object
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader("error5.jpg", Aspose.BarCode.BarCodeRecognition.DecodeType.EAN13))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
//Get code text by passing TRUE to get the Barcode along with checksum value
Console.WriteLine("BarCode Type: " + result.CodeType);
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
}
//Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DatabarExpandedStacked);
//Set the Code text for the barcode
generator.CodeText = "(01)98898765432106(3202)012345(15)991231";
//Save the image
generator.Save("6segmets.png");
//Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DatabarExpandedStacked);
//Set the Code text for the barcode
generator.CodeText = "(01)98898765432106(3202)012345(15)991231";
//Save the image
generator.Save("6segmets.png");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object and Set border width
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code93Standard);
generator.Parameters.Border.Width.Millimeters = 0.5f;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code39Standard, "1234567"))
{
generator.Parameters.Barcode.IsChecksumEnabled = EnableChecksum.Yes;
generator.Save(dataDir + "code39-checeksum_out.png");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
//Generation
//Instantiate BarCodeGenerator object
BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Codabar);
//Set the Code text for the barcode
generator.CodeText = "1234567890";
//Set the EnableChecksum property to yes
generator.Checksum.Enable = EnableChecksum.Yes;
//Set the CodabarChecksumMode
generator.Codabar.ChecksumMode = Aspose.BarCode.CodabarChecksumMode.Mod10;
//Save the image on the system
generator.Save("Codabar_Mod10.png");
//Recognition
//Initialize reader object
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader("Codabar_Mod10.png", Aspose.BarCode.BarCodeRecognition.DecodeType.Codabar))
{
//Set ChecksumValidation property of the reader to On
reader.ChecksumValidation = Aspose.BarCode.BarCodeRecognition.ChecksumValidation.On;
while (reader.Read())
{
//Get code text
System.Console.WriteLine("{0}:{1}", reader.GetCodeType(), reader.GetCodeText());
//Get checksum value
System.Console.WriteLine("Checksum:" + reader.GetCheckSum());
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
//Generation
//Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Codabar);
//Set the Code text for the barcode
generator.CodeText = "1234567890";
//Set the EnableChecksum property to yes
generator.Parameters.Barcode.IsChecksumEnabled = EnableChecksum.Yes;
//Set the CodabarChecksumMode
generator.Parameters.Barcode.Codabar.CodabarChecksumMode = BarCode.CodabarChecksumMode.Mod10;
//Save the image on the system
generator.Save("Codabar_Mod10.png");
//Recognition
//Initialize reader object
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader("Codabar_Mod10.png", Aspose.BarCode.BarCodeRecognition.DecodeType.Codabar))
{
//Set ChecksumValidation property of the reader to On
reader.ChecksumValidation = Aspose.BarCode.BarCodeRecognition.ChecksumValidation.On;
foreach (BarCodeResult result in reader.ReadBarCodes())
{
//Get code text
Console.WriteLine("BarCode Type: " + result.CodeType);
Console.WriteLine("BarCode CodeText: " + result.CodeText);
//Get checksum value
System.Console.WriteLine("Checksum:" + result.Extended.OneD.CheckSum);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator , specify codetext and symbology in the constructor
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Codabar, "11112222333344"))
{
// Set the codabar start symbol to A and stop symbol to D
generator.Parameters.Barcode.Codabar.CodabarStartSymbol = CodabarSymbol.A;
generator.Parameters.Barcode.Codabar.CodabarStopSymbol = CodabarSymbol.D;
generator.Save(dataDir + "Coabar-start-stop-symbols_out.png");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
string dst = dataDir + "codetext-appearence_out.jpg";
// Set the symbology type to Code128
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567"))
{
// Set differnt barcode properties
generator.Parameters.Barcode.CodeTextParameters.Alignment = TextAlignment.Center;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Above;
generator.Parameters.Barcode.CodeTextParameters.Color = Color.Red;
generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 1.0f;
generator.Save(dst, BarCodeImageFormat.Jpeg);
};
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode and set code text, symbology type
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, "One thing 2 thing");
// Set the code text location, graphics unit and margins
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
generator.Parameters.Barcode.Padding.Bottom.Pixels = 0;
generator.Parameters.Barcode.Padding.Top.Pixels = 0;
generator.Parameters.Barcode.Padding.Left.Pixels = 0;
generator.Parameters.Barcode.Padding.Right.Pixels = 0;
// Get Bitmap with exact barcode only
Bitmap bmp = generator.GenerateBarCodeImage();
bmp.Save(dataDir + "CreateAndSetSizeForImageWithBarcode_out.Png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234");
generator.Save(dataDir + "Code128-customized_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.UpcaGs1Code128Coupon, "514141100906(8102)03");
generator.Save(dataDir + "UpcaGs1Code128Coupon_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "1234567890");
generator.Save(dataDir + "datamatrix-barcode_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode and set code text, symbology type
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "123456");
// Get bitmap with exact barcode only and Save image on local disk
Bitmap bmp = generator.GenerateBarCodeImage();
bmp.Save(dataDir + "CreateImageWithExactBarcodeOnly_out.png", ImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate BarcodeGenerator object Set the Code text & SymbologyType for the barcode
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, "1234567890");
generator.Save(dataDir + "pdf417-barcode_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
const string codetext = "被洪水困住的";
// Generate the barcode
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, codetext);
// Encode the code text and Set the display text
generator.Parameters.Barcode.Pdf417.CodeTextEncoding = Encoding.Unicode;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = codetext;
generator.Save(dataDir + "CreatePdf417BarcodeWithChineseCharacters_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
const string codetext = "AYŞE" + "\n" + "Ümit" + "\n" + "Ümit@estee.com" + "\n" + "Türkiye";
// Generate the barcode
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Pdf417, codetext);
// Encode the code text and Set the display text
generator.Parameters.Barcode.Pdf417.CodeTextEncoding = Encoding.Unicode;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = codetext;
generator.Save(dataDir + "CreatePdf417BarcodeWithTurkishCharacters_out.png");
// Create an instance of BarcodeGenerator class
// Set barcode text
// Set encoding type
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.AustraliaPost, "12345678"))
{
// Set barcode Dimension and height
generator.Parameters.Barcode.XDimension.Pixels = 1f;
generator.Parameters.Barcode.BarHeight.Millimeters = 40;
// Save the barcode image
generator.Save("postnet.png");
}
// Create an instance of BarCodeGenerator class
// Set barcode text
// Set encoding type
using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.AustraliaPost, "12345678"))
{
// Set barcode Dimension and height
generator.XDimension.Pixels = 1f;
generator.BarHeight.Millimeters = 40;
// Save the barcode image
generator.Save("postnet.png");
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "1234567890");
generator.Save(dataDir + "CreateQRbarcode_out.bmp", BarCodeImageFormat.Bmp);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1DatabarCoupon, "512345678900(8110)001234502239811110555");
generator.Parameters.CaptionAbove.Text = "012345-022398";
generator.Save(dataDir + "couponUpcaDatabar_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set Always show checksum on image
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code39Standard, "0123456789"))
{
generator.Parameters.Barcode.ChecksumAlwaysShow = true;
generator.Save(dataDir + "DisplayChecksumCharacter_out.png");
};
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object and Enable border to be shown in the barcode
BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code93Standard);
generator.Border.Visible = true;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Initialize the BarcodeGenerator class by passing barcode text and barcode symbology as parameters.
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DataMatrix, "abcdefghijklmnopqrstuvwxyzabcdef");
// Set various different properties/variables of the barcode.
generator.Parameters.Border.Visible = true;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Above;
//generator.D2.Columns = 4;
//generator.D2.Rows = 3;
// Specify caption Above settings.
generator.Parameters.CaptionAbove.Text = "Caption ABOVE";
generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center;
generator.Parameters.CaptionAbove.Visible = true;
generator.Parameters.CaptionAbove.TextColor = Color.Green;
// Specify caption Below settings.
generator.Parameters.CaptionBelow.Text = "Caption BELOW";
generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center;
generator.Parameters.CaptionBelow.Visible = true;
generator.Parameters.CaptionBelow.TextColor = Color.Yellow;
// Specify text font settings.
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "Courier New";
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 24;
generator.Parameters.Barcode.CodeTextParameters.Font.Style = FontStyle.Bold;
// Call the export to XML method to export the properties to XML file.
generator.Save(dataDir + "BarcodeGenerator .DataMatrix_out.xml");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode
Bitmap imgBarcode = null;
BarcodeGenerator barCodeGenerator = new BarcodeGenerator (EncodeTypes.MacroPdf417);
// Set the codetext by converting it into unicode byte array
barCodeGenerator.CodeText = "منحة";
barCodeGenerator.Parameters.Barcode.Pdf417.CodeTextEncoding = Encoding.Unicode;
imgBarcode = barCodeGenerator.GenerateBarCodeImage();
imgBarcode.Save(dataDir + "GenerateAndRecognizeUTF8Characters_out.png");
// Recognize the above barcode
using (BarCodeReader reader = new BarCodeReader(dataDir + "GenerateAndRecognizeUTF8Characters_out.png"))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Encoding unicode = Encoding.Unicode;
// Get the characters array from the bytes
char[] unicodeChars = new char[unicode.GetCharCount(result.CodeBytes, 0, result.CodeBytes.Length)];
unicode.GetChars(result.CodeBytes, 0, result.CodeBytes.Length, unicodeChars, 0);
// Build unicode string
string strCodeText = new string(unicodeChars);
Console.WriteLine(strCodeText);
}
}
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.PatchCode, "Patch T");
generator.Save(dataDir + "patch.bmp");
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.PatchCode, "Patch T");
generator.Parameters.ImageWidth.Millimeters = 150; // in millimeters
generator.Parameters.Barcode.Padding.Top.Pixels = 0.5f; // make the same small margins
generator.Parameters.Barcode.Padding.Right.Pixels = 0.5f;
generator.Parameters.Barcode.Padding.Left.Pixels = 0.5f;
generator.Parameters.Barcode.Padding.Bottom.Pixels = 0.5f;
// to hide codetext
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
Image topImg = generator.GenerateBarCodeImage();
generator.Parameters.RotationAngle = 90;
Image leftImg = generator.GenerateBarCodeImage();
generator.Parameters.RotationAngle = 90;
Image bottomImg = generator.GenerateBarCodeImage();
generator.Parameters.RotationAngle = 90;
Image rigthtImg = generator.GenerateBarCodeImage();
Bitmap frameImg = new Bitmap(topImg.Width, rigthtImg.Height + 2 * topImg.Height);
// Initialize graphics object from the image
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(frameImg))
{
graphics.DrawImage(topImg, 0, 0);
graphics.DrawImage(leftImg, 0, topImg.Height);
graphics.DrawImage(bottomImg, 0, topImg.Height + leftImg.Height);
graphics.DrawImage(rigthtImg, topImg.Width - rigthtImg.Width, topImg.Height);
}
// save Patch code frame
frameImg.Save(dataDir + "output.jpg");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Set codetext
string codeText = "1159628792";
// Initialize BarCodeGenerator
BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.AustraliaPost, codeText);
// Set format control code to standard
generator.Save(dataDir + "AustraliaPost-Standard_out.png");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Initialize BarCode builder class object and set symbology type as Aztec and set the barcode text
BarCodeBuilder builder = new BarCodeBuilder("25", Symbology.Aztec);
// Save barcode
builder.Save(dataDir + "Aztec_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator class.
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.CodablockF, "CODABLOCKF 01234567890123456789012digits");
// Save the image to disk in PNG format
generator.Save("CodablockF_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator class.
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.GS1Code128, "(8012)ABC123");
// Save the image to disk in PNG format
generator.Save("AI8012_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator class.
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.GS1CodablockF, "(01)03412345678900(17)010200");
// Save the image to disk in PNG format
generator.Save("GS1CodablockF_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
Console.WriteLine("Assembly version: " + BuildVersionInfo.AssemblyVersion);
Console.WriteLine("File Version: " + BuildVersionInfo.FileVersion);
Console.WriteLine("Product: " + BuildVersionInfo.Product);
Console.WriteLine("Product Major: " + BuildVersionInfo.ProductMajor);
Console.WriteLine("Product Minor: " + BuildVersionInfo.ProductMinor);
Console.WriteLine("Release Date: " + BuildVersionInfo.ReleaseDate);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Create an instance of BarcodeGenerator class
// Set barcode text
// Set encoding type
using (BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567890"))
{
// Set Auto size to None
generator.Parameters.AutoSizeMode = AutoSizeMode.None;
// Set image height & width to minimum
generator.Parameters.ImageWidth.Millimeters = 1;
generator.Parameters.ImageHeight.Millimeters = 1;
// Save the barcode image
generator.Save(dataDir + "barcode-image-minimum_out.jpeg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodesImages();
// Create an instance of BarCodeGenerator class
// Set barcode text
// Set encoding type
using (BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code128, "1234567890"))
{
// Set Auto size to None
generator.AutoSizeMode = AutoSizeMode.None;
// Set image height & width to minimum
generator.BarCodeWidth.Millimeters = 1;
generator.BarCodeHeight.Millimeters = 1;
// Save the barcode image
generator.Save(dataDir + "barcode-image-minimum_out.jpeg", BarCodeImageFormat.Jpeg);
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create an instance of BarCodeReader class
// Set file path
// Set the recognition type
using (BarCodeReader reader = new BarCodeReader(dataDir + "1bc.png", DecodeType.Code128))
{
// Perform read operation
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Create an array of Code128DataPortion class
// Call the GetCode128DataPortions method
Code128DataPortion[] code128DataPortions = result.Extended.Code128.Code128DataPortions;
// Execute Loop for each Code128DataPortion instance
foreach (Code128DataPortion code128DataPortion in code128DataPortions)
{
// Display the subtype and data
System.Console.WriteLine("Code128SubType {0}", code128DataPortion.Code128SubType);
System.Console.WriteLine("Data {0}", code128DataPortion.Data);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create an instance of BarCodeReader class
// Set file path
// Set the recognition type
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader("1bc.png", Aspose.BarCode.BarCodeRecognition.DecodeType.Code128))
{
// Perform read operation
if (reader.Read())
{
// Create an array of Code128DataPortion class
// Call the GetCode128DataPortions method
Aspose.BarCode.BarCodeRecognition.Code128DataPortion[] code128DataPortions = reader.GetCode128DataPortions();
// Execute Loop for each Code128DataPortion instance
foreach (Aspose.BarCode.BarCodeRecognition.Code128DataPortion code128DataPortion in code128DataPortions)
{
// Display the subtype and data
System.Console.WriteLine("Code128SubType {0}", code128DataPortion.Code128SubType);
System.Console.WriteLine("Data {0}", code128DataPortion.Data);
}
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
// Set caption above its text and text alignment & also make it visible
generator.Parameters.CaptionAbove.Visible = true;
generator.Parameters.CaptionAbove.Text = "Aspose";
generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center;
generator.Parameters.CaptionAbove.TextColor = Color.Red;
generator.Parameters.CaptionAbove.Font.FamilyName = "Pristina";
generator.Parameters.CaptionAbove.Font.Size.Point = 14;
//space between the barcode and the caption
//generator.Parameters.CaptionAbove.Space.Millimeters = 5;
// Assign caption object to be displayed above the barcode
generator.Parameters.CaptionBelow.Visible = true;
generator.Parameters.CaptionBelow.Text = "Aspose Caption below";
generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center;
generator.Parameters.CaptionBelow.TextColor = Color.OrangeRed;
generator.Parameters.CaptionBelow.Font.Size.Point = 14;
generator.Parameters.CaptionBelow.Font.FamilyName = "Pristina";
//space between the barcode and the caption
//generator.CaptionBelow.Space.Millimeters = 5;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "ManageCaption_out.jpg", BarCodeImageFormat.Jpeg);
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
string dstCode128 = dataDir + "code128-YDimensionChanged_out.jpg";
// Instantiate barcode object and set CodeText & Barcode Symbology
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
// Save the image to your system and set its image format to Jpeg
generator.Save(dstCode128, BarCodeImageFormat.Jpeg);
// Set the X-Dimension for the bars of the barcode
generator.Parameters.Barcode.XDimension.Millimeters = 0.5f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dstCode128, BarCodeImageFormat.Jpeg);
// Instantiate barcode object and set differnt barcode properties
using (BarcodeGenerator generator1 = new BarcodeGenerator (EncodeTypes.Pdf417, "1234567"))
{
generator1.Parameters.ImageHeight.Millimeters = 4;
// Save the image to your system and set its image format to Jpeg
generator1.Save(dataDir + "pdf417-YDimensionChanged_out.jpg", BarCodeImageFormat.Jpeg);
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object and Set border margins by assigning an instance of MarginsF
BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.Code93Standard);
generator.Margins.Top.Millimeters = 2f;
generator.Margins.Left.Millimeters = 2f;
generator.Margins.Right.Millimeters = 2f;
generator.Margins.Bottom.Millimeters = 2f;
// Instantiate BarcodeGenerator object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.EAN13, "348503498549085409");
try
{
// Error message will not been thrown in case of false, default value is also false and Get barcode image
generator.Parameters.Barcode.ThrowExceptionWhenCodeTextIncorrect = true;
Bitmap bitmap = generator.GenerateBarCodeImage();
}
catch (Exception ex)
{
Console.WriteLine("Exception must be thrown, {0}", ex.Message);
}
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
List<FoundBarCodes> found = new List<FoundBarCodes>();
using (BarCodeReader reader = new BarCodeReader(dataDir + "tiffImage.tif", DecodeType.Code128))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
found.Add(new FoundBarCodes(result.CodeText, result.Region));
}
found.Sort(new FoundComparator());
int i = 1;
foreach (FoundBarCodes barcode in found)
{
Console.WriteLine("Codetext ( " + i + " ): " + barcode.CodeText);
Console.WriteLine("Top left coordinates: X = " + barcode.region.Points[0].X + ", Y = " + barcode.region.Points[0].Y);
Console.WriteLine("Bottom left coordinates: X = " + barcode.region.Points[1].X + ", Y = " + barcode.region.Points[1].Y);
Console.WriteLine("Bottom right coordinates: X = " + barcode.region.Points[2].X + ", Y = " + barcode.region.Points[2].Y);
Console.WriteLine("Top right coordinates: X = " + barcode.region.Points[3].X + ", Y = " + barcode.region.Points[3].Y);
Console.WriteLine();
i++;
}
}
public struct FoundBarCodes
{
public readonly string CodeText;
public readonly BarCodeRegionParameters region;
public FoundBarCodes(string text, BarCodeRegionParameters reg)
{
CodeText = text;
region = reg;
}
}
public class FoundComparator : IComparer<FoundBarCodes>
{
public int Compare(FoundBarCodes found1, FoundBarCodes found2)
{
Point[] found1Points = found1.region.Points;
Point[] found2Points = found2.region.Points;
Point found1XyMin = new Point(int.MaxValue, int.MaxValue);
Point found2XyMin = new Point(int.MaxValue, int.MaxValue);
foreach (Point p in found1Points)
if (p.X < found1XyMin.X && p.Y < found1XyMin.Y)
{
found1XyMin.X = p.X;
found1XyMin.Y = p.Y;
}
foreach (Point p in found2Points)
if (p.X < found2XyMin.X && p.Y < found2XyMin.Y)
{
found2XyMin.X = p.X;
found2XyMin.Y = p.Y;
}
if (found1XyMin.X < found2XyMin.X && found1XyMin.Y < found2XyMin.Y)
return -1;
if (found1XyMin.X > found2XyMin.X && found1XyMin.Y > found2XyMin.Y)
return 1;
if (found1XyMin.Y < found2XyMin.Y)
return -1;
if (found1XyMin.Y > found2XyMin.Y)
return 1;
return 0;
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
var img = Image.FromFile(dataDir + "tiffImage.tif");
int totalFrame = img.GetFrameCount(FrameDimension.Page);
// Feed the pages to BarCodeReader one by one
for (int i = 0; i < totalFrame; i++)
{
// Set the active page and feed it to the BarCodeReader
var w = img.SelectActiveFrame(FrameDimension.Page, i);
var bitmap = new Bitmap(img);
BarCodeReader reader = new BarCodeReader(bitmap, DecodeType.AllSupportedTypes);
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeText + " " + result.CodeType);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
using (BarCodeReader reader = new BarCodeReader(dataDir + "test.png", DecodeType.MostCommonTypes))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType.ToString() + " " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
using (BarCodeReader reader = new BarCodeReader(dataDir + "test.png", DecodeType.PostalTypes))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType.ToString() + " " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
using (BarCodeReader reader = new BarCodeReader(dataDir + "test.png", DecodeType.Types1D))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine(result.CodeType.ToString() + " " + result.CodeText);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Load barcode image and Read barcode
using (BarCodeReader reader = new BarCodeReader(dataDir + "Chinese.png", DecodeType.Pdf417))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
var t = result.CodeBytes;
var encodingValue = Encoding.GetEncoding(1254).GetString(t);
}
}
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Load barcode image and Read barcode
using (BarCodeReader reader = new BarCodeReader(dataDir + "Turkish.png", DecodeType.Pdf417))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
var t = result.CodeBytes;
var encodingValue = Encoding.GetEncoding(1254).GetString(t);
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create an instance of BarCodeGenerator class.
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Aztec, "25");
// Set AztecSymbolMode property.
generator.Parameters.Barcode.Aztec.AztecSymbolMode = AztecSymbolMode.Rune;
generator.Save(dataDir + "SetAztecSymbolMode_out.png");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate barcode object and Set border style to solid
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code93Standard);
generator.Parameters.Border.DashStyle = BorderDashStyle.Solid;
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set differnt barcode properties
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
generator.Parameters.Barcode.XDimension.Millimeters = 1f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode-codetext_out.jpg", BarCodeImageFormat.Jpeg);
Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "barcode-codetext_out.jpg");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set differnt barcode properties
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
generator.Parameters.Barcode.BarHeight.Millimeters = 3.0f;
// Save the image locally and set its image format to Jpeg
generator.Save(dataDir + "barcode3_out.jpg", BarCodeImageFormat.Jpeg);
// Set the bar height to 3 millimeters and Save the image locally and set its image format to Jpeg
generator.Parameters.Barcode.BarHeight.Millimeters = 7.0f;
generator.Save(dataDir + "barcode7_out.jpg", BarCodeImageFormat.Jpeg);
// Set the bar height to 3 millimeters and Save the image to disk
generator.Parameters.Barcode.BarHeight.Millimeters = 11.0f;
generator.Save(dataDir + "Code128-bar-height_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and Set the SymbologyType and Height and Resolution for barcode
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.DatabarStackedOmniDirectional, "(01)90013670000396(3200)15(11)150819");
generator.Parameters.Barcode.XDimension.Millimeters = 0.330f;
generator.Parameters.Barcode.BarHeight.Millimeters = 27.77f;
generator.Parameters.Resolution = 1200.0f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "Barheight_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator , specify codetext symbology and encode mode
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "test123");
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.Auto;
generator.Save(dataDir + "QR-Encode-mode_out.jpg");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create instance of BarcodeGenerator , specify codetext and symbology in the constructor
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.QR, "1234567890");
// Set QRErrorLevel and Save the file to disk.
generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelH;
generator.Save(dataDir + "QR-error-correction_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.EAN13, "123456789123");
// Set the supplement data (5 Digit)
generator.Parameters.Barcode.Supplement.SupplementData = "12345";
generator.Parameters.Barcode.Supplement.SupplementSpace.Millimeters = 2.0f;
generator.Save(dataDir + "SetSupplementData_out.jpg", BarCodeImageFormat.Jpeg);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Create an instance of BarCodeBuilder class and set the symbology and code text.
BarCodeBuilder builder = new BarCodeBuilder("12345", Symbology.Code39Standard);
// Set the GraphicsUnit property to Millimeter.
builder.GraphicsUnit = Aspose.BarCode.GraphicsUnit.Millimeter;
// Set the dimension and bar height
builder.xDimension = 0.22f;
builder.BarHeight = 15f;
// Set the barcode resolution.
builder.Resolution = new Resolution(72, 72, ResolutionMode.Customized);
// For .NET 2.0 and upper, to compare results, set margins like default of compact edition
builder.Margins = new MarginsF(8, 6, 4, 2);
System.Drawing.Bitmap barcodeImage = builder.GenerateBarCodeImage();
// Compact case: put to pictureBox
pictureBox1.Image = barcodeImage;
barcodeImage.Save(dataDir + "barcode_out.png", System.Drawing.Imaging.ImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Set the symbology and code text and X dimension reduction property of barcode and save barcode Image
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "blackReduction");
generator.Parameters.Barcode.XDimension.Millimeters = 1.2f;
generator.Parameters.Barcode.BarWidthReduction.Millimeters = 0.2f;
generator.Save(dataDir + "SetWideNarrowRatio_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
generator.Save(dataDir + "barcode-SpecifySymbologies_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate barcode object and set differnt barcode properties
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code128, "1234567");
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode-symbiology_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode, Set codeText, SymbologyType and Save barcode on local disk
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.SwissPostParcel, "989967121212121212");
generator.Save(dataDir + "SwissPostParcelBarcodeWithAdditionalServiceType_out.Png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode and Save barcode on local
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.SwissPostParcel, "RA121212122CH");
generator.Save(dataDir + "SwissPostParcelBarcodeWithInternationalMailType_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Generate the barcode and Save barcode on local
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.SwissPostParcel, "0610");
generator.Save(dataDir + "SwissPostParcelSymbology_out.png");
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageBarCodes();
// Instantiate linear barcode object
BarcodeGenerator generator = new BarcodeGenerator (EncodeTypes.Code39Standard, "1234567");
// Set the wide to narrow ratio for the barcode
generator.Parameters.Barcode.WideNarrowRatio = 3.0f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode_ratio_3_out.jpg", BarCodeImageFormat.Jpeg);
// Set the wide to narrow ratio for the barcode
generator.Parameters.Barcode.WideNarrowRatio = 5.0f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode_ratio_5_out.jpg", BarCodeImageFormat.Jpeg);
// Set the wide to narrow ratio for the barcode
generator.Parameters.Barcode.WideNarrowRatio = 7.0f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "barcode_ratio_7_out.jpg", BarCodeImageFormat.Jpeg);
// Set the wide to narrow ratio for the barcode
generator.Parameters.Barcode.WideNarrowRatio = 9.0f;
// Save the image to your system and set its image format to Jpeg
generator.Save(dataDir + "code39-wide-narrow-ratio_out.jpg", BarCodeImageFormat.Jpeg);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageComplexBarcodes();
// Instantiate barcode object and set CodeText
var swissQRCodetext = new SwissQRCodetext();
swissQRCodetext.Bill.Account = "Account";
swissQRCodetext.Bill.BillInformation = "BillInformation";
swissQRCodetext.Bill.Currency = "EUR";
var generator = new ComplexBarcodeGenerator(swissQRCodetext);
var img = generator.GenerateBarCodeImage();
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = "test";
// Save the Barcode image in BMP format
img.Save(dataDir + "swissQRCode_out.bmp", ImageFormat.Bmp);
// Save the Barcode image in JPEG format
generator.Save(dataDir + "swissQRCodetext_out.png", BarCodeImageFormat.Png);
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ManageComplexBarcodes();
using (var reader = new BarCodeReader(dataDir + "swissQRCodetext_out.png", DecodeType.QR))
{
foreach (BarCodeResult barcodeResult in reader.ReadBarCodes())
{
SwissQRCodetext result = ComplexCodetextReader.TryDecodeSwissQR(barcodeResult.CodeText);
Console.WriteLine("Account :" + result.Bill.Account);
Console.WriteLine("BillInformation = " + result.Bill.BillInformation);
Console.WriteLine("Currency :" + result.Bill.Currency);
}
}
using (var generator = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
generator.Save(dataDir + "GenerateBarcode_out.png");
}
using (var gen = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
gen.CodeText = "123456789";
gen.Parameters.Barcode.AutoSizeMode = Aspose.BarCode.Generation.V3.AutoSizeMode.Interpolation;
gen.Parameters.Barcode.BarCodeWidth.Pixels = 500;
gen.Parameters.Barcode.BarCodeHeight.Pixels = 200;
gen.Save(dataDir + "GenerateBarcodeWithAutoSizeInterpolation_out.png");
}
using (var gen = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
gen.CodeText = "123456789";
gen.Parameters.CaptionAbove.Padding.Top.Pixels = 70;
gen.Parameters.CaptionAbove.Padding.Bottom.Pixels = 70;
gen.Parameters.CaptionAbove.Padding.Left.Pixels = 50;
gen.Parameters.CaptionAbove.Padding.Right.Pixels = 50;
gen.Parameters.CaptionAbove.Text = "Caption Above";
gen.Parameters.CaptionAbove.TextColor = Color.Red;
gen.Parameters.CaptionAbove.Font.Size.Pixels = 28;
gen.Parameters.CaptionAbove.Visible = true;
gen.Parameters.CaptionAbove.Alignment = Aspose.BarCode.Generation.V3.StringAlignment.Center;
gen.Save(dataDir + "GenerateBarcodeWithCaptionAbove_out.png");
}
using (var gen = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
gen.CodeText = "123456789";
gen.Parameters.CaptionBelow.Padding.Top.Pixels = 70;
gen.Parameters.CaptionBelow.Padding.Bottom.Pixels = 70;
gen.Parameters.CaptionBelow.Padding.Left.Pixels = 50;
gen.Parameters.CaptionBelow.Padding.Right.Pixels = 50;
gen.Parameters.CaptionBelow.Text = "Caption Below";
gen.Parameters.CaptionBelow.TextColor = Color.Red;
gen.Parameters.CaptionBelow.Font.Size.Pixels = 28;
gen.Parameters.CaptionBelow.Visible = true;
gen.Parameters.CaptionBelow.Alignment = Aspose.BarCode.Generation.V3.StringAlignment.Center;
gen.Save(dataDir + "GenerateBarcodeWithCaptionBelow_out.png");
}
using (var generator = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14, "1234567890"))
{
generator.Save(dataDir + "GenerateBarcodeWithCodeText_out.png");
}
using (var generator = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
string codetext = generator.CodeText;
Console.WriteLine(codetext);
}
using (var gen = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
gen.CodeText = "123456789";
gen.Parameters.Border.Width.Pixels = 50;
gen.Parameters.Border.Color = Color.Red;
gen.Parameters.Border.Visible = true;
gen.Parameters.Border.DashStyle = Aspose.BarCode.BorderDashStyle.Solid;
gen.Save(dataDir + "SettingBarcodeBorder_out.png");
}
using (var generator = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
generator.CodeText = "123456789";
generator.Parameters.Barcode.BarHeight.Pixels = 500;
generator.Save(dataDir + "SettingBarcodeHeight_out.png");
}
using (var gen = new Aspose.BarCode.Generation.V3.BarcodeGenerator(EncodeTypes.ITF14))
{
gen.CodeText = "123456789";
gen.Parameters.Barcode.ForeColor = Color.DarkBlue;
gen.Parameters.Barcode.XDimension.Pixels = 5;
gen.Parameters.Barcode.BarHeight.Pixels = 200;
gen.Parameters.Barcode.Padding.Top.Pixels = 70;
gen.Parameters.Barcode.Padding.Bottom.Pixels = 70;
gen.Parameters.Barcode.Padding.Left.Pixels = 70;
gen.Parameters.Barcode.Padding.Right.Pixels = 70;
gen.Save(dataDir + "SettingBarcodeProperties_out.png");
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Create an instance of BarCodeBuilder
BarCodeBuilder builder = new BarCodeBuilder();
// Set the symbology type, codetext
builder.SymbologyType = Symbology.Code39Standard;
builder.CodeText = "test-123";
// Get the barcode image and Place the image on the Picturebox control
Image img = builder.BarCodeImage;
pictureBox1.Image = img;
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
private void previewButton_Click(object sender, System.EventArgs e)
{
printPreviewDialog1.Document=printDocument1;
printPreviewDialog1.ShowDialog();
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
private void printButton_Click(object sender, System.EventArgs e)
{
printDocument1.Print();
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(barCodeControl1.BarCodeImage, 350, 40);
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Create an instance of BarCodeReader
BarCodeReader reader = new BarCodeReader(txtBarCodeImage.Text, BarCodeReadType.Code39Standard);
// Set the symbology type to Code39Standard
// Recognize the barcode
string strMessage = "";
// Get codetext and symbology types of all the barcodes recognized
while(reader.Read())
{
strMessage += "CodeText: " + reader.getCodeText() + "\nSymbology Type: " + reader.getReadType().ToString() + "\n";
}
reader.Close();
MessageBox.Show(strMessage);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Create barcode builder
Aspose.BarCode.BarCodeBuilder bb;
bb = new Aspose.BarCode.BarCodeBuilder();
bb.CodeText = codeText;
bb.BorderVisible = false;
bb.BarHeight = 15f;
bb.SymbologyType = Aspose.BarCode.Symbology.Code128;
bb.xDimension = 0.6f;
bb.Resolution.DpiX = 300f;
bb.Resolution.DpiY = 300f;
// Save barcode image to stream
System.IO.MemoryStream ms;
ms = new System.IO.MemoryStream();
bb.BarCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
// Create DataSet_BarCode
DataSet_BarCode ds = new DataSet_BarCode();
DataRow dr = ds.Tables["DataTable_BarCode"].NewRow();
dr["CodeText"] = codeText;
dr["BarCodeImage"] = ms.GetBuffer();
ds.Tables["DataTable_BarCode"].Rows.Add(dr);
CrystalReport1 barcodeReport = new CrystalReport1();
barcodeReport.SetDataSource(ds);
this.CrystalReportViewer1.ReportSource = barcodeReport;
this.CrystalReportViewer1.DataBind();
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
void RetrieveFromDB()
{
SqlConnection con = null;
try
{
con = new SqlConnection(connectionString);
string sqlStatement = "SELECT * FROM barcodes";
SqlDataAdapter adapter = new SqlDataAdapter(sqlStatement, con);
DataTable dt = new DataTable("barcodes");
adapter.Fill(dt);
BarCodeControl bcc = new BarCodeControl();
bcc.CodeText = dt.Rows[0]["codetext"].ToString();
bcc.SymbologyType = (Symbology)Enum.Parse(typeof(Symbology), dt.Rows[0]["symbology"].ToString(), true);
panel1.Controls.Add(bcc);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if (con != null)
con.Close();
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
void StoreInDB()
{
SqlConnection con = null;
string sql = "INSERT INTO barcodes(codetext,symbology) VALUES(@Codetext,@Symbology)";
try
{
con = new SqlConnection(connectionString);
con.Open();
SqlCommand sqlInsert = new SqlCommand();
sqlInsert.Connection = con;
sqlInsert.CommandText = sql;
sqlInsert.Parameters.Add("@Codetext", this.barCodeControl1.CodeText);
sqlInsert.Parameters.Add("@Symbology", barCodeControl1.SymbologyType.ToString());
sqlInsert.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if (con != null)
con.Close();
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
SaveFileDialog fd = new SaveFileDialog();
if (fd.ShowDialog() == DialogResult.OK)
{
txtBarCodeImage.Text = fd.FileName;
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Open file dialog to browse and select the file
OpenFileDialog fd = new OpenFileDialog();
if (fd.ShowDialog() == DialogResult.OK)
{
// Set the file path
txtBarCodeImage.Text = fd.FileName;
// Create a bitmap and assign it to the Picturebox control
Bitmap bmp = new Bitmap(txtBarCodeImage.Text);
pictureBox1.Image = bmp;
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code39Standard, "1234567");
// Creating memory stream and Saving barcode image to memory stream
System.IO.Stream ms = new System.IO.MemoryStream();
generator.Save(ms, BarCodeImageFormat.Bmp);
// Create Pdf document and Add a section to the Pdf document
Document doc = new Document();
doc.Pages.Add();
// Open document
PdfFileMend mender = new PdfFileMend();
// Create PdfFileMend object to add barcode image
mender.BindPdf(doc);
// Add image in the PDF file
mender.AddImage(ms, 1, 100, 600, 200, 700);
// Save changes
mender.Save(dataDir + "AddImage_out.pdf");
// Close PdfFileMend object
mender.Close();
// Create Pdf document and Add a section to the Pdf document
Document doc = new Document();
doc.Pages.Add();
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567");
// Creating memory stream and Saving barcode image to memory stream
System.IO.Stream ms = new System.IO.MemoryStream();
generator.Save(ms, BarCodeImageFormat.Bmp);
// Instantiate Excel class that represents an excel file
Workbook excel1 = new Workbook();
// Add the barcode image into the pictures collection of the first worksheet of the excel file in the form of a MemoryStream, ms with upper left row=5 and
// Upper left column=5 and Save the excel file
excel1.Worksheets[0].Pictures.Add(5, 5, ms);
excel1.Save(dataDir + "MyFile_out.xls");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128);
generator.CodeText = "1234567";
//Save and Retrieve Barcode Information
StoreInDB(generator);
BarcodeGenerator barcode = RetrieveFromDB();
// Save the retrievd Barcode in JPEG format
barcode.Save(dataDir + "barcode_out.jpg", BarCodeImageFormat.Jpeg);
// Save and Retrieve Barcode Image
StoreImageInDB(generator);
Image image = RetrieveImageFromDB();
// Save the retrieved Barcode image in JPEG format
image.Save(dataDir + "BarcodeFromDB_out.jpg", ImageFormat.Jpeg);
private static BarcodeGenerator RetrieveFromDB()
{
BarcodeGenerator barcode = null;
string connectionString = "server=localhost;database=test_db;uid=sa;pwd=123;";
// Create the SQL connection.
SqlConnection mConnection = new SqlConnection(connectionString);
mConnection.Open();
// Create the SQL command.
string commandString = "SELECT * FROM barcodes";
SqlCommand command = new SqlCommand(commandString, mConnection);
// Create the data adapter.
SqlDataAdapter adapter = new SqlDataAdapter(command);
// Fill the results from the database into a DataTable.
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
string SymbologyType = dataTable.Rows[0]["Symbology"].ToString();
bool isValid = EncodeTypes.Parse(SymbologyType, out BaseEncodeType encodeType);
if(isValid)
{
barcode = new BarcodeGenerator(encodeType);
barcode.CodeText = dataTable.Rows[0]["CodeText"].ToString();
}
// Close the connection.
mConnection.Close();
return barcode;
}
private static Image RetrieveImageFromDB()
{
string connectionString = "server=localhost;database=test_db;uid=sa;pwd=123;";
// Create the SQL connection.
SqlConnection mConnection = new SqlConnection(connectionString);
mConnection.Open();
// Create the SQL command.
string commandString = "SELECT * FROM barcodeImages";
SqlCommand command = new SqlCommand(commandString, mConnection);
// Create the data adapter.
SqlDataAdapter adapter = new SqlDataAdapter(command);
// Fill the results from the database into a DataTable.
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
MemoryStream ms = new MemoryStream((byte[])dataTable.Rows[0]["barcodeImage"]);
Image image = Image.FromStream(ms, true);
mConnection.Close();
return image;
}
private static void StoreImageInDB(BarcodeGenerator barcode)
{
string connectionString = "server=localhost;database=test_db;uid=sa;pwd=123;";
MemoryStream ms = new MemoryStream();
barcode.Save(ms, BarCodeImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
byte[] imgBytes = ms.ToArray();
// Create the SQL connection
SqlConnection mConnection = new SqlConnection(connectionString);
mConnection.Open();
// Create the SQL command.
string commandString = "INSERT INTO barcodeImages(CodeText,barcodeImage) VALUES(@codetext, @BarcodeImage)";
SqlCommand command = new SqlCommand(commandString, mConnection);
command.Parameters.AddWithValue("codetext", barcode.CodeText);
command.Parameters.AddWithValue("BarcodeImage", imgBytes);
// Execute the command.
command.ExecuteNonQuery();
mConnection.Close();
}
private static void StoreInDB(BarcodeGenerator generator)
{
string connectionString = "server=localhost;database=test_db;uid=sa;pwd=123;";
string Codetext = generator.CodeText;
string Symbology = generator.BarcodeType.ToString();
// Create the SQL connection.
SqlConnection mConnection = new SqlConnection(connectionString);
mConnection.Open();
// Create the SQL command.
string commandString = "INSERT INTO barcodes (CodeText,Symbology) VALUES('" + Codetext + "','" + Symbology + "')";
SqlCommand command = new SqlCommand(commandString, mConnection);
// Execute the command.
command.ExecuteNonQuery();
// Close the connection.
mConnection.Close();
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128);
generator.CodeText = "1234567";
// Save the Barcode image in JPEG format
generator.Save(dataDir + "barcode_out.jpg", BarCodeImageFormat.Jpeg);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Create a word document object with Aspose.Words
Document doc = new Document();
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code39Standard, "1234567");
// Create builder for document object, Insert the barCode image into document and Save the word document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertImage(generator.GenerateBarCodeImage());
doc.Save(dataDir + "Myfile_out.doc");
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
try
{
Document pdfDocument = new Document(dataDir + "document.pdf");
int pageCount = pdfDocument.Pages.Count;
for (var i = 1; i <= pageCount; i++)
{
var converter = new PdfConverter();
converter.BindPdf(dataDir + @"document.pdf");
converter.StartPage = i;
converter.EndPage = i;
converter.DoConvert();
MemoryStream stream = new MemoryStream();
converter.GetNextImage(stream, ImageFormat.Png);
using (BarCodeReader reader = new BarCodeReader(stream, DecodeType.Code93Standard))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Codetext found: " + result.CodeType + ", Symbology: " + result.CodeText);
}
}
converter.Close();
converter.Dispose();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
Dictionary<string, BaseEncodeType> collection = new Dictionary<string, BaseEncodeType>();
collection.Add("ONE123", EncodeTypes.Code39Standard);
collection.Add("Process Collection", EncodeTypes.DataMatrix);
collection.Add("Dictionary Collection", EncodeTypes.QR);
collection.Add("X06712AT", EncodeTypes.Code128);
collection.Add("979026000043", EncodeTypes.EAN13);
collection.Add("Aztec BarCode", EncodeTypes.Aztec);
List<Bitmap> images = new List<Bitmap>();
foreach (KeyValuePair<string, BaseEncodeType> pair in collection)
{
BarcodeGenerator builder = new BarcodeGenerator(pair.Value, pair.Key);
images.Add(builder.GenerateBarCodeImage());
}
int maxWidth = int.MinValue;
int sumHeight = 0;
foreach (Bitmap bmp in images)
{
sumHeight += bmp.Height;
if (maxWidth < bmp.Width)
maxWidth = bmp.Width;
}
const int offset = 10;
Bitmap resultBitmap = new Bitmap(maxWidth + offset * 2, sumHeight + offset * images.Count);
using (Graphics g = Graphics.FromImage(resultBitmap))
{
g.Clear(Color.White);
int yPosition = offset;
for (int i = 0; i < images.Count; ++i)
{
Bitmap currentBitmap = images[i];
g.DrawImage(currentBitmap, offset, yPosition);
yPosition += currentBitmap.Height + offset;
}
}
resultBitmap.Save(dataDir + "barcodes_out.png", ImageFormat.Png);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
try
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Bind the pdf document
Pdf.Facades.PdfExtractor pdfExtractor = new Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(dataDir + @"document.pdf");
// Set page range for image extraction
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 1;
// Extract the images
Console.WriteLine("Extracting images....");
pdfExtractor.ExtractImage();
// Save images to stream in a loop
while (pdfExtractor.HasNextImage())
{
Console.WriteLine("Getting next image....");
// Save image to stream
MemoryStream imageStream = new MemoryStream();
pdfExtractor.GetNextImage(imageStream);
imageStream.Position = 0;
Console.WriteLine("Recognizing barcode....");
// Recognize the barcode from the image stream above
using (BarCodeReader reader = new BarCodeReader(imageStream, DecodeType.Code39Standard))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Codetext found: " + result.CodeType + ", Symbology: " + result.CodeText);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
try
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Bind the pdf document
Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter();
pdfConverter.BindPdf(dataDir + @"document.pdf");
// Set page range for image extraction
pdfConverter.StartPage = 1;
pdfConverter.EndPage = 1;
// Set rendering optimization for barcodes
pdfConverter.RenderingOptions.BarcodeOptimization = true;
pdfConverter.DoConvert();
// Save images to stream in a loop
while (pdfConverter.HasNextImage())
{
// Save image to stream
MemoryStream imageStream = new MemoryStream();
pdfConverter.GetNextImage(imageStream);
imageStream.Position = 0;
// Recognize the barcode from the image stream above
using (BarCodeReader reader = new BarCodeReader(imageStream, DecodeType.AllSupportedTypes))
{
var res = reader.ReadBarCodes();
foreach (BarCodeResult result in res)
{
Console.WriteLine("Codetext found: " + result.CodeType + ", Symbology: " + result.CodeText);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_TechnicalArticles();
// Load the word document, get all the shapes
Document wordDocument = new Document(dataDir + "Document.doc");
NodeCollection shapes = wordDocument.GetChildNodes(NodeType.Shape, true);
// Loop through all the shapes
foreach (Shape shape in shapes)
{
// Check if it has an image
if (shape.HasImage)
{
// Save the image in memory stream
MemoryStream imgStream = new MemoryStream();
shape.ImageData.Save(imgStream);
// Recognize the barcode from the image stream above
using (BarCodeReader reader = new BarCodeReader(new Bitmap(imgStream), DecodeType.Code39Standard))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Codetext found: " + result.CodeType + ", Symbology: " + result.CodeText);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate linear barcode object, Set the Code text and symbology type for the barcode
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567");
// Creating memory stream and Saving barcode image to memory stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
generator.Save(ms, BarCodeImageFormat.Bmp);
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
String barcode = null;
MemoryStream stream = new MemoryStream();
// Save barcode in stream object
barcodeName.Save(stream, ImageFormat.Png);
// Create an instance of BarCodeReader and set image and symbology type to recognize
BarCodeReader reader = new BarCodeReader(stream, BarCodeReadType.Code39Extended);
// Try to recognize barcode in the image
if (reader.Read())
barcode = "Code Text: " + reader.GetCodeText() + " Symbology: " + reader.GetReadType();
// Close the reader and Display the codetext
reader.Close();
MessageBox.Show(barcode);
<xs:schema id="DataSet_BarCode" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DataSet_BarCode" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="DataTable_BarCode">
<xs:complexType>
<xs:sequence>
<xs:element name="CodeText" type="xs:string" minOccurs="0" />
<xs:element name="BarCodeImage" type="xs:base64Binary" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
private void Form1_Load(object sender, EventArgs e)
{
// Instantiate an instance of license and set the license file through its path
License license = new License();
license.SetLicense("Aspose.BarCode.lic");
}
' For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Instantiate an instance of license and set the license file through its path
Dim license As license = New license
License.SetLicense("Aspose.BarCode.lic")
End Sub
public void save(java.lang.String fileName, int fileFormat)
# For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
use Win32::OLE;
# Create an instance of BarCodeBuilder
my $barcode = CreateObject Win32::OLE 'Aspose.BarCode.BarCodeBuilder';
# Set code text and symbology type and save the barcode image
$barcode->{CodeText} = “test-123”;
$barcode->{SymbologyType} = 15;
$barcode->Save("testperl_out.png");
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Generate BarCode in PHP using Aspose.BarCode for .NET</title>
</head>
<body>
<form name="form1" method="post" action="GenerateBarCode.php" ID="Form1">
Please enter CodeText: <input name="txtCodeText" value="test-123" ID="Text1"/>
<br />
<input type="submit" value="Generate BarCode" ID="Submit1" NAME="Submit1"/>
</form>
<?php
// Error handler function
function customError($errno, $errstr)
{
echo "<hr><b>Error:</b> [$errno] $errstr <br><hr>";
}
// Set error handler
set_error_handler("customError");//trigger error
// Request value of CodeText from the form
$strCodeText = $_POST['txtCodeText'];
// Check if codetext is empty
if ($strCodeText != "")
{
// Create a new instance of BarCodeBuilder object using COM interop
$barcodeBuilder = new COM("Aspose.BarCode.BarCodeBuilder");
// Set the codetext, symbology type and save the barcode image in a folder of webserver
$barcodeBuilder->CodeText = $strCodeText;
$barcodeBuilder->SymbologyType = 15;
$barcodeBuilder->Save("e:\\data\\aspose\\temp\\testphp.png");
}
?> </body>
</html>
<?php
phpinfo();
?>
// Create an ole object
oleobject barcode;
barcode = CREATE oleobject;
// Initialize it with BarCodeBuilder
barcode.ConnectToNewObject("Aspose.BarCode.BarCodeBuilder");
// Set the code text, symbology type and save the barcode image
barcode.CodeText = “test-123”;
barcode.SymbologyType = 15;
barcode.Save("testpowerbuilder_out.png");
import win32com.client
# Create an instance of BarCodeBuilder class using COM interop
barcodeBuilder = win32com.client.Dispatch("Aspose.BarCode.BarCodeBuilder")
# Set codetext and symbology type and save the barcode image to file in disk
barcodeBuilder.CodeText = "testing-123"
barcodeBuilder.SymbologyType = 15
barcodeBuilder.Save("testPython.png")
try
{
// Read file from directory
using (BarCodeReader reader = new BarCodeReader("Scan.jpg"))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Read symbology type and code text
Console.WriteLine("Symbology Type: " + result.CodeType);
Console.WriteLine("CodeText: " + result.CodeText);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose BarCode License. You can purchase full license or get 30 day temporary license from https://www.aspose.com/purchase/default.aspx.");
}
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
barCodeElement1.CodeText = "XYZ-111";
barCodeElement1.SymbologyType = Aspose.BarCode.Symbology.Code128;
' For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
barCodeElement1.CodeText = "XYZ-111"
barCodeElement1.SymbologyType = Aspose.BarCode.Symbology.Code128
// For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
// Instantiate the License class and Pass only the name of the license file embedded in the assembly
Aspose.BarCode.License license = new Aspose.BarCode.License();
license.SetLicense("Aspose.BarCode.lic");
' For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET
' Instantiate the License class and Pass only the name of the license file embedded in the assembly
Dim license As Aspose.BarCode.License = New Aspose.BarCode.License()
license.SetLicense("Aspose.BarCode.lic")
SELECT ProductID, Name, ProductNumber FROM Product
<configuration>
<startup>
<requiredRuntime version="v1.0.3705" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">
<dependentAssembly>
<assemblyIdentity name="Regcode" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.EnterpriseServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Security" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="CustomMarshalers" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Accessibility" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Configuration.Install" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.DirectoryServices" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ServiceProcess" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.RegularExpressions" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Services" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Design" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Messaging" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IEExecRemote" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="IIEHost" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ISymWrapper" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="mscorcfg" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Management" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Remoting" publicKeyToken="b77a5c561934e089" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.Serialization.Formatters.Soap" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mobile" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Vsa.Vb.CodeDOMProcessor" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft_VsaVb" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualBasic.Vsa" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="cscompmgd" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.JScript" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualBasic" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualC" publicKeyToken="b03f5f7f11d50a3a" culture=""/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Generate BarCode in ASP using Aspose.BarCode for .NET</title>
</head>
<body>
<form name="form1" method="post" action="GenerateBarCode.asp" ID="Form1">
Please enter CodeText: <input name="txtCodeText" value="test-123" ID="Text1"/>
<br />
<input type="submit" value="Generate BarCode" ID="Submit1" NAME="Submit1"/>
</form>
<%
' Get value of CodeText from the Form
strCodeText = Request.form("txtCodeText")
' If there is some value in CodeText, generate barcode
If strCodeText <> "" Then
' Declare instance of type BarCodeBuilder
Dim barCodeBuilder
' Initialize using CreateObject() method
Set barCodeBuilder = CreateObject("Aspose.BarCode.BarCodeBuilder")
' Set the CodeText, Symbology Type and save the barcode Image.
barCodeBuilder.CodeText = strCodeText
barCodeBuilder.SymbologyType = 15
strBarCodeImage = "E:\\Testasp.png"
barCodeBuilder.Save strBarCodeImage
' Save the barcode image in a folder in webserver – BMP format
strBarCodeImage = "E:\\testasp.bmp"
barCodeBuilder.Save_5 strBarCodeImage, 0
Response.Write("BarCode image successfully generated at " & strBarCodeImage)
End If
%>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Recognize barcode in ASP using Aspose.BarCode for .NET</title>
</head>
<body>
<form name="form1" method="post" action="BarCode.asp">
Please file name with full path: <input name="filePath" value="c:\\ab\\testasp.png" />
<br />
<input type="submit" value="Recognize BarCode" />
</form>
<%
' Get file name with full path
barcodeFile = Request.form("filePath")
If barcodeFile <> "" Then
Dim barcodeReader
Set barcodeReader = CreateObject("Aspose.BarCodeRecognition.BarCodeReader")
barcodeReader.SetBarCodeImage(barcodeFile)
barcodeReader.SetBarCodeReadType(4)
barcodeReader.Read()
strBarCodeText = barcodeReader.GetCodeText()
Response.Write("BarCode image recognized, codetext: " & strBarCodeText)
End If
%>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment