import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Image; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.BarcodePDF417; import com.lowagie.text.pdf.PdfWriter; public class PDF417 { public static void main(String[] args) { int errorLevel = 8; int codeColumns = 50; int codeRows = 50; int aspectRatio = 3; int yHeight = 3; int imgPercent = 100; Document document = new Document(); try { // step 2: // we create a writer @SuppressWarnings("unused") PdfWriter writer = PdfWriter.getInstance( // that listens to the document document, // and directs a PDF-stream to a file new FileOutputStream("i://barcodes.pdf")); // step 3: we open the document document.open(); // PDF417 document.add(new Paragraph("Settings includes rows and columns: EL="+errorLevel+" CC="+codeColumns+" CR="+codeRows+" AR="+aspectRatio+" YH="+yHeight+" IP="+imgPercent)); BarcodePDF417 pdf417 = new BarcodePDF417(); String text = "Testing Java Barcode is not that bad If CAPTIVA could only read more than 259 characters. Testing Java Barcode is not that bad If CAPTIVA could only read more than 259 characters. Testing Java Barcode is not that bad If CAPTIVA could only read more than 259 characters."; pdf417.setErrorLevel(errorLevel); pdf417.setCodeColumns(codeColumns); pdf417.setCodeRows(codeRows); pdf417.setAspectRatio(aspectRatio); pdf417.setYHeight(yHeight); pdf417.setText(text); System.out.println(pdf417.getText()); Image img = pdf417.getImage(); img.scalePercent(imgPercent, imgPercent * pdf417.getYHeight()); document.add(img); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5: we close the document document.close(); } }