TCPDF: 1 половина портрета американской юридической газеты - PullRequest
0 голосов
/ 10 июля 2019

Мне нужно напечатать только половину допустимого размера бумаги в США. И мне также нужно, чтобы мой нижний колонтитул был динамичным с заданным содержимым, чтобы, если содержание превышало, нижний колонтитул перемещался на следующую страницу половины юридического документа США.

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A4', true, 'UTF-8', false);
$pdf->SetFont('Times', '', 11); 
$pdf->AddPage();
$pdf->SetFillColor(255, 255, 127);
$y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
$osDate = $headerData['cart_date'];
$osCustomer = $headerData['cart_name'];
$osDistMeans =  $headerData['cart_dist'];
$osinvNo =  $headerData['cart_no'];
$osTime = $headerData['cart_time'];

$title = <<<EOD
<p style="font-size:45px"><strong>OS</strong></p>
EOD;

$day = date('m-d-Y',strtotime($osDate));
$time = date('g:i A',strtotime($osTime));
$pdf->writeHTMLCell(0,0,'',14,$title,0,1,0,true,'R',true);

$pdf->writeHTMLCell(0,0,'',15,'<p style="font-size:12px">'.$day.'/ '.$time.'</p>',0,1,0,true,'L',true);
$pdf->writeHTMLCell(0,0,'',20,'<p style="font-size:12px">'.$osCustomer.'</p>',0,1,0,true,'L',true);
// pickup warehouse color: blue, white text
// pickup store color:red, white text
if($osDistMeans == "CASH PICKUP STORE" || $osDistMeans == "CHARGE PICKUP STORE"){
    $pdf->writeHTMLCell(60,0,'',25,'<p style="font-size:12px; background-color:red;color:white;">'.$osDistMeans.'</p>',0,1,0,true,'L',true);
}else if($osDistMeans == "CASH PICKUP WHS" || $osDistMeans == "CHARGE PICKUP WHS"){
    $pdf->writeHTMLCell(45,0,'',25,'<p style="font-size:12px; background-color:blue;color:white;">'.$osDistMeans.'</p>',0,1,0,true,'L',true);
}else{
    $pdf->writeHTMLCell(0,0,'',25,'<p style="font-size:12px">'.$osDistMeans.'</p>',0,1,0,true,'L',true);
}
$pdf->writeHTMLCell(0,0,'',30,'<p style="font-size:12px">'.$osinvNo.'</p></br>',0,1,0,true,'L',true);

$table = '<table style="padding:3px">';
$table .= '<tr>
            <th style="border-bottom:1px solid black;width:40px"><strong>QTY</strong></th>
            <th style="border-bottom:1px solid black;width:270px"><strong>DESCRIPTION</strong></th>
            <th style="border-bottom:1px solid black;width:50px"><strong>W/ STOCK</strong></th>
            <th style="border-bottom:1px solid black;width:50px"><strong>W/O STOCK</strong></th>
            <th style="border-bottom:1px solid black;width:70px"><strong>PRICE</strong></th>
            <th style="border-bottom:1px solid black;width:70px"><strong>AMOUNT</strong></th>
        </tr>'; 

$no = 1;

$sumTotal = 0;
foreach ($WHO as $key) {
    $sumTotal += $key['LINETOTAL'];

    $table .= '<tr>
                <td>'.number_format($key['QUANTITY']).'</td>
                <td style="text-align:left"><p>'.'<strong>'.$key['ITEMCODE'].'</strong><br />'.$key['DSCRIPTION'].'</p></td>
                <td>'.number_format($key['SERVED']).'</td>
                <td>'.number_format($key['UNSERVED']).'</td>
                <td style="text-align:right;">'.number_format($key['PRICE'],2).'</td>
                <td style="text-align:right;">'.number_format($key['LINETOTAL'],2).'</td>
            </tr>
            ';
    }
$table .= '<tr>
            <td colspan="7" style="text-align:right;"><h2><strong>Total Amount:   '.number_format($sumTotal,2).'</strong></h2></td>
         </tr>';
$table .= '</table>';

$pdf->writeHTMLCell(0,0,'','',$table,0,1,0,true,'C',true);
$pdf->writeHTMLCell(0,0,'',230,'<p style="font-size:14px;color:gray;">THIS DOCUMENT IS FOR INTERNAL USE ONLY</p></br>',0,1,0,true,'C',true);
$pdf->writeHTMLCell(0,0,'',235,'<p style="font-size:10px;color:red;"><u>"THIS DOES NOT SERVE AS AN OFFICIAL RECEIPT"</u></p></br>',0,1,0,true,'C',true);

$pdf->lastPage();

ob_clean();
$pdf->Output('soreport.pdf', 'I');

Это мой код, последние два writeHtmlCell будут моим нижним колонтитулом и должны быть напечатаны, если таблица превышает размер бумаги, который в два раза меньше формата Legal США.

...