
hello
i am displaying one table on my jsp page and i want to save that table in pdf file can u please help me???
please reply as soon as possible

1)createPDF.jsp
<html>
<form name="form" method="post" action="pdf.jsp">
<table border="1">
<tr><td>Name</td><td>Address</td></tr>
<tr><td><input type="text" name="name"></td><td><input type="text" name="address"></td></tr>
<tr><td><input type="text" name="name"></td><td><input type="text" name="address"></td></tr>
<tr><td><input type="text" name="name"></td><td><input type="text" name="address"></td></tr>
<tr><td><input type="text" name="name"></td><td><input type="text" name="address"></td></tr>
</table>
<input type="submit" value="Submit">
</form>
</html>
2)pdfTable.jsp:
<%@page import="java.io.*"%>
<%@page import="com.lowagie.text.*"%>
<%@page import="com.lowagie.text.pdf.*"%>
<%
String name[]=request.getParameterValues("name");
String address[]=request.getParameterValues("address");
try{
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("C:/data.pdf"));
document.open();
PdfPTable table=new PdfPTable(2);
table.addCell("Name");
table.addCell("Address");
for(int i=0;i<name.length;i++){
table.addCell(name[i]);
table.addCell(addres[i]);
}
document.add(table);
document.close();
}
catch(Exception e){}
%>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.