Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include the main TCPDF library (search for installation path).
- require_once('tcpdf/tcpdf_include.php');
- // create new PDF document
- $pdf = new TCPDF("P", "px", PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
- // set document information
- $pdf->SetCreator(PDF_CREATOR);
- $pdf->SetAuthor('The Midweek Inc.');
- $pdf->SetTitle('Distribution '.date("Y-m-d H:i:s"));
- // remove default header/footer
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- // set default monospaced font
- $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
- // set margins
- $pdf->SetMargins(30, 30, 30);
- // set auto page breaks
- $pdf->SetAutoPageBreak(TRUE, 30);
- // set image scale factor
- $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
- $pdf->setFontSubsetting(false);
- // set some language-dependent strings (optional)
- if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
- require_once(dirname(__FILE__).'/lang/eng.php');
- $pdf->setLanguageArray($l);
- }
- // ---------------------------------------------------------
- // set font
- $pdf->SetFont('helvetica', '', 12);
- foreach($pages as $page) {
- // build the html
- $html = '<table cellpadding="20" cellspacing="0">';
- foreach($page as $section) {
- $html .= '<tr><td style="height:325px;border-top:#000000 solid 2px;border-bottom:#000000 solid 2px;">';
- $html .= '<table cellpadding="5" cellspacing="0">';
- $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;"><strong>';
- $html .= strtoupper($section['city'].' '.$section['route_name'].' '.$section['zip']);
- $html .= '</strong><br />';
- // bundle size
- if ($section['end_bundle'] === true) {
- $html .= '<strong>BUNDLE SIZE : '.$section['final_bundle_size'].'</strong>';
- } else {
- $html .= '<strong>BUNDLE SIZE : '.$section['bundle_size'].'</strong>';
- }
- $html .= '</td></tr>';
- // bundle count
- $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;"><strong>BUNDLE '.$section['bundle_count'].'</strong><br />';
- // mail or carry
- if ($section['mail'] === true) {
- $html .= '<strong>POSTAL DELIVERY</strong>';
- } else {
- $html .= '<strong>PALLET / STACK '.$section['pallet'].' / '.$section['stack'].'</strong>';
- }
- $html .= '</td></tr>';
- // inserts area
- $html .= '<tr><td style="width:30%;"> </td><td style="width:68%;text-align:left;">Inserts Included</td></tr>';
- if (count($section['inserts']) > 0) {
- $html .= '<tr><td colspan="2"><table cellpadding="5" cellspacing="0">';
- $z=1;
- foreach($section['inserts'] as $insert) {
- if ($z == 1) { $html .= '<tr>'; }
- $html .= '<td style="width:40%;text-align:center;">'.$insert.'</td>';
- if ($z == 2) { $html .= '</tr>'; $z = 0; }
- $z++;
- }
- if ($z == 2) { $html .= '<td style="width:40%;"> </td></tr>'; }
- $html .= '</table></td></tr>';
- }
- $html .= '</table>';
- $html .= '</td></tr>';
- }
- $html .= '</table>';
- // add a page
- $pdf->AddPage();
- // output the HTML content
- $pdf->writeHTML($html, true, false, false, false, '');
- } // end foreach
- // reset pointer to the last page
- $pdf->lastPage();
- // ---------------------------------------------------------
- //Close and output PDF document
- $date = date("Ymd"); //date("YmdHis");
- $pdf->Output('bundle_tops_'.$date.'.pdf', 'I');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement