Advertisement
johncarlson21

tcpdf output

Oct 29th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. // Include the main TCPDF library (search for installation path).
  2. require_once('tcpdf/tcpdf_include.php');
  3. // create new PDF document
  4. $pdf = new TCPDF("P", "px", PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
  5. // set document information
  6. $pdf->SetCreator(PDF_CREATOR);
  7. $pdf->SetAuthor('The Midweek Inc.');
  8. $pdf->SetTitle('Distribution '.date("Y-m-d H:i:s"));
  9. // remove default header/footer
  10. $pdf->setPrintHeader(false);
  11. $pdf->setPrintFooter(false);
  12. // set default monospaced font
  13. $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  14. // set margins
  15. $pdf->SetMargins(30, 30, 30);
  16. // set auto page breaks
  17. $pdf->SetAutoPageBreak(TRUE, 30);
  18. // set image scale factor
  19. $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
  20. $pdf->setFontSubsetting(false);
  21. // set some language-dependent strings (optional)
  22. if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
  23.     require_once(dirname(__FILE__).'/lang/eng.php');
  24.     $pdf->setLanguageArray($l);
  25. }
  26. // ---------------------------------------------------------
  27. // set font
  28. $pdf->SetFont('helvetica', '', 12);
  29. foreach($pages as $page) {
  30.     // build the html
  31.     $html = '<table cellpadding="20" cellspacing="0">';
  32.     foreach($page as $section) {
  33.         $html .= '<tr><td style="height:325px;border-top:#000000 solid 2px;border-bottom:#000000 solid 2px;">';
  34.         $html .= '<table cellpadding="5" cellspacing="0">';
  35.         $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;"><strong>';
  36.         $html .= strtoupper($section['city'].' '.$section['route_name'].' '.$section['zip']);
  37.         $html .= '</strong><br />';
  38.         // bundle size
  39.         if ($section['end_bundle'] === true) {
  40.             $html .= '<strong>BUNDLE SIZE : '.$section['final_bundle_size'].'</strong>';
  41.         } else {
  42.             $html .= '<strong>BUNDLE SIZE : '.$section['bundle_size'].'</strong>';
  43.         }
  44.         $html .= '</td></tr>';
  45.        
  46.         // bundle count
  47.         $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;"><strong>BUNDLE '.$section['bundle_count'].'</strong><br />';
  48.        
  49.         // mail or carry
  50.         if ($section['mail'] === true) {
  51.             $html .= '<strong>POSTAL DELIVERY</strong>';
  52.         } else {
  53.             $html .= '<strong>PALLET / STACK '.$section['pallet'].' / '.$section['stack'].'</strong>';
  54.         }
  55.        
  56.         $html .= '</td></tr>';
  57.        
  58.         // inserts area
  59.         $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;">Inserts Included</td></tr>';
  60.         if (count($section['inserts']) > 0) {
  61.             $html .= '<tr><td colspan="2"><table cellpadding="5" cellspacing="0">';
  62.             $z=1;
  63.             foreach($section['inserts'] as $insert) {
  64.                 if ($z == 1) { $html .= '<tr>'; }
  65.                 $html .= '<td style="width:40%;text-align:center;">'.$insert.'</td>';
  66.                 if ($z == 2) { $html .= '</tr>'; $z = 0; }
  67.                 $z++;
  68.             }
  69.             if ($z == 2) { $html .= '<td style="width:40%;"> </td></tr>'; }
  70.             $html .= '</table></td></tr>';
  71.         }
  72.         $html .= '</table>';
  73.         $html .= '</td></tr>';
  74.     }
  75.     $html .= '</table>';
  76.     // add a page
  77.     $pdf->AddPage();
  78.    
  79.     // output the HTML content
  80.     $pdf->writeHTML($html, true, false, false, false, '');
  81. } // end foreach
  82. // reset pointer to the last page
  83. $pdf->lastPage();
  84. // ---------------------------------------------------------
  85. //Close and output PDF document
  86.    
  87. $date = date("Ymd"); //date("YmdHis");
  88. $pdf->Output('bundle_tops_'.$date.'.pdf', 'I');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement