Wrap dates in pdf and setup the bottom of pdf pages.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 19 Sep 2018 15:56:08 +0000 (11:56 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 19 Sep 2018 15:56:08 +0000 (11:56 -0400)
For bottom of pdf pages need to check if too close so we can goto new
page.
Wrap the dates part so it won't go over the Title.

models/front/events/pdfCreator.php

index 6ee1a15..de0ef0b 100644 (file)
@@ -18,6 +18,7 @@ $this->line_height   = 10;
 $this->pdf_font_size = 8;
 $this->pdf_lft_col_x = 20;
 $this->pdf_rgt_col_x = 320;
+$this->pdf_bottom_y  = 200;
 
 usort( $events, function($event1, $event2){
     if ( $event1['starting_timestamp'] == $event2['starting_timestamp']) {
@@ -101,7 +102,7 @@ foreach ( $events as $eventId => $event ) {
         }
     }
     // Add the Event Dates
-    $event_date_y = $pdf->ezText( '<b>'.$eventDates.'</b>', $this->pdf_font_size, array( 'aleft' => $this->pdf_lft_col_x ) );
+    $event_date_y = $pdf->ezText( '<b>'.$eventDates.'</b>', $this->pdf_font_size, array( 'aleft' => $this->pdf_lft_col_x, 'aright' => $this->pdf_rgt_col_x ) );
 
     // title
     $pdf->ezSetY( $eventTopY );
@@ -209,6 +210,12 @@ foreach ( $events as $eventId => $event ) {
 
     // bottom
     $pdfY = $pdf->y;
+    // If the $pdf->y is too close to the bottom then start next page.
+    if ( $pdf->y < $this->pdf_bottom_y && !( $totalEvents == $index ) ) {
+        $pdf->ezNewPage();
+        $pdfY = $this->pdf_top_y;
+        $pdf->ezSetY( $pdfY );
+    }
 }