tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Barcodes > iText > QR Code Barcode

QR Code Barcode 

iText is a free and open source library for creating PDF documents and generating Barcodes in Java. This requires the library iText-5.0.2.jar to be in classpath. The following example shows generating QR Code Barcode.

File Name  :  
com/bethecoder/tutorials/itext/QRCodeTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.itext;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BarcodeQRCode;
import com.itextpdf.text.pdf.PdfWriter;

public class QRCodeTest {

  /**
   @param args
   @throws DocumentException 
   @throws FileNotFoundException 
   @throws UnsupportedEncodingException 
   */
  public static void main(String[] argsthrows FileNotFoundException, 
    DocumentException, UnsupportedEncodingException {
    
    Document document = new Document(new Rectangle(PageSize.A4));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("qrcode.pdf"));
    document.open();

    //QR Code Barcode
    document.add(new Paragraph("QR Code Barcode"));
        
    BarcodeQRCode qrcode = new BarcodeQRCode(
        "IText Barcode tutorials from BE THE CODER"00null);
    Image image = qrcode.getImage();
    
    //Add Barcode to PDF document
        document.add(image);
        document.close();
  }

}
   

It gives the following output,

QR Code Barcode


                    Print

   



Books Recommendation

 
 
bl  br