Пример #1
0
         $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']);
 # write the barcode
 if ($item['barcode']) {
     foreach ($item['barcode'] as $code => $quantity) {
         if ($quantity == 1) {
             Barcode($pdf, $bx + $vmargin, $by + $height - $vmargin - $basefontsize / 72, $code, $basefontsize / 72, 1 / 72, strlen($code));
             break;
         }
     }
 }
 # write the name
 $pdf->SetFontSize($size = $basefontsize * 2);
 $pdf->SetTextColor(0);
Пример #2
0
        die_json("No such item.");
    }
}
$trim = $_REQUEST['trim'];
$left_margin = 0.2;
$label_width = 2.0;
$label_height = 0.75;
$basefontsize = 9;
$vmargin = 0.1;
$dummy = new AlphaPDF('P', 'in', array($label_width, $label_height));
$pdf = new AlphaPDF('P', 'in', array($label_width, $label_height));
foreach ($items as $item) {
    $pdf->AddPage();
    $pdf->Rotate(270);
    $pdf->SetFont('Helvetica', '');
    $pdf->SetFontSize($size = $basefontsize);
    $pdf->SetTextColor(0);
    // write the name
    $name = utf8_decode($item['name']);
    if ($trim) {
        $name = preg_replace("/{$trim}/i", '', $name);
    }
    $width = $pdf->GetStringWidth($name);
    while ($width > $label_width - $left_margin * 2 && $size) {
        $pdf->SetFontSize(--$size);
        $width = $pdf->GetStringWidth($name);
    }
    $pdf->Text(($label_width - $width) / 2, $vmargin + $size / 72, $name);
    // write the prices
    $pdf->SetFontSize($size = $basefontsize * 2);
    // figure out the font size