"; //calculate column width $column_width = ($page_width - (($number_of_columns-1) * $column_padding) - ($margin_size * 2) ) / $number_of_columns; $column_height = $page_height - ($margin_size * 2); //load libraries require_once('vendor/autoload.php'); //run function to attach meeting data to $meetings $meetings = attachPdfMeetingData(); // Extend the TCPDF class to create custom Header and Footer class MYPDF extends TCPDF { //Page header public function Header() { $header_text = get_option('tsmp_header'); if ($header_text != "") { // Set font $this->SetFont('helvetica', 'B', 15); $this->Cell(0, 15, $header_text, 0, false, 'C', 0, '', 0, false, 'M', 'B'); } } }//end of class //create new PDF $pageLayout = array($page_width, $page_height); // or array($height, $width) $pdf = new MYPDF("", PDF_UNIT, $pageLayout, true, 'UTF-8', false); $pdf->SetFont('helvetica', '', $font_size); $pdf->SetMargins($margin_size, $margin_size, $margin_size, true); $pdf->SetAutoPageBreak(TRUE, $margin_size); $pdf->AddPage(); $current_column = 1; //starting x,y for the start of this column $column_x = $margin_size + (($column_padding + $column_width) * ($current_column - 1)); $column_y = $margin_size; // ========================================================== // Pre HTML // ========================================================= //loop through pre-html if($intro_text != ""){ $html_array = explode($html_delimiter, $intro_text ); foreach ($html_array as $html_block) { $html_block .= $html_delimiter; //put back what we striped out //get start page to see if adding this text would send it over the edge $start_page = $pdf->getPage(); //start a transaction, so if it goes over the edge of the page, we can rollback $pdf->startTransaction(); $pdf->MultiCell($column_width, 1, $html_block, 0, 'J', 0, 2, $column_x, '', true , 0, true, true, 0, 'T', true); $end_page = $pdf->getPage(); if ($end_page == $start_page) { //if we are still onthe same page $pdf->commitTransaction(); }else{ //we would have popped to a new page $pdf = $pdf->rollbackTransaction(); $current_column++; if($current_column > $number_of_columns){ //last column on the page //need a new page $pdf->AddPage(); $current_column = 1; } $column_x = $margin_size + (($column_padding + $column_width) * ($current_column - 1)); $column_y = $margin_size; $pdf->SetXY($column_x,$column_y, true); //write the text on the new column [and page] $pdf->MultiCell($column_width, 1, $html_block , 0, 'J', 0, 2, $column_x, '', true , 0, true, true, 0, 'T', true); } }//end of Loop }//end of if // ========================================================== // meetings // ========================================================== $current_day = ""; //loop through meetings foreach ($meetings as $meeting){ $column_x = $margin_size + (($column_padding + $column_width) * ($current_column - 1)); $column_y = $margin_size; // $meeting_header = ""; // ------------------------------------------------------------------------- if($meeting['formatted_day'] !== $current_day){ $current_day = $meeting['formatted_day']; $meeting_header = "