Java Magazine, July/August 2018
Figure 2 Data set rendered to a PDF table ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 19 libraries In the code of Listing 2 we created a PdfDocument instance just like we did in Listing 1 Then we did the following The page size of the page we created in our first example was A4 which is the standard size for documents outside of the US In this example we wanted to create a document with pages in the Letter size in landscape orientation We passed this page size information as the second parameter when we created the high level Document object We also reduced the default margins to 12 points We organized all the content into a Table with nine columns We defined the width of each column using a relative width For instance the first column is four times as wide as the second column The total width of the table is defined as 100 of the available width on the page taking into account a margin of 12 points to the right and 12 points to the left The table has a header for which we wanted to use a diferent style Therefore we created a Style object that caused text to be written in bold and to be aligned in the center of its container We read the CSV file line by line using a BufferedReader We processed the first line the header using the header style We looped over the rest of the lines and processed them without defining a style
You must have JavaScript enabled to view digital editions.