Skip to content

Commit 2f30096

Browse files
Merge pull request #76 from aspose-barcode/agent/hibc-lic-barcode/2026-07-06-185436
feat: Add Aspose.BarCode .NET C# Examples — Hibc Lic Barcode
2 parents 58f17f2 + 8b8b895 commit 2f30096

35 files changed

Lines changed: 1320 additions & 1154 deletions

File tree

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,64 @@
1+
// Title: Add Quiet Zone to HIBC DataMatrix LIC Barcode
2+
// Description: Demonstrates how to generate a HIBC DataMatrix LIC barcode with a ten‑module quiet zone using Aspose.BarCode.
3+
// Category-Description: This example belongs to the Aspose.BarCode complex barcode generation category. It shows how to work with the ComplexBarcodeGenerator, HIBCLICSecondaryAndAdditionalDataCodetext, and SecondaryAndAdditionalData classes to create HIBC‑compliant DataMatrix barcodes. Developers often need to adjust quiet zones, module size, and padding to satisfy printing standards and regulatory requirements.
4+
// Prompt: Add a quiet zone of ten modules around a DataMatrix HIBC LIC barcode to meet printing standards.
5+
// Tags: datamatrix, hibc, quietzone, png, generation, complexbarcode, aspose.barcodes, secondarydata
6+
17
using System;
2-
using System.IO;
38
using Aspose.BarCode.ComplexBarcode;
49
using Aspose.BarCode.Generation;
5-
using Aspose.BarCode.BarCodeRecognition;
10+
using Aspose.Drawing;
611
using Aspose.Drawing.Imaging;
712

813
/// <summary>
9-
/// Demonstrates generation of a HIBC DataMatrix LIC barcode with custom module size,
10-
/// quiet zone, and resolution using Aspose.BarCode.
14+
/// Generates a HIBC DataMatrix LIC barcode with a ten‑module quiet zone and saves it as a PNG image.
1115
/// </summary>
1216
class Program
1317
{
1418
/// <summary>
15-
/// Entry point of the application. Generates and saves a HIBC DataMatrix LIC barcode image.
19+
/// Entry point of the example. Prepares secondary data, configures barcode parameters, adds a quiet zone,
20+
/// and saves the resulting image.
1621
/// </summary>
1722
static void Main()
1823
{
19-
// Prepare primary HIBC LIC data (required fields)
20-
var primaryCodetext = new HIBCLICPrimaryDataCodetext
24+
// Prepare secondary data for the HIBC LIC DataMatrix barcode (lot and serial numbers).
25+
var secondaryData = new SecondaryAndAdditionalData
2126
{
22-
BarcodeType = EncodeTypes.HIBCDataMatrixLIC,
23-
Data = new PrimaryData
24-
{
25-
ProductOrCatalogNumber = "12345", // Product or catalog identifier
26-
LabelerIdentificationCode = "A999", // Labeler ID
27-
UnitOfMeasureID = 1 // Unit of measure identifier
28-
}
27+
LotNumber = "LOT123",
28+
SerialNumber = "SN001"
2929
};
3030

31-
// Define module size (XDimension) in points (1 point = 1/72 inch)
32-
float moduleSize = 2f; // 2 points per module
33-
34-
// Construct output file path in the current working directory
35-
string outputPath = Path.Combine(Directory.GetCurrentDirectory(), "hibc_datamatrix.png");
31+
// Create the complex codetext object that combines the barcode type, link character, and secondary data.
32+
var hibcCodetext = new HIBCLICSecondaryAndAdditionalDataCodetext
33+
{
34+
BarcodeType = EncodeTypes.HIBCDataMatrixLIC,
35+
LinkCharacter = '+',
36+
Data = secondaryData
37+
};
3638

37-
// Generate the barcode with a quiet zone of ten modules on each side
38-
using (var generator = new ComplexBarcodeGenerator(primaryCodetext))
39+
// Initialize the complex barcode generator with the prepared codetext.
40+
using (var generator = new ComplexBarcodeGenerator(hibcCodetext))
3941
{
40-
// Set the size of a single module (XDimension)
41-
generator.Parameters.Barcode.XDimension.Point = moduleSize;
42+
// Define the module size (XDimension) – 2 points per module.
43+
generator.Parameters.Barcode.XDimension.Point = 2f;
4244

43-
// Calculate quiet zone size (10 modules * module size)
44-
float quietZone = 10f * moduleSize;
45+
// Calculate quiet zone size: ten modules on each side.
46+
float quietZone = generator.Parameters.Barcode.XDimension.Point * 10f;
4547

46-
// Apply quiet zone padding to all sides
48+
// Apply the quiet zone to all four padding sides.
4749
generator.Parameters.Barcode.Padding.Left.Point = quietZone;
4850
generator.Parameters.Barcode.Padding.Top.Point = quietZone;
4951
generator.Parameters.Barcode.Padding.Right.Point = quietZone;
5052
generator.Parameters.Barcode.Padding.Bottom.Point = quietZone;
5153

52-
// Optional: set image resolution for higher quality output
53-
generator.Parameters.Resolution = 300f;
54+
// Enable automatic sizing using interpolation mode.
55+
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
5456

55-
// Save the generated barcode image as PNG
56-
generator.Save(outputPath, BarCodeImageFormat.Png);
57+
// Save the generated barcode as a PNG file.
58+
generator.Save("hibc_datamatrix.png");
5759
}
5860

59-
// Inform the user where the barcode image was saved
60-
Console.WriteLine($"Barcode saved to: {outputPath}");
61+
// Inform the user that the barcode has been generated.
62+
Console.WriteLine("HIBC DataMatrix LIC barcode generated with a 10‑module quiet zone.");
6163
}
6264
}
Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,49 @@
1+
// Title: Generate HIBC DataMatrix LIC Barcode at 600 DPI
2+
// Description: Creates a HIBC DataMatrix LIC barcode with secondary data and saves it as a 600 DPI PNG image.
3+
// Category-Description: This example belongs to the Aspose.BarCode complex barcode generation category. It demonstrates how to use the ComplexBarcodeGenerator together with HIBCLICSecondaryAndAdditionalDataCodetext to produce high‑density HIBC LIC DataMatrix barcodes. Typical use cases include pharmaceutical labeling and inventory tracking where secondary information (lot, serial, dates) must be encoded at high resolution for small‑format labels.
4+
// Prompt: Adjust the image resolution to 600 DPI when generating a DataMatrix HIBC LIC barcode for high‑density labels.
5+
// Tags: datamatrix, hibc, lic, generation, resolution, png, complexbarcodegenerator, hibclicsecondaryandadditionaldatacodetext
6+
17
using System;
28
using Aspose.BarCode.ComplexBarcode;
39
using Aspose.BarCode.Generation;
4-
using Aspose.Drawing;
510

611
/// <summary>
7-
/// Demonstrates generation of a HIBC DataMatrix barcode that includes secondary and additional data,
8-
/// saved at a resolution of 600 DPI.
12+
/// Demonstrates generation of a HIBC DataMatrix LIC barcode with secondary data
13+
/// and saves the image at 600 DPI resolution.
914
/// </summary>
1015
class Program
1116
{
1217
/// <summary>
13-
/// Entry point of the application.
14-
/// Prepares barcode data, configures the generator, saves the image, and outputs a confirmation message.
18+
/// Entry point of the example. Prepares secondary data, configures the generator,
19+
/// and saves the high‑resolution barcode image.
1520
/// </summary>
1621
static void Main()
1722
{
18-
// ------------------------------------------------------------
19-
// 1. Prepare secondary‑and‑additional data for the HIBC LIC DataMatrix barcode
20-
// ------------------------------------------------------------
21-
var secondaryData = new SecondaryAndAdditionalData
23+
// Prepare secondary and additional data required for a HIBC LIC DataMatrix barcode
24+
var secondaryCodetext = new HIBCLICSecondaryAndAdditionalDataCodetext
2225
{
23-
LotNumber = "LOT123", // Lot identifier
24-
SerialNumber = "SN001", // Serial number
25-
ExpiryDate = DateTime.Today.AddMonths(6), // Expiration date (6 months from today)
26-
ExpiryDateFormat = HIBCLICDateFormat.MMDDYY, // Date format for the expiry date
27-
Quantity = 10, // Quantity of items
28-
DateOfManufacture = DateTime.Today // Manufacturing date
26+
BarcodeType = EncodeTypes.HIBCDataMatrixLIC,
27+
LinkCharacter = '+',
28+
Data = new SecondaryAndAdditionalData
29+
{
30+
LotNumber = "LOT123",
31+
SerialNumber = "SN456",
32+
ExpiryDate = DateTime.Today.AddMonths(6),
33+
ExpiryDateFormat = HIBCLICDateFormat.MMDDYY,
34+
Quantity = 10,
35+
DateOfManufacture = DateTime.Today
36+
}
2937
};
3038

31-
// ------------------------------------------------------------
32-
// 2. Create the complex codetext object that combines the barcode type,
33-
// link character, and the secondary data defined above
34-
// ------------------------------------------------------------
35-
var hibcCodetext = new HIBCLICSecondaryAndAdditionalDataCodetext
39+
// Generate the barcode with a high image resolution (600 DPI)
40+
using (var generator = new ComplexBarcodeGenerator(secondaryCodetext))
3641
{
37-
BarcodeType = EncodeTypes.HIBCDataMatrixLIC, // Use HIBC DataMatrix LIC symbology
38-
LinkCharacter = '+', // Required link character for HIBC
39-
Data = secondaryData // Attach the secondary data
40-
};
42+
// Set the resolution property to 600 DPI
43+
generator.Parameters.Resolution = 600;
4144

42-
// ------------------------------------------------------------
43-
// 3. Generate the barcode with a resolution of 600 DPI and save it as PNG
44-
// ------------------------------------------------------------
45-
using (var generator = new ComplexBarcodeGenerator(hibcCodetext))
46-
{
47-
// Set both horizontal and vertical resolution to 600 DPI
48-
generator.Parameters.Resolution = 600f;
49-
50-
// Save the generated barcode image; PNG is the default format
51-
generator.Save("HIBC_DataMatrix_600DPI.png");
45+
// Save the generated barcode as a PNG file
46+
generator.Save("HIBC_DataMatrix_600dpi.png");
5247
}
53-
54-
// ------------------------------------------------------------
55-
// 4. Inform the user that the barcode has been generated
56-
// ------------------------------------------------------------
57-
Console.WriteLine("Barcode generated with 600 DPI resolution: HIBC_DataMatrix_600DPI.png");
5848
}
5949
}
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1+
// Title: Apply white background and black foreground to a QR HIBC LIC barcode
2+
// Description: Demonstrates generating a QR HIBC LIC barcode with high‑contrast colors for printing.
3+
// Category-Description: This example belongs to the Aspose.BarCode barcode generation category, focusing on complex barcode creation using the ComplexBarcodeGenerator and HIBCLICSecondaryAndAdditionalDataCodetext classes. It shows how to configure color parameters for QR HIBC LIC barcodes, a common requirement for clear, high‑contrast print output in healthcare and logistics applications. Developers often need to customize foreground and background colors when generating barcodes for scanners and label printers.
4+
// Prompt: Apply a white background and black foreground to a QR HIBC LIC barcode for high‑contrast printing.
5+
// Tags: barcode, hibc, qr, lic, color, background, foreground, generation, aspnet, aspose.barcode
6+
17
using System;
2-
using Aspose.BarCode;
3-
using Aspose.BarCode.Generation;
48
using Aspose.BarCode.ComplexBarcode;
9+
using Aspose.BarCode.Generation;
510
using Aspose.Drawing;
611

712
/// <summary>
8-
/// Demonstrates generation of a HIBC QR LIC barcode using Aspose.BarCode.
13+
/// Generates a QR HIBC LIC barcode with a white background and black foreground,
14+
/// illustrating color customization for high‑contrast printing scenarios.
915
/// </summary>
1016
class Program
1117
{
1218
/// <summary>
13-
/// Entry point of the application. Generates a HIBC QR LIC barcode and saves it as an image file.
19+
/// Entry point of the example. Creates secondary and additional data for a QR HIBC LIC barcode,
20+
/// sets color parameters, and saves the resulting image.
1421
/// </summary>
1522
static void Main()
1623
{
17-
// Prepare primary HIBC LIC data with product details and labeler code.
18-
var primaryCodetext = new HIBCLICPrimaryDataCodetext
24+
// Prepare secondary‑and‑additional data codetext for a QR HIBC LIC barcode
25+
var hibcCodetext = new HIBCLICSecondaryAndAdditionalDataCodetext
1926
{
20-
BarcodeType = EncodeTypes.HIBCQRLIC,
21-
Data = new PrimaryData
27+
BarcodeType = EncodeTypes.HIBCQRLIC, // QR version of HIBC LIC
28+
LinkCharacter = '+', // Required link character
29+
Data = new SecondaryAndAdditionalData
2230
{
23-
ProductOrCatalogNumber = "12345", // Product or catalog identifier
24-
LabelerIdentificationCode = "A999", // Labeler identification code
25-
UnitOfMeasureID = 1 // Unit of measure identifier
31+
LotNumber = "LOT123" // Example secondary data
2632
}
2733
};
2834

29-
// Create a ComplexBarcodeGenerator using the prepared primary data.
30-
using (var generator = new ComplexBarcodeGenerator(primaryCodetext))
35+
// Generate the barcode with specified colors
36+
using (var generator = new ComplexBarcodeGenerator(hibcCodetext))
3137
{
32-
// Configure visual appearance: white background and black bars.
33-
generator.Parameters.BackColor = Color.White;
34-
generator.Parameters.Barcode.BarColor = Color.Black;
38+
// Set foreground (barcode) color to black
39+
generator.Parameters.Barcode.BarColor = Aspose.Drawing.Color.Black;
3540

36-
// Save the generated barcode image to a PNG file.
41+
// Set background color to white
42+
generator.Parameters.BackColor = Aspose.Drawing.Color.White;
43+
44+
// Save the generated barcode image to a PNG file
3745
generator.Save("hibc_qr.png");
3846
}
39-
40-
// Inform the user that the barcode has been generated.
41-
Console.WriteLine("Barcode generated: hibc_qr.png");
4247
}
4348
}

0 commit comments

Comments
 (0)