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

VF page Doc conversion - Header is being displayed twice on First page.
Hi
I am facing an issue with VF to word doc conversion , header is being disaplyed twice on the first page, and header is displayed only once in the remaining all pages.
Thanks
Prajnith
Hi,
Atlast after a lot of trial and error, i have finally managed to overcome the problem of repeating header and footer in the generated ms word file.
For this i have applied a style for header and footer and contained both in a table.
This effectively pushed the table off the page and since the table is very thin due to the minimal header/footer information, moving the table off the page did not cause Word to generate another page.
Please note
1)The height of header and footer should not be too much.
2)I have tested this in word 2007 only.
I hope this will work in your case too.
Please find the actual code i have used below:
By: Parin
All Answers
Is the page part of a composition that uses a template? If so, try setting the template to showHeader=false;
Im using the below code to display header in the word doc.
<apex:page standardController="Quote" extensions="testclassCTRL" cache="true"
contentType="application/vnd.msword#QuoteNumber-{!quoteObj.QuoteNumber}.doc" standardStylesheets="false" >
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<Style>
@page Section1 {mso-Header:f1;}
div.Section1{page:Section1;}
p.MsoHeader, li.MsoHeader, div.MsoHeader{
mso-pagination:widow-orphan;
tab-stops:center 216.0pt right 432.0pt;}
</Style>
<body>
<div class="Section1">
<div style="mso-element:Header" id="f1">
<table border="0" width="100%" height="10" id="headertable" >
<tr>
<td width="20%">
<div style="font-family: Arial; font-size: 8pt;text-align:left;">
<apex:outputText value="{!quoteObj.quoteToName}" />
<br/>
<apex:outputText value="Quotation No:{!quoteObj.QuoteNumber}"/>
</div>
</td>
<td width="60%">
<div style="font-family: Arial; font-size: 12pt; font-weight: bold;text-align:center;">
<apex:outputText style="font-family: Arial; font-size: 12pt; font-weight: bold">Test Header 4</apex:outputText>
</div>
</td>
<td width="20%">
<div style="font-family: Arial; font-size: 8pt;text-align:right;">
<apex:outputText >
{!MONTH(TODAY())}/{!DAY(TODAY())}/{!YEAR(TODAY())}
</apex:outputText>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
</apex:page>
Hi,
Atlast after a lot of trial and error, i have finally managed to overcome the problem of repeating header and footer in the generated ms word file.
For this i have applied a style for header and footer and contained both in a table.
This effectively pushed the table off the page and since the table is very thin due to the minimal header/footer information, moving the table off the page did not cause Word to generate another page.
Please note
1)The height of header and footer should not be too much.
2)I have tested this in word 2007 only.
I hope this will work in your case too.
Please find the actual code i have used below:
By: Parin
Thanks a lot :)
Prajnith.
Thank you! You just saved my life! :D
Probably I am missing something here? Can you explain what your post is doing. I tried and it pushed header and footer to both of the page.
I was hoping to generate a word doc with header and footer on every new page, just like renderas='pdf' works.
Thanks.
Brilliant piece of code, helped me heaps.
I have a question, how can I not display the header and footer on Page 1?
I know that it passed lot of time, but if someone else needs answer for hiding Header and Footer on Page 1, you can just add "mso-title-page: yes;". Below is an example:
@page Section1{
size:8.5in 11.0in;
margin:1.2cm 0.5in 1.2cm 0.5in;
mso-header-margin:0.1in;
mso-title-page: yes;
mso-header:h1;
mso-footer:f1;
mso-footer-margin:0.2in;
mso-paper-source:0;
}