To update the vencedor answer above and remove the extra empty character encoding added to your images / header / footer textures, you can do something like this:
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title></title> <style> <!-- p.MsoHeader, li.MsoHeader, div.MsoHeader{ margin:0in; margin-top:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; } p.MsoFooter, li.MsoFooter, div.MsoFooter{ margin:0in 0in 1in 0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; } .footer { font-size: 9pt; } @page Section1{ size:8.5in 11.0in; margin:0.5in 0.5in 0.5in 0.5in; mso-header-margin:0.5in; mso-header:h1; mso-footer:f1; mso-footer-margin:0.5in; mso-paper-source:0; } div.Section1{ page:Section1; } table#hrdftrtbl{ margin:0in 0in 0in 9in; } --> </style> <style type="text/css" media="screen,print"> body { font-family: "Calibri", "Verdana","HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-size:12pt; } pageBreak { clear:all; page-break-before:always; mso-special-character:line-break; } </style> </head> <body style='tab-interval:.5in'> <div class="Section1"> Something page 1 <div class="pageBreak"></div> Something page 2 <div class="pageBreak"></div> <table id='hrdftrtbl' border='1' cellspacing='0' cellpadding='0'> <tr> <td> <div style='mso-element:header' id="h1" > <p class="MsoHeader"> <table border="0" width="100%"> <tr> <td> YOUR_HEADER IMAGE/TEXT </td> </tr> </table> </p> </div> </td> <td> <div style='mso-element:footer' id="f1"> <p class="MsoFooter"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" class="footer"> YOUR_FOOTER_TEXT <g:message code="offer.letter.page.label"/> <span style='mso-field-code: PAGE '></span> of <span style='mso-field-code: NUMPAGES '></span> </td> </tr> </table> </p> </div> </td> </tr> </table> </div> </body> </html>
This now includes the complete css components for the header and footer segments.
The trick, which actually removes the extra encoding, declares another table in the MsoFooter and MsoHeader sections.
Vahid source share