import java.io.*;
import com.pdfjet.*;
/**
* Example_11.java
*/
public class Example_11 {
public Example_11() throws Exception {
PDF pdf = new PDF(new FileOutputStream("Example_11.pdf"));
// Font f1 = new Font(pdf, CoreFont.HELVETICA);
Font f1 = new Font(pdf,
new BufferedInputStream(getClass().getResourceAsStream(
"/fonts/DroidFonts/DroidSans.otf")),
CodePage.UNICODE,
Embed.YES);
Page page = new Page(pdf, Letter.PORTRAIT);
BarCode code = new BarCode(BarCode.CODE128, "Hello, World!");
code.setPosition(170.0f, 70.0f);
code.setModuleLength(0.75f);
code.setFont(f1);
code.drawOn(page);
code = new BarCode(BarCode.CODE128, "G86513JVW0C");
code.setPosition(170.0f, 170.0f);
code.setModuleLength(0.75f);
code.setDirection(BarCode.TOP_TO_BOTTOM);
code.setFont(f1);
code.drawOn(page);
code = new BarCode(BarCode.CODE39, "WIKIPEDIA");
code.setPosition(270.0f, 370.0f);
code.setModuleLength(0.75f);
code.setFont(f1);
code.drawOn(page);
code = new BarCode(BarCode.CODE39, "CODE39");
code.setPosition(400.0f, 70.0f);
code.setModuleLength(0.75f);
code.setDirection(BarCode.TOP_TO_BOTTOM);
code.setFont(f1);
code.drawOn(page);
code = new BarCode(BarCode.CODE39, "CODE39");
code.setPosition(450.0f, 70.0f);
code.setModuleLength(0.75f);
code.setDirection(BarCode.BOTTOM_TO_TOP);
code.setFont(f1);
code.drawOn(page);
code = new BarCode(BarCode.UPC, "712345678904");
code.setPosition(450.0f, 270.0f);
code.setModuleLength(0.75f);
code.setDirection(BarCode.BOTTOM_TO_TOP);
code.setFont(f1);
code.drawOn(page);
pdf.complete();
}
public static void main(String[] args) throws Exception {
new Example_11();
}
} // End of Example_11.java
© 2023 Innovatics Inc.