+ Start a Discussion

Page Header in PDF render of large dataTable

Hi there,

Has anyone figured out how to put a rich (not just plain text) page header on a VisualForce page that is being rendered as PDF? 

I have a VF page which is essentially a pretty report output - just a large dataTable that spans many pages.  I am using the 'headerValue' attribute to set the column headers at the top of the dataTable which works very well.  However, I need these column headers to show up on the top of every page that is created in the PDF. 

I have looked in depth at the @page CSS stuff that VF supposedly implements, but cannot find anything that would let me use any actual HTML/CSS for the header.

VisualForce PDF gurus - any ideas???   Has anyone put page headers on the top of every rendered PDF page?

Mark YoungMark Young

From what I've seen the VisualForce PDF output is just a PDF print of the Html page.

This being the case, the only way I know of to do this is to implement paging inside your page controller (so you print a page header, then 20 rows, then a page break, then page header, 20 rows, page break, ad infinitum...)

Alternatively, you might need to try custom pdf generation through a webservice etc.  Or try one of the services on the AppExchange such as LOOP.

hi Mark, thanks for the reply.

yeah, i think you are right, and so far that has been my experience.    

However, i saw in another post somewhere that Ron Hess mentioned that Visual Force supports the CSS @page stuff.  I think (hope)  he means this stuff: http://www.w3.org/TR/css3-page/.    In here they talk about implementing page headers and footers using something called 'margin boxes'.  

I have been able to get it to work for a simple text footer, but am having problems getting any markup or anything formatted into the header. Frankly, this is stretching my CSS knowledge and I was hoping someone had gone through this successfully already.

Message Edited by gireeshz on 07-14-2008 10:29 AM

Message Edited by gireeshz on 07-14-2008 10:31 AM
Mark YoungMark Young

Ah, sorry gireeshz,

I haven't had much of a look at the @page tags, but it looks like it's not 100% supported.  I can get plain text to show in a page header (i.e.):

@page {
    @top-center { content: "Test Content" }

but am unable to flow a div into it to insert html (i.e.):

@page {
    @top-center { content: flow(header); }
.testBlock { flow: static(header); }

<div class="testBlock">
This should be header text

 Would be keen to know if you have any luck with it.





yes, this is precisely the wall i came up against.   Just cannot seem to get it into a div or anything that will allow some formatting. 

apparently, the 'content' property will allow an URL or an image as well.  this probably won't work for what I need but it might help you out.

Unfortunately  rendering content as pdf  does not support the generation of headers (and footers) as you would like.  We are looking into why this is so. Please submit an ideaexchange idea for support of html headers and footers.