Esempio n. 1
0
function pdf_barcode($pdf, $productId, $col, $row)
{
    $product = \Pasteque\ProductsService::get($productId);
    $x = H_MARGIN + $col * COL_SIZE + $col * H_PADDING;
    $y = V_MARGIN + $row * ROW_SIZE + $row * V_PADDING;
    $pdf->SetXY($x, $y);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, utf8_decode($product->reference), 0, 1, "C");
    $pdf->SetXY($x, $y + TEXT_HEIGHT);
    $data = \Barcode::fpdf($pdf, "000000", $pdf->GetX() + BARCODE_WIDTH / 2, $pdf->GetY() + BARCODE_HEIGHT / 2, 0, "ean13", array('code' => $product->barcode), BARCODE_WIDTH / (15 * 7), BARCODE_HEIGHT);
    $pdf->SetXY($x, $y + BARCODE_HEIGHT + TEXT_HEIGHT);
    $pdf->Cell(BARCODE_WIDTH, TEXT_HEIGHT, $product->barcode, 0, 1, "C");
}
Esempio n. 2
0
 public function addBarcode($code)
 {
     $fontSize = 2.4;
     $marge = 1;
     // between barcode and hri in pixel
     $x = $this->GetX() + 45;
     // barcode center
     $y = $this->GetY() + 6;
     // barcode center
     $height = 9;
     // barcode height in 1D ; module size in 2D
     $width = 0.37;
     // barcode height in 1D ; not use in 2D
     $angle = 0;
     // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
     $type = 'code39';
     $black = '000000';
     // color in hexa
     //$this->SetFont('Arial','B',$fontSize);
     $data = Barcode::fpdf($this, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
     //$this->SetFont('Arial','B',$fontSize);
     //$this->SetTextColor(0, 0, 0);
     $len = $this->GetStringWidth($data['hri']);
     Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
     $this->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
     $this->setLineWidth(0.12);
 }
Esempio n. 3
0
} else {
    $marge = 5;
    // between barcode and hri in pixel
    $x = 30;
    // barcode center
    $y = 120;
    // barcode center
    $height = 40;
    // barcode height in 1D ; module size in 2D
    $width = 1;
    // barcode height in 1D ; not use in 2D
}
// -------------------------------------------------- //
//            ALLOCATE FPDF RESSOURCE
// -------------------------------------------------- //
$pdf = new eFPDF('P', 'mm', array(102, 252));
// set the orentation, unit of measure and size of the page
$pdf->AddPage();
// -------------------------------------------------- //
//                      BARCODE
// -------------------------------------------------- //
$data = Barcode::fpdf($pdf, $black, $x, $y, $angle, $type, array('code' => $code), $width, $height);
$pdf->SetFont('Arial', 'B', $fontSize);
$pdf->SetTextColor(0, 0, 0);
$len = $pdf->GetStringWidth($data['hri']);
Barcode::rotate(-$len / 2, $data['height'] / 2 + $fontSize + $marge, $angle, $xt, $yt);
// -------------------------------------------------- //
//                      OUTPUT
// -------------------------------------------------- //
$pdf->TextWithRotation($x + $xt, $y + $yt, $data['hri'], $angle);
$pdf->Output();
Esempio n. 4
0
    // 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) {
        $type = 'code39';
    }
    $info = Barcode::fpdf($dummy, '000000', 0, 0, 0, $type, $code, 1 / 72, $basefontsize / 2 / 72);
    Barcode::fpdf($pdf, '000000', $label_width - $left_margin - $info['width'] / 2 - 2 / 72, $label_height - $vmargin - 7 / 72, 0, $type, $code, 1 / 72, $basefontsize / 2 / 72);
    // write the code
    $pdf->SetFontSize($size = $basefontsize / 2);
    $width = $pdf->GetStringWidth($item['code']);
    $pdf->Text($label_width - $width - $left_margin - 2 / 72, $label_height - $vmargin, $item['code']);
}
$tmpfname = tempnam("/tmp", "lab");
if ($_REQUEST['DEBUG']) {
    $pdf->Output("test.pdf", 'I');
    exit;
}
$pdf->Output($tmpfname, 'F');
$printer = LABEL_PRINTER;
shell_exec("lpr -P{$printer} {$tmpfname}");
echo jsonp(array("result" => "Printed."));