<?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();
$pdf->SetCompression(true); $pdf->SetMargins(0, 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);
$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']) { $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)];