为转换为PDF的VF page或VF component设置header和footer的代码参考:
<apex:page standardStylesheets="false" id="pge" renderAs="pdf" controller="DynaPdfPageCTRL" applyHtmlTag="false" showHeader="false" >
<head>
<style>
@page {
@top-center {
content: element(header);
}
@bottom-left {
content: element(footer);
}
}
div.header {
padding: 10px;
position: running(header);
}
div.footer {
display: block;
padding: 5px;
position: running(footer);
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
</style>
</head>
<!-- HEADER -->
<div class="header">
<apex:image value="{!$Resource.Header_Test_ES}" height="100%" width="100%"/>
</div>
<!-- FOOTER -->
<div class="footer">
<div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
<apex:image value="{!$Resource.Footer_Test_ES}" width="100%" height="100%" />
</div>
<!-- CONTENT -->
<div class="content">
<apex:repeat value="{!testStringList}" var="s">
<b>{!s}</b>
<br/>
</apex:repeat>
</div>
</apex:page>