PLEASE PROVIDE ME A WAY TO PUT A JSP OUTPUT IN PDF FILE........

ACTUALLY WHAT I M DOING IS THAT.........
There is a JSP page which displays charts (bar,pie) of students (name and marks ) from database ,,i want that this chart output also display in PDF file...
pls help

HEy Peter can you pls provide me the CODE ,i tried through itext but didnt get along..
so pls help buddy ...provide me the code to trnsfer JSP output in PDF

I have better idea. Show us code you tried, including any error messages you may got and we may try to help you.

HEy Peter can you pls provide me the CODE ,i tried through itext but didnt get along..
so pls help buddy ...provide me the code to trnsfer JSP output in PDF

You can use PDFPtable for table formatting

we cant convert jsp in to pdf .
you have to render the ur output in pdf format using iText.jar
search pdf using itext u will get ur solution

we cant convert jsp in to pdf .
you have to render the ur output in pdf format using iText.jar
search pdf using itext u will get ur solution

That is what I already suggested in 2nd post, however sanjayrawat177 never came back...

I am posting here my code which display pdf.
I m using struts 1.2 this method generate pdf.
I have used iText jar

public ActionForward print(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response) 
                  throws IOException, ServletException {
	 
	 try{
 /** set content type as PDF */

		 response.setContentType("application/pdf");
 /** create Object Of document */

		 Document document = new Document(PageSize.FLSE);
		 /** set margin of page */
		document.setMargins(1.25F,0.75F, 5F,0.75F);

 ByteArrayOutputStream baos = new ByteArrayOutputStream();
		 
		 PdfWriter pdfWriter=PdfWriter.getInstance(document, baos);

 document.open();

 /** Table For header address */

		 PdfPTable headerTable =new PdfPTable(3);
		 headerTable.setWidthPercentage(91);

		 /** Add company Address*/ 

		 /** First Cell  For address*/

		 PdfPCell headerCell=new PdfPCell();
		 headerCell.addElement(new Paragraph("My comapany"));

		 /** add cell to headerTable*/

		 headerTable.addCell(headerCell);


		 /** Second cell For CompanyLogo */

		 headerCell=new PdfPCell();
		 /** get context object */

		 ServletContext context=request.getSession().getServletContext();
		 /** get Real  Path of image */ 

		 String path=context.getRealPath(login.getPath());
		 /** set image to cell*/

		 Image img= Image.getInstance(path);
		 headerCell.setImage(img);

		 /** add cell to headerTable*/

		 headerTable.addCell(headerCell);

		 /** Third cell for lable of document **/

		 headerCell=new PdfPCell();
		String allLedger="ALL LEDGER";
		headerCell.addElement(new Paragraph(allLedger+"\n"
			 +"From Date:"+session.getAttribute("firstDate")+"\nTo Date:"+session.getAttribute("lastDate")
			 ,new Font(Font.TIMES_ROMAN, 10f, Font.BOLD, Color.black )));
		
		 /** add cell to headerTable*/
		
		headerTable.addCell(headerCell);

 /** add table to document */
	 
	 document.add(headerTable);
 document.close();
	 /** Don't know why??*/
	 response.setContentLength(baos.size());
	 /** comment it if u don't want to download pdf*/
	//response.addHeader("Content-Disposition", "attachment; filename=\"ledgers.pdf\"");
	
	 /** get out put Stream*/
	 out = response.getOutputStream();
	 /** write to--- Don't know*/
	 baos.writeTo(out);
	/** Clear OutputStream*/
	 out.flush();
	 out.close();
	   
	 	
	 }catch (Exception e) {
		System.err.println("exception in print=="+e.getMessage());
	}
	       
        	  return mapping.findForward("printJsp55");
        }

It generate pdf whic u can use to print.
you can add your data to PdfPTable.
This is the best way to generate pdf.

Hi Every body thanks for replying for my question........
I was out of town thats y not came to net,,,...
I want to show my Fusion charts which r displaying on JSP page to the PDF file....
In new version of Fusion charts 3.1 there is fuctionality to export them in type of format ... but my fusion chart r of 3.0 version....which dont have this functionality.......
and i have a reason behind using older version of fusion chart....
so psl suggest me the way to export my old version of fusion chart to PDF file....

thanks..

This article has been dead for over six months. Start a new discussion instead.