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?
applyBodyTag="false"
you are getting it to recognise the CSS (whereas without it, it isn't), its that that is moving your logo right to the top (i'm a bit puzzled by why it appears to the left though). I've updated my answer to include the VF, note the addition of themargin-top
styling.