Header and footer issues

675 views
Skip to first unread message

Michael Fatica

unread,
May 25, 2012, 2:42:53 PM5/25/12
to dom...@googlegroups.com
Hi all,

I'm having trouble positioning and repeating the header and footer using the example code.  

My HTML validates XHTML Transitional, and I believe I've followed the example exactly.

This is what it looks like in HTML, note that the header and footer appear correctly fixed at the top and bottom of the "page"


This is the PDF view,

The code to export it couldn't be simpler:


<?php
require_once("components/com_quote/assets/pdf/dompdf/dompdf_config.inc.php");

spl_autoload_register('DOMPDF_autoload'); 

ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<link rel="stylesheet" href="components/com_quote/assets/css/pdf.css" type="text/css" />
</head>
<body>

<div id="header">
  <table>
    <tr>
      <td>Example document</td>
      <td style="text-align: right;">Author</td>
    </tr>
  </table>
</div>

<div id="footer">
<table>
    <tr>
      <td>Example footer</td>
      <td style="text-align: right;">Author</td>
    </tr>
  </table>
  <div class="page-number"></div>
</div>

SNIP...full html of the export...SNIP

</div>
</body>
</html>
<?php

$html = ob_get_contents();

ob_end_clean();

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();

$dompdf->stream($params->get('filename','Kiosk_Quote_') . $q_id . ".pdf",array("Attachment" => 0));

?>

The included CSS file uses the example code:

/*****************Start of PDF Header**********************/

@page {
margin: 2cm;
}

body {
margin: 0.5cm 0;
text-align: justify;
}

#header,
#footer {
  position: fixed;
  left: 0;
right: 0;
color: #aaa;
font-size: 0.9em;
height:100px;
}

#header {
  top: 0;
border-bottom: 0.1pt solid #aaa;
}

#footer {
  bottom: 0;
  border-top: 0.1pt solid #aaa;
}

#header table,
#footer table {
width: 100%;
border-collapse: collapse;
border: none;
}

#header td,
#footer td {
  padding: 0;
width: 50%;
}

.page-number {
  text-align: center;
}

.page-number:before {
  content: "Page " counter(page);
}

hr {
  page-break-after: always;
  border: 0;
}

Any ideas?

Thanks!

John Bell

unread,
May 26, 2012, 5:14:17 AM5/26/12
to dom...@googlegroups.com
it looks like your css file is not being loaded as the link needs the local file path or fully qualified url. Are you using Joomla! ? if so, try:
<link rel="stylesheet" href="<?php echo JPATH_BASE ?>/components/com_quote/assets/css/pdf.css" type="text/css" />

John
--
You received this message because you are subscribed to the Google Groups "dompdf" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dompdf/-/2fabiFuCMhsJ.
To post to this group, send email to dom...@googlegroups.com.
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dompdf?hl=en.

Michael Fatica

unread,
May 26, 2012, 5:23:31 PM5/26/12
to dom...@googlegroups.com
Thanks John,

I discovered this behavior was only for BETA 3, so upgrading solved the problem.  </facepalm>
To unsubscribe from this group, send email to dompdf+unsubscribe@googlegroups.com.

John Bell

unread,
Apr 18, 2013, 9:28:47 AM4/18/13
to dom...@googlegroups.com
Best to start a new thread on this

John
On 12/04/2013 23:29, Amulet wrote:
Hello.
I'm a newbie to Dompdf, and I have been hunting for solutions to change the output style of the pdfs. It looks like I'm getting closer here :).
But what is confusing me is in which file does the code  <link rel="stylesheet" href="<?php echo JPATH_BASE ?>/components/com_componentname/
assets/css/pdf.css" type="text/css" /> go? I am using Joomla 3.
Thank you!

To unsubscribe from this group and stop receiving emails from it, send an email to dompdf+un...@googlegroups.com.

To post to this group, send email to dom...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages