Finaly i got the solution here is the code
In the action class
public String ExportPDF()
{
tablestruct = ""+tablestruct+"";
//System.out.println("After concat "+tablestruct);
try{
String filePath = ServletActionContext.getServletContext().getRealPath("/testpdf.pdf");
System.out.println(filePath);
Document document=new Document(PageSize.LETTER);
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(filePath));
document.open();
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.parse(new StringReader(tablestruct));
document.close();
System.out.println("Done");
File file = new File(filePath);
inputStream = new DataInputStream( new FileInputStream(file));
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}