Java Magazine, July/August 2018
Converting HTML Data to PDF Suppose that you already have in the form of an HTML file all the data you want to render as a PDF file Figure 4 shows a web page in a browser listing all the states of the US with white text on a black background for the header row and an alternating background for the data rows If you look inside the HTML file that we used in Figure 4 shown in Listing 4 you can see that text and background colors are defined using CSS You can also see that the page size orientation and a footer are defined using an @ page rule When printed each page would have a footer labeled Page X of Y where X is the current page number and Y is the total number of pages Listing 4 HTML and CSS to render data in a browser html head meta http equiv Content Type content text html charset windows 1252 style th background black color white tr nth child even background C0C0C0 @ page size A4 landscape @ bottom right ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 23 libraries Figure 4 US states shown in a browser
You must have JavaScript enabled to view digital editions.