Print table row "datatable"

Asked

Viewed 298 times

0

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.

1 answer

0

Use the component p:dataExport of Primefaces. It enables you to easily export data from a datatable to EXCEL, PDF, CSV and XML formats.

Here is an example of its use on the Primefaces website: http://www.primefaces.org/showcase/ui/data/dataexporter/basic.xhtml

PDF has a very simple format, but it is possible to 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 class with.lowagie.text.Document belongs to lib itext.

To make more elaborate PDF documents, you can make them using Jasper Reports and iText or make them into HTML. Both ways will require research and a little study, but the result is great. I recommend the first option because reports in HTML sometimes gets some difference between Bowsers.

I hope it helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.