Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
}