Пример #1
0
$pdf->SetAutoPageBreak(false);
$x = $y = 0;
$light = 96;
$basefontsize = 6;
$label_width = 2.625;
foreach ($items as $item) {
    $bx = 0.25 + $x * ($label_width + 0.125);
    $by = 0.5 + $y * $height;
    $vmargin = 0.125;
    if ($x == 0 && $y == 0) {
        $pdf->AddPage();
        if ($_REQUEST['debug']) {
            $pdf->SetDrawColor($light);
            $pdf->SetLineWidth(1 / 72 / 2);
            for ($ly = 0; $ly < 11; $ly++) {
                $pdf->Line(0, 0.5 + $ly, 8.5, 0.5 + $ly);
            }
            $pdf->Line(0.1875, 0, 0.1875, 11);
            $pdf->Line(0.1875 + 2.625, 0, 0.1875 + 2.625, 11);
            $pdf->Line(0.1875 + 2.625 + 0.125, 0, 0.1875 + 2.625 + 0.125, 11);
            $pdf->Line(0.1875 + 2.625 + 0.125 + 2.625, 0, 0.1875 + 2.625 + 0.125 + 2.625, 11);
            $pdf->Line(0.1875 + 2.625 + 0.125 + 2.625 + 0.125, 0, 0.1875 + 2.625 + 0.125 + 2.625 + 0.125, 11);
            $pdf->Line(0.1875 + 2.625 + 0.125 + 2.625 + 0.125 + 2.625, 0, 0.1875 + 2.625 + 0.125 + 2.625 + 0.125 + 2.625, 11);
        }
    }
    # write the code
    $pdf->SetFont('Helvetica', '');
    $pdf->SetFontSize($basefontsize);
    $pdf->SetTextColor($light);
    $width = $pdf->GetStringWidth($item['code']);
    $pdf->Text($bx + $label_width - $width - $vmargin, $by + $height - $vmargin, $item['code']);
Пример #2
0
     $pwidth = $pdf->GetStringWidth($price);
 }
 // sale price
 $price = '$' . ($item['sale_price'] ? $item['sale_price'] : $item['retail_price']);
 $pwidth = $pdf->GetStringWidth($price);
 $pdf->Text($label_width - $left_margin - $pwidth, $label_height / 2 + $vmargin, $price);
 // retail price, if different
 if ($item['sale_price']) {
     $price = '$' . $item['retail_price'];
     $pwidth = $pdf->GetStringWidth($price);
     $pdf->Text($left_margin + $vmargin, $label_height / 2 + $vmargin, $price);
     $pdf->SetDrawColor(0);
     $pdf->SetAlpha(0.4);
     $line_width = $size / 3;
     $pdf->SetLineWidth($line_width / 72);
     $pdf->Line($left_margin, $label_height / 2 + $vmargin - ($size / 72 / 2 - $line_width / 72 / 2), $left_margin + $pwidth + $vmargin * 2, $label_height / 2 + $vmargin - ($size / 72 / 2 - $line_width / 72 / 2));
     $pdf->SetAlpha(1);
 }
 // write the barcode
 $code = $item['fake_barcode'];
 if ($item['barcode']) {
     foreach ($item['barcode'] as $barcode => $quantity) {
         if ($quantity == 1) {
             $code = $barcode;
             break;
         }
     }
 }
 $types = array(8 => 'ean8', 12 => 'upc', 13 => 'ean13');
 $type = $types[strlen($code)];
 if (!$type) {