You need to sign in to do that
Don't have an account?

PDF Headers and Footers from Controller
I've started to use CSS to generate headers and footers for my visualforce pdfs, as below:
Is it at all possible to generate these headers and footers from information in my controller? So, for example, I can add the name of a record in my page header. I've noticed in CSS3 you can use 'string-set' but this doesn't seem to work (or I don't know how to work it properly).
Anyone have any insight into this?
Code:
@page { @top-right { content: "My Header"; } @bottom-right { content: "My Footer"; } }
Is it at all possible to generate these headers and footers from information in my controller? So, for example, I can add the name of a record in my page header. I've noticed in CSS3 you can use 'string-set' but this doesn't seem to work (or I don't know how to work it properly).
Anyone have any insight into this?
Although I don't think it was meant to work this way, it seems you can wrap the style-element in a head-element within your visual force page. Then it is possible to use dynamic data in the @page section.
See example below:
All Answers
Maybe if I could get @page to work inside style tags then it'll solve my problem - any ideas?
Message Edited by XactiumBen on 11-07-2008 02:11 PM
This is something i have been banging my head against for a while. Check out these other threads for more info:
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3908#M3908
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3209
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=2080&view=by_date_ascending&page=1
Hope this helps!
It's not the best of solutions, especially if your divs could potentially go over one page, but it will have to do for now. Also, I've already voted for the PDF Header and Footer idea - I was hoping there was some trick to get this working.
Hi..
Can u post ur div code here..?
How to insert new line in content in css file..
I have tried
@top-right {
content: "Page /a Test";
}
and
@top-right {
content: "Page /00000a Test";
}
It doesnt work..
I need
test
I have store the following code as priintcss in static resource, and I have already stored logo in static resource named logo.
@page {
@top-right {
content: "Page " counter(page);
}
@top-left{
background-image: url('logo');
}
}
I am using following code in VF page..
<apex
age controller="HistoryCon" showHeader="false" renderAs="pdf">
<apex:stylesheet value="{!$Resource.printcss}"/>
I want to render a PDF file.. I can get a page number in each page but I couldnt get a image...
Is it possible to get an image as header..
Although I don't think it was meant to work this way, it seems you can wrap the style-element in a head-element within your visual force page. Then it is possible to use dynamic data in the @page section.
See example below:
Hi..
Ur code working fine... Thanks for ur reply...
Additional question..
How to add a static image as a Header (Logo) of PDF...
I'm sure I tried to put a style straight into my page but couldn't get this to work. It's been a while since I tried it though so perhaps it's fine now. That appears to be the most elegant solution anyway.
I need the same thing - dynamic data from my controller to show up in the header of my pdf. The @page only works for me if it is inside a css file and included in the page, not if it is directly inside the page. Has anyone found a way to do this?
I was able to get this working with the help of SFDC Support. The following code works for me:
Also I was able to move the css portion into a static resource and then in the page I just needed to include the resource between <head> </head> tags and then use a div around the dynamic text I wanted to show in the header or footer.
Hope that helps others searching for this same functionality.