External CSS: first and second pages ok...other pages margin-top has
no effect at all!
This is the HTML I pass to dompdf:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link href="styles/style_pdf.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<script type="text/php">
if ( isset($pdf) )
{
$php_code =
'
$w = $pdf->get_width();
$h = $pdf->get_height();
$header = $pdf->open_object();
// Add a logo
$img_w = 45;
$img_h = 35;
$pdf->image("images/logo_little.png", "png", 60, 15,
$img_w, $img_h );
// Close the object (stop capture)
$pdf->close_object();
$font = Font_Metrics::get_font("Helvetica", "italic");
$size = 10;
$color = array(0.7,0.7,0.7); // grigio
$text_center_up = "Acceptance Test Plan";
$text_center_dw = "SOME TEXT HERE";
$width_center_up = Font_Metrics::get_text_width($text_center_up,
$font, $size);
$width_center_dw = Font_Metrics::get_text_width($text_center_dw,
$font, $size);
$text_right = "SOME PROJECT HERE1";
$width_right = Font_Metrics::get_text_width($text_right, $font,
$size);
if ($PAGE_NUM > 1)
{
$pdf->add_object($header, "all");
$pdf->text($w / 2 - $width_center_up / 2, 20, $text_center_up,
$font, $size, $color);
$pdf->text($w / 2 - $width_center_dw / 2, 35, $text_center_dw,
$font, $size, $color);
$pdf->text($w - $width_right - 60, 35, $text_right, $font,
$size, $color);
$pdf->line(60, 55, $w - 60, 55, $color, 0.5);
}
';
$pdf->page_script($php_code);
}
</script>
<script type="text/php">
if ( isset($pdf) )
{
$php_code =
'
$font = Font_Metrics::get_font("verdana");
if (!isset($font))
{
Font_Metrics::get_font("sans-serif");
}
$size = 10;
$color = array(0.7,0.7,0.7); // grigio
$text_height = Font_Metrics::get_font_height($font, $size);
$w = $pdf->get_width();
$h = $pdf->get_height();
$y = $h - 3 * $text_height - 24;
$page_nr = $PAGE_NUM;
$text_left = "FOOTER LEFT HERE";
$width_left = Font_Metrics::get_text_width($text_left, $font,
$size);
$text_center = $page_nr . "/" . $PAGE_COUNT;
$width_center = Font_Metrics::get_text_width("100/100", $font,
$size);
$text_right = "FOOTER RIGHT HERE";
$width_right = Font_Metrics::get_text_width($text_right, $font,
$size);
if ($PAGE_NUM > 1)
{
// FOOTER
$pdf->line(60, $y-3, $w - 60, $y-3, $color, 0.5);
$pdf->text(60, $y, $text_left, $font, $size, $color);
$pdf->text($w / 2 - $width_center / 2, $y, $text_center, $font,
$size, $color);
$pdf->text($w - $width_right - 60, $y, $text_right, $font, $size,
$color);
}
else
{
// JUST TO PROVE IT WRITES SOMETHING ELSE ONLY ON THE FIRST PAGE
$color = array(0,0,0); // nero
$pdf->text(400, 410, $PAGE_COUNT." Pages", $font, $size, $color);
}
';
$pdf->page_script($php_code);
}
</script> <center>
<h1>A BIG TITLE</h1>
<h2>SUBTITLE</h2>
<h2> </h2>
</center>
<p><br /><br /><br /></p>
<table style="width: 100%; page-break-after: always;">
<tbody>
<tr>
<td width="33%">Bla</td>
<td width="34%">Bla</td>
<td width="33%">Bla</td>
</tr>
<tr>
<td><br /><strong>some text</strong><br /><br /></td>
<td><br /><strong>some text</strong><br /><br /></td>
<td><br /><br /><br /></td>
</tr>
<tr>
<td>some text</td>
<td>some text</td>
<td>some text</td>
</tr>
<tr>
<td><br /><strong>some text</strong><br /><br /></td>
<td><br /><strong></strong><br /><br /></td>
<td><br /><strong>some text</strong><br /><br /></td>
</tr>
<tr>
<td>Date:05/05/2011</td>
<td>Date:</td>
<td>Date:</td>
</tr>
</tbody>
</table>
<table style="width: 100%; page-break-after: always;">
<tbody>
<tr>
<td colspan="5"><strong>A TABLE</strong></td>
</tr>
<tr>
<td><strong>A</strong></td>
<td><strong>B</strong></td>
<td><strong>C</strong></td>
<td><strong>D</strong></td>
<td><strong>E</strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
<ul style="page-break-after: always;">
<li>1.</li>
<li>2. </li>
<li>3. </li>
<li>4.</li>
<li>5. </li>
</ul>
<h2>Another list List</h2>
<ul>
<li>Bla Bla</li>
<li>Bla Bla</li>
</ul>
<p><br /><br /><br /></p>
<h2>Illustration Index</h2>
<ul style="page-break-after: always;">
<li>Illustration 1: dddd</li>
<li>Illustration 2: eeee</li>
</ul>
<h2>1. INTRODUCTION</h2>
<p style="text-align: justify;">Some very long text here Some very
long text hereSome very long text hereSome very long text hereSome
very long text hereSome very long text hereSome very long text
hereSome very long text hereSome very long text hereSome very long
text hereSome very long text hereSome very long text hereSome very
long text hereSome very long text hereSome very long text hereSome
very long text hereSome very long text hereSome very long text
hereSome very long text hereSome very long text hereSome very long
text hereSome very long text hereSome very long text hereSome very
long text hereSome very long text hereSome very long text hereSome
very long text hereSome very long text hereSome very long text
hereSome very long text hereSome very long text hereSome very long
text hereSome very long text hereSome very long text hereSome very
long text hereSome very long text hereSome very long text hereSome
very long text hereSome very long text here</p>
<h3>1.1 Sub Intro</h3>
<p style="text-align: justify;"><strong>Bla Bla</strong></p>
</body>
</html>