Machine generation of PDF files the easy way – final piece

This is essentially a refinement of the previous steps. I have added a lot of new list data but instead of being limited to what political party they are in or even if they like to party, I have extended this a bit. The final result will generate a form and will look like this.

data7

Now “party” data field is actually much more generic. It can be whatever is described in the xml file itself.

     <being>
        <first> Hooch  </first>
        <last>  </last>
        <party> Dogue de Bordeaux </party>
        <additionaldesc> breed </additionaldesc>
     </being>

Note: Lazy programmer syndrome. The proper thing to do would have been to rename the party field to a more neutral name.

Thus it is possible to use the additionaldesc field to contain a better name for that cell.

It really isn’t necessary but I have added a header to each list. What is in each header is hard-coded but it does serve to provide an interesting reminder about the support that is provided. Simply by defining this table-header it will be displayed each time the table is broken by a page break.

Also the footer has been modified to display a page number. Generating a page number is not difficult but it also provides the trick to display the total number of pages as well. This is neat because the xslt script is data driven, it has no idea how many pages exist when it is run.

The second change to the footer probably seems unnecessary at first glance. I have added a table so I can display my text left justified and the page number right justified. Normally you would think that simply adding the text-align to the block would be enough, and in one sense it is. When I first did this example it kinda worked. The text was left justified on one line and the page number was right justified on the next line. In order to have both of these pieces of text on the same line I needed to create a table in the footer.

There is really a lot more that could be done using XSL-FO but that will have to be left to another time.

Download source and pdf for this example

Download everything.

This entry was posted in programming and tagged , , , . Bookmark the permalink.