I have a Visualforce page that renders as a PDF. It displays a table of data and an image on the header on each page:
<apex:page renderAs="pdf">
<head>
<style type="text/css" media="print">
@page {
@top-center {
content: element(header);
}
}
div.header {
position: running(header);
}
.sectionTitle {
font-weight: bold;
}
</style>
</head>
<div class="header">
<img src="{!$Resource.logo}" width="25%"/>
</div>
<div class="content">
<table>
<tr>
<td class="sectionTitle">test</td>
</tr>
</table>
</div>
</apex:page>
My issue is that I want to apply CSS classes to my table elements; however the CSS is not applied (in this example the text should be bold but it doesn't). If I set the applyBodyTag
or applyHtmlTag
of apex:page
to false
, it does take effect the CSS classes for the table but the header breaks.
Any ideas?
Best Answer
Change your
<apex:page>
to this:According to the docs:
Using the sample you provided, I was able to render the following as PDF:
The header (logo) appears on every page as expected using the following VF: