Exemple #1
0
<?php

require 'alphapdf.php';
$pdf = new AlphaPDF();
$pdf->AddPage();
$pdf->SetLineWidth(1.5);
// draw opaque red square
$pdf->SetFillColor(255, 0, 0);
$pdf->Rect(10, 10, 40, 40, 'DF');
// set alpha to semi-transparency
$pdf->SetAlpha(0.5);
// draw green square
$pdf->SetFillColor(0, 255, 0);
$pdf->Rect(20, 20, 40, 40, 'DF');
// draw jpeg image
$pdf->Image('lena.jpg', 30, 30, 40);
// restore full opacity
$pdf->SetAlpha(1);
// print name
$pdf->SetFont('Arial', '', 12);
$pdf->Text(46, 68, 'Lena');
$pdf->Output();
Exemple #2
0
             $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);
 $name = utf8_decode($item['name']);
 $width = $pdf->GetStringWidth($name);
 while ($width > $label_width - $vmargin * 2 && $size) {
Exemple #3
0
 $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
 $price = '$' . max($item['sale_price'], $item['retail_price']);
 $pwidth = $pdf->GetStringWidth($price);
 while ($pwidth > ($label_width - $left_margin * 2 - $vmargin * 2) / 2 && $size) {
     $pdf->SetFontSize(--$size);
     $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']) {