function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dev_jhdev_jh 

Unable to get PDF header & footer to show

Hi all,

 

I have been researching the forum to understand how to get headers and footers in the PDFs generated from Visualforce. According to these posts it is possible:

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=6411

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3403

 

However, I have been following the instructions but I get no header or footer. I will explain:

 

1 - I created the static resource as suggested. The file contains the following:

 

 

@page { @bottom-left { content: "Page " counter(page) " Customer Report"; } @top-center { content: "PDF Header"; } }

 

 2 - I included this static resource on my Visualforce page. The first lines of code are:

 

 

<apex:page standardController="Opportunity" showHeader="true" renderas="pdf"> <apex:includeScript value="{!$Resource.PDFHeaderFooter}"/> <table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1"> <tr> <td valign="top">

 

 However, I am not getting anything on the header or footer of the PDF. Can you help? Thanks,

 

J

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SuriSuri

Hi.

 

Save the Static Resource File as a .css File.

 

Then use:

 

<apex:stylesheet value="{!$Resource.PDFHeaderFooter}" />

 

on the VF Page.

 

This should work.

All Answers

Kirtesh_JainKirtesh_Jain

Hi ,

 

I am able to generate Pdf file Header and Footer with same logic by using same flow of your way.

I think you should save resouce file as .css file and load that , I was with this issue when I were not able to get header and footer.

 

 

Thanks,

kirtesh

dev_jhdev_jh
That´s exactly how I did it. I saved as .CSS and uploaded that but it isn´t working...
SuriSuri

Hi.

 

Save the Static Resource File as a .css File.

 

Then use:

 

<apex:stylesheet value="{!$Resource.PDFHeaderFooter}" />

 

on the VF Page.

 

This should work.

This was selected as the best answer
dev_jhdev_jh

Thanks Suri, that was the issue, I needed the "<apex:stylesheet>" tag!.

 

I have a further question. I want to format the text on the footer to a specific font but are unsure as to how to do this. I also found that special characters liks ñ (&ntilde;) can´t be represented neither as "ñ" or "&ntilde;"

 

Thanks!

SuriSuri

Yup.

 

Well, if you want to format the font in PDF's footer, use in your CSS Stylesheet:

 

 

@bottom-left {
  

  font-family: Arial Unicode MS;

 

  content: "Page  " counter(page) "Customer Report";

 

 
 }

Kirtesh_JainKirtesh_Jain

Hi,

 

I am able to generate Pdf file from VF page. I have one Problem that I used <div style="page-break-after:always"/> inside the repeat tag . When repeat process ends then also generate one New blank page at last .

What may be reason of it of blank pdf page.

 

 

Thanks,

Kirtesh

JeeTJeeT

here is my code
<apex:repeat value="{!clause}" var="desc" id="theRepeat" >
<br/><apex:outputLabel style="font-size:11pt;font-family:arial,helvetica,sans-serif;">
<b><apex:outputText value="{!desc.Name}"/></b>
</apex:outputLabel><br/>
<apex:outputLabel style="font-size:11pt;font-family:arial,helvetica,sans-serif;">
<apex:outputText value="{!desc.Insurance__c}"/>
</apex:outputLabel>
</apex:repeat>
on the insurance field contents are having bullets. I wants to put a page break after when a bullet will come.
like this:-
• Description1
• Description1
• Description1

but this is coming as a paragraph without a page break on the PDF.

How can I resolve this Issue??