title: i text jsp output to pdf
body: <p>i m trying to use the itext to convert the jsp output to pdf format
  using itext and i dnt have much knowledge in java i m just starting the
  programming please help me to convert the jsp output  to pdf</p>
  
  <p>i had tried some one example but its converting the jsp code to pdf but not the jsp out put
  here is my code </p>
  
  <pre><code> import com.lowagie.text.Document;  
   import com.lowagie.text.Paragraph;  
  import com.lowagie.text.Rectangle;
  import com.lowagie.text.pdf.PdfWriter;  
   import java.io.File;  
   import java.io.FileOutputStream;  
   public class PDFConversion  
   {  
  
    private void createPdf(String inputFile, String outputFile, boolean isPictureFile)  
   {  
  
        Rectangle pageSize = new Rectangle(2780, 2525);  
       Document pdfDocument = new Document(pageSize);  
        String pdfFilePath = "C:\\Users\\hp\\Desktop\\jsp_to_pdf.pdf";  
        try  
        {  
            FileOutputStream fileOutputStream = new FileOutputStream(pdfFilePath);  
           //PdfWriter writer = null;  
           PdfWriter writer = PdfWriter.getInstance(pdfDocument, fileOutputStream);  
            writer.open();  
            pdfDocument.open();  
  
             if (isPictureFile)  
            {  
             pdfDocument.add(com.lowagie.text.Image.getInstance("C:\\Users\\hp\\Documents\\NetBeansProjects\\pdf_print\\web\\example1.jsp"));  
            }  
  
            else  
            {  
            File file = new File("C:\\Users\\hp\\Documents\\NetBeansProjects\\pdf_print\\web\\example1.jsp");  
            pdfDocument.add(new Paragraph(org.apache.commons.io.FileUtils.readFileToString(file)));  
            }  
            pdfDocument.close();  
            writer.close();  
        }  
        catch (Exception exception)  
        {  
         System.out.println("Document Exception!" + exception);  
        }  
     }  
     public static void main(String args[])  
  
     {  
  
      PDFConversion pdfConversion = new PDFConversion();  
  
  
  
  
  
  
       pdfConversion.createPdf("example1.jsp","jsp_to_pdf.pdf", false);  
  
      }  
  
   } 
  </code></pre>
  
  <p>thanks&amp;regards
  shadab akram khan</p>