Wednesday, 12 November 2014

How to generate PDF report using iText java API

package Flowell.Flowell1;

import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;


public class iTextPDFTutorial {
    public void iTextPDF() throws Exception{
        String FILE = "C:/Users/Youtility/Desktop/sampleiText.pdf";
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(FILE));
        document.open();
        document.add(new Paragraph("Hello iText"));
        document.add(new Paragraph("I will be printed in PDF with the help of iText"));
        document.close();
           
    }
   
    public static void main(String args[]){
        iTextPDFTutorial get = new iTextPDFTutorial();
        try {
            get.iTextPDF();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

No comments:

Post a Comment