Creating, Printing, Exporting Barcodes - with List & Label in .NET/C#

Introduction

Barcodes are machine-readable symbols used in many processes across a wide range of industries for quick identification. First used primarily in the manufacturing industry, barcodes are now present in many ways in everyday life. For example, when scanning goods at the supermarket checkout or franking postal items. As the range of uses has increased, so have the variants of barcodes. Barcodes are divided into different types such as barcodes or 2D codes and have names like Code128, QR-Code, PDF417, Datamatrix or EAN-13.

With List & Label, our reporting component for software development, you can use barcodes in numerous formats. The portfolio of barcodes is constantly expanding. Meanwhile List & Label belongs to the leading reporting tools with a wide range of different barcode formats for any solutions and requirements. Just to name a few:

  • Aztec
  • Code39
  • Codablock F
  • Datamatrix
  • EAN128
  • GS1
  • Maxicode
  • FIM
  • ISBN
  • Premiumadress
  • PDF417 + MicroPDF417
  • Pharmacode
  • QR-Code
  • Royal Mail
  • and many more

A list of all supported barcode formats can be found in the overviews for General 1D Codes, Postcodes (1D and 2D Codes) and General 2D Codes. But how can these barcodes be created with List & Label and which requirements are necessary?

Prerequisites for List & Label barcodes

In order to use the barcodes, List & Label must be integrated as a component in your own application. The .NET Tutorial shows how fast and easy this can be done. Then call the integrated List & Label Report Designer using the Design() method to create your own template for a report with barcodes.

No special barcode font needs to be purchased for any barcode and there are no runtime fees. List & Label draws the barcodes completely by itself according to the respective standard. We have verified the quality and conformity of the barcodes through a cooperation with REA, a renowned vendor of barcode verifiers.

Specialized in print optimization

One feature that clearly sets List & Label apart from other products is the optional print optimization for optimal barcode pixel alignment. This ensures that when printing on a physical printer, the quality of the barcode is adjusted depending on the output device pixels. This avoids rounding errors and ensures readability.

Note: List & Label is offered in different editions for varying requirements, 2D barcodes are included from the Professional Edition.

Create and define barcodes

But how can the barcodes now be created with List & Label - both interactively through the Report Designer or even controlled through the source code?

In the Report Designer

The easiest way to create any barcode is directly in the Designer. Here there is the barcode object that can be easily inserted from the ribbon:


Barcode in Report Designer: use as static text

For the Text option, you then simply select the desired content for the barcode to be encoded. However, its formatting depends on the selected barcode (here: QR code). Thus, fixed or static texts could be used as barcodes. But for more dynamics and flexibility and also depending on the declared data source in List & Label, a formula can also be determined using the designer function Barcode() to define the content of a barcode and its type:


Barcode in Report Designer: use as formula

In the source code (with .NET component in C#)

The Report Designer is used here as well. Directly from the registered data source it is specified that the data should be registered predefined as a certain barcode type. This way, users do not have to take care of formatting the barcode themselves. The process can be specified by the application itself in the source code and significantly reduces the complexity from later end users. For this purpose, the class LlBarcode is available when programming in C#, whose properties determine the Content and the Type of the barcode. Example:

LlBarcode myBarcode = new LlBarcode("EXPSA01", LlBarcodeType.EAN128);
LL.Variables.Add("Item.No_EAN128", myBarcode);

In the Designer itself, users only see that a barcode variable with the name Item.No_EAN128 is available. This can now be easily placed in the report via drag & drop:


*Barcode in the report designer: use as variable

Tip: Using the data binding events AutoDefineField/AutoDefineVariable the field/variable types can also be easily changed at runtime in your own program code. Example:

LL.AutoDefineVariable += LL_AutoDefineVariable;
LL.Design();
 
private void LL_AutoDefineVariable(object sender, AutoDefineElementEventArgs e)
{
    if(e.Name == "Item.No_EAN128")
    {
        e.FieldType = LlFieldType.Barcode_EAN128;
    }
}

In the source code via DOM API without designer (with .NET component in C#)

List & Label offers another elegant way to create and modify a report: With the so-called Document Object Model (DOM) API, a report can be created completely in source code. This way it is also possible to modify existing reports. With the help of the class ObjectBarcode via the AddNewBarcode() method, barcodes are simply added without the Report Designer becoming visible even once. Example:

private void GenerateBarcodeObject()
{
    try
    {
        // Create new DOM project, type LlProject.List
        using (ProjectList proj = new ProjectList(LL))
        {
            // Set file name and file access options
            proj.Open(Path.Combine(Application.StartupPath, "dynamic.lst"), LlDomFileMode.Create, LlDomAccessMode.ReadWrite);
 
            // Get the coordinates for the first page
            Size pageExtend = proj.Regions[0].Paper.Extent.Get();
 
            // Add a barcode object
            ObjectBarcode llobjBarcode = proj.Objects.AddNewBarcode();
            llobjBarcode.Source.BarcodeType = LlBarcodeType.EAN128;
            llobjBarcode.Source.Text = "EXPSA01";
            llobjBarcode.WithText = "true";
            llobjBarcode.Position.Set(pageExtend.Width - 50000, 10000, pageExtend.Width - (pageExtend.Width - 40000), 27000);
 
            proj.Save();
        }
    }
    catch (ListLabelException LlException)
    {
        // Catch Exceptions
        MessageBox.Show("Information: " + LlException.Message + "\n\nThis information was generated by a List & Label custom exception.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}

Print or Export barcodes

Once the report is created using the Report Designer or DOM API, another strength of List & Label comes into play - the numerous export options. The report with the barcodes can be output in many ways:

  • classically to any printer
  • in document formats such as PDF, Word (DOCX), Excel (XLSX) etc.
  • in graphic formats for easy further processing like PNG, SVG, JPEG etc.


Output setting: Format selection in List & Label

Printing or exporting is performed and controlled from your own application using the List & Label component in the source code via the Print() and Export() methods. This is thoroughly explained in the .NET Tutorial in the chapter Design, Print and Export.

Tip: For image export formats like PNG or JPEG, the helpful Export Options Picture.CropFile and Picture.CropFrameWidth are available to remove an unnecessary white frame from labels/barcodes.

Examples of special barcodes in List & Label

List & Label offers a wide range of different barcodes that can be used for various requirements in any field of application, such as payment transactions, shipping (via forwarding agents), processes in the medical/pharmaceutical sector, as ISBN in publishing, and many more.

Swiss QR code

In swiss payment transactions, the so-called Swiss QR code is required, which must have the Swiss cross in the middle. The article Print Swiss QR Invoice with List & Label contains a sample report for the Report Designer for this purpose and is based on a typical sample invoice.
grafik
QR code with Swiss cross

Individual QR codes with company or product logo

Instead of the Swiss cross in the abovementioned Swiss QR code, it is also possible to place your own company or product logo in the QR code. This way, the corporate identity, for example on letter paper, can be shown to even better advantage.
grafik
QR code with product logo

EPC QR codes for SEPA Credit Transfers

In the international payment traffic, QR codes can also be created for SEPA transfers, which is exemplified in the article Creating EPC Barcodes with List & Label.

Feel free to leave us a comment if you have implemented other interesting or special requirements with List & Label in the barcode area.

Test barcodes with the Trial

To quickly get an idea of List & Label’s barcode capabilities download our free List & Label Trial.

© combit GmbH