I'm using Java, JPA, Wildfly and Primefaces. I have a table with several columns and rows, how do I print (report) each row of the table? each line will have its print icon and I would like to know how to send each line to the printer.
I'm using Java, JPA, Wildfly and Primefaces. I have a table with several columns and rows, how do I print (report) each row of the table? each line will have its print icon and I would like to know how to send each line to the printer.
Use the p: dataExporter component of PrimeFaces. It allows you to easily export data from a datatable into EXCEL, PDF, CSV and XML formats.
Here's an example of its use on the PrimeFaces website: link
PDF has a very simple formatting, but you can configure some basic things programmatically, such as margin and orientation:
public static void formatarRelatorioPdf(Document pdf) {
pdf.setMarginMirroringTopBottom(false);
pdf.setPageSize(PageSize.A4.rotate());
pdf.setMargins(-102, -102, 2, 2);
}
Note: The com.lowagie.text.Document class belongs to lib itext .
To make more elaborate PDF documents, you can do them using Jasper Reports and iText or make them in HTML. In both ways you will need research and a little study, but the result is great. I recommend the first option because HTML reports sometimes get some difference between bowsers.
I hope you have helped!