seam pdf: an empty page is added
radmila Apr 29, 2009 11:26 AMHello,
I have just started working with seam pdf for generating differrent types of documents.
First of all I have to generate some reports which should have a header and a footer on each page (even the first page). The header and the footer are common for all documents, therefore I have 2 files, one for header and the second for footer.
testHeader.xhtml:
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://jboss.com/products/seam/pdf"> <p:table columns="2" widths="3 1" widthPercentage="100" spacingAfter="5"> <f:facet name="defaultCell"> <p:cell borderWidth="0"/> </f:facet> <p:cell horizontalAlignment="left"> <p:html lang="ro"> <font size="8px" face="helvetica" encoding="iso-8859-2"> Unit: <br/> Address: #{currentContext.currentUser.userCompany.address}<br/> Phone: #{currentContext.currentUser.userCompany.phone}<br/> </font> </p:html> </p:cell> <p:cell horizontalAlignment="right" verticalAlignment="middle"> <h:panelGroup rendered="#{currentContext.currentUser.userCompany.logo != null}"> <p:image value="#{global.getInputStream(currentContext.currentUser.userCompany.logo)}" height="150" width="200"/> </h:panelGroup> </p:cell> </p:table> </f:view>
testFooter.xhtml
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://jboss.com/products/seam/pdf"> <p:font size="10" name="helvetica" encoding="iso-8859-2">Generated by 11111111                                                   - <p:pageNumber/> -</p:font> </f:view>
The first problem encountered is the header. It seams that the header is not displayed on the first page if I use p:header
. To overcome this problem I use ui:include
twice in my document, the first one is for the first page and the second one is in p:header
(for all the other pages). The next code block illustrates my approach:
<ui:include src="testHeader.xhtml" /> <p:header borderWidthTop="0" borderWidthBottom="0" alignment="left"> <ui:include src="testHeader.xhtml" /> </p:header> <f:facet name="header"> <p:footer borderWidthTop="0.1" borderWidthBottom="0" alignment="left"> <ui:include src="testFooter.xhtml" /> </p:footer> </f:facet>
I have checked the documentation regarding headers and footers and it states The p:header and p:footer components provide the ability to place header and footer text on each page of a generated document, with the exception of the first page.
I have also checked the examples, but I haven't found any example with both header and footer in the same document. Is there other way (except the 2 includes) to put a header on every page?
The second observation is concerning the empty page added after the last page with content. In my opinion in the last page with content there is enough space for 3 more lines with text and another page should not be created. The empty page contains only the header and the footer. Is this a limitation of seam pdf?
I will not post here a test file which illustrates the second observation because it is pretty big, but I can provide it via e-mail.