4
Good afternoon, I would like a help regarding generating a pdf report in java. Well I am using the first faces to export this report. I created the first line with the fields as you can see in the image below, but when automatically exporting generates also this second line, taking it from my datatable, how do I leave only the line I created? because I don’t want the one that comes from datatable to appear. Thank you
this is my bean I’m making to generate my pdf.
public void preProcessPDF(Object document) throws DocumentException, BadElementException, IOException {
Document pdf = (Document) document;
pdf.setPageSize(PageSize.A4.rotate());
pdf.open();
PdfPTable table = new PdfPTable(8);
table.addCell(new PdfPCell(new Phrase("Rodovia")));
table.addCell(new PdfPCell(new Phrase("Callbox")));
table.addCell(new PdfPCell(new Phrase("Tipo")));
table.addCell(new PdfPCell(new Phrase("Versão Firmware")));
table.addCell(new PdfPCell(new Phrase("Endereço IP")));
table.addCell(new PdfPCell(new Phrase("Ramal/Numero")));
table.addCell(new PdfPCell(new Phrase("Ativo")));
table.addCell(new PdfPCell(new Phrase("Status")));
Font catFont = new Font(Font.TIMES_ROMAN, 18, Font.BOLD);
Paragraph p = new Paragraph("Relatório", catFont);
p.setAlignment(Element.ALIGN_CENTER);
p.setSpacingAfter(20);
pdf.add(p);
pdf.add(table);
}
<h:commandLink>
<i class="fa fa-file-pdf-o fa-fw"/> #{bundle['system.ui.label.export.pdf']}
<p:dataExporter type="pdf"
encoding="iso-8859-1"
target="callbox_datatable"
preProcessor="#{callboxBean.preProcessPDF}"
/>
</h:commandLink>
but if I do this, in addition to hiding my line, it will hide my data too, and that’s not what I want, I want to remove the line in which it creates itself, and put my personalized.
– Ivan
You’re right @Ivan Have a look at this picture: http://stackoverflow.com/questions/16574259/dataexporter-pdf-header-position might help
– Pedro Teles