<?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();
$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']) { $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; } } }