PDF jet

Using the BarCode2D class to draw PDF417 barcode


Example_12.pdf
using System;
using System.IO;
using System.Text;

using PDFjet.NET;


/**
 *  Example_12.cs
 *
 */
public class Example_12 {

    public static void Main(String[] args) {

        FileStream fos = new FileStream("Example_12.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);

        Font f1 = new Font(pdf, "Helvetica");

        Page page = new Page(pdf, Letter.PORTRAIT);

        StringBuilder buf = new StringBuilder();
        StreamReader reader = new StreamReader(
                new FileStream("Example_12.cs", FileMode.Open));
        String line = null;
        while ((line = reader.ReadLine()) != null) {
            buf.Append(line);
            // Both CR and LF are required by the scanner!
            buf.Append((char) 13);
            buf.Append((char) 10);
        }
        reader.Close();

        BarCode2D code2D = new BarCode2D(buf.ToString());
        code2D.SetPosition(100.0f, 60.0f);
        code2D.DrawOn(page);

        TextLine text = new TextLine(f1,
                "PDF417 barcode containing the program that created it.");
        text.SetPosition(100.0f, 40.0f);
        text.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }

}   // End of Example_12.cs

© 2017 Innovatics Inc.