I'm trying to export some auto generated HTML that is in a JavaScript var with iTextPdf in the java code, but I don't know how it works, because I've got an String in the var and I don't know how to Export it. This is my HTML code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table>
<tr>
<td></td>
<td colspan="4" align="center">Filtros de Busqueda</td>
</tr>
<tr></tr>
<tr>
<td colspan="2">Proveedor</td>
<td colspan="14">OCA - OCA</td>
</tr>
<tr>
<td colspan="2">Sector</td>
<td colspan="14">Sin Sector  </td>
</tr>
</table>
</body>
</html>
All this code in in a javascript var I'm sending it by a submit and in the action I'm doing this
Document document = new Document(PageSize.A4, 10, 10, 10, 10);
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(filePath + fileName + ".pdf"));
document.open();
StringReader reader = new StringReader(buffer);
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
worker.parseXHtml(pdfWriter, document, reader);
document.close();
pdfWriter.close();
pdfWriter = null;
System.gc();
response.setContentType("application/vnd.pdf");
response.setHeader("Content-Disposition",
"attachment;filename=\"" + fileName + "." + fileType
+ "\"");
PrintWriter out = response.getWriter();
out.print(buffer);
out.close();
For some reason this isn't working, my first tought was that it can't convert an string. Is there anything wrong in the code?