0

While using the following code, my footer goes beyond the page (and is not visible):

  $footer = $pdf->open_object();

  $w = $pdf->get_width();
  $h = $pdf->get_height();
  $size = 10;

  $color = array(.24,.65,.04);
  $font = Font_Metrics::get_font("verdana", "bold");
  $text_height = Font_Metrics::get_font_height($font, $size);


  $text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

  $width = Font_Metrics::get_text_width($text, $font, $size);
  $pdf->page_text (16 , $y-15, $text, $font, $size, $color);

This way, footer is added for sure, but only a portion of text is visible. Any ideas?

user1314305
  • 2,777
  • 2
  • 16
  • 14
  • If you're using v0.6 (and you should be) and you don't need to have the total number of pages try using CSS instead. When you script the footer using the rendering library directly you have to handle layout on your own. – BrianS Jul 28 '14 at 23:07
  • This question discusses the two methods of creating headers/footers: http://stackoverflow.com/q/7484318/264628 – BrianS Jul 28 '14 at 23:08
  • @BrianS Hi Brian, thanks for your message and apologies for my late response. I've used 0.6 as well. The problem with inline script has already been mentioned in my previous message, already. Now, the problem with "position:fixed" CSS is that, if the content of the page become long enough to reach the bottom, the footer overlaps it, and hides the contents. Again not a solution. Thus I had to resort to using footer as all other divs. – user1314305 Aug 04 '14 at 07:39
  • Now, the footer does not appear at the bottom of the page, as I'd like to . Instead it appears just below where the content ends. That is sometimes at the bottom of the page, sometimes in the middle of the page and sometime, at the top of a new page. Not very elegant, but still better than overlapping text. – user1314305 Aug 04 '14 at 07:43
  • When using fixed-positioned content you can avoid overlapping the content by setting page margins then positioning your header/footer outside the margins using negative values. Check out the CSS sample again. If you decide to use CSS and are still having problems start a new question with a code sample. – BrianS Aug 05 '14 at 15:58
  • (Put my comments as answer since, technically, they answer the question posed.) – BrianS Aug 05 '14 at 15:59

1 Answers1

0

dompdf performs layout then uses the rendering library to produce the PDF. The rendering libraries have no knowledge of dompdf and so can not use its layout engine. That is to say, when you script a header/footer using the PDF rendering library directly you have to handle layout on your own.

If you want dompdf to perform the layout use CSS for the header/footer. This question has answers outlining the two methods of creating headers/footers: stackoverflow.com/q/7484318/264628.

BrianS
  • 13,284
  • 15
  • 62
  • 125