Using the BarCode class to draw Code128 barcodes

using System;
using System.IO;
using System.Collections;using System.Collections.Generic;

using PDFjet.NET;


/**
 *  Example_11.cs
 *
 */
public class Example_11 {

    public Example_11() {
        PDF pdf = new PDF();
        Font f1 = new Font(pdf, "Helvetica");

        Page page = new Page(pdf, Letter.PORTRAIT);
        BarCode code = new BarCode(
                BarCode.CODE128, "Hello, World!");
        code.SetPosition(170.0, 70.0);
        code.SetModuleLength(1.00);
        code.SetFont(f1);
        code.DrawOn(page);
        code = new BarCode(
                BarCode.CODE128, "G86513JVW0C");
        code.SetPosition(170.0, 170.0);
        code.SetModuleLength(0.75);
        code.SetDirection(BarCode.TOP_TO_BOTTOM);
        code.SetFont(f1);
        code.DrawOn(page);
        pdf.Wrap();
        pdf.Save("Example_11.pdf");
    }


    public static void Main(String[] args) {
        try {
            new Example_11();
        } catch (Exception e) {
            Console.WriteLine(e.StackTrace);
        }
    }

}   // End of Example_11.cs
Example_11.pdf

© 2007 Innovatics Inc.