PDF jet

Using the BarCode2D class to draw PDF417 barcode


Example_12.pdf
import java.io.*;

import com.pdfjet.*;


/**
 *  Example_12.java
 *
 */
public class Example_12 {

    public static void main(String[] args) throws Exception {

        FileOutputStream fos = new FileOutputStream("Example_12.pdf");

        PDF pdf = new PDF(fos);

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

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

        StringBuilder buf = new StringBuilder();
        BufferedReader reader =
                new BufferedReader(new FileReader("Example_12.java"));
        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();
        fos.close();
    }

}   // End of Example_12.java

© 2017 Innovatics Inc.