Пример #1
0
 /**
  * Objekte auf PDF zeichnen
  *
  * @param array $templ
  * @param array $data
  */
 function _write_object($templ, $data)
 {
     global $barcode;
     for ($i = 0; $i < count($templ); $i++) {
         if ($templ[$i]['user_type'] == $row['type'] || $templ[$i]['user_type'] == "0") {
             switch ($templ[$i]['type']) {
                 case 'text':
                     $this->pdf->SetFont($templ[$i]['font'], '', $templ[$i]["fontsize"]);
                     $this->pdf->SetTextColor($templ[$i]["red"], $templ[$i]["green"], $templ[$i]["blue"]);
                     if ($templ[$i]['end_x'] == "1") {
                         $this->pdf->Text($templ[$i]["pos_x"] - $this->pdf->GetStringWidth($templ[$i]['text']) + $this->x, $templ[$i]["pos_y"] + $this->y, $templ[$i]['text']);
                     } else {
                         $this->pdf->Text($templ[$i]["pos_x"] + $this->x, $templ[$i]["pos_y"] + $this->y, $templ[$i]['text']);
                     }
                     break;
                 case 'rect':
                     $this->pdf->SetDrawColor($templ[$i]["red"], $templ[$i]["green"], $templ[$i]["blue"]);
                     if ($templ[$i]['fontsize'] == "1") {
                         $this->pdf->SetFillColor($templ[$i]["red"], $templ[$i]["green"], $templ[$i]["blue"]);
                         $this->pdf->Rect($templ[$i]['pos_x'] + $this->x, $templ[$i]['pos_y'] + $this->y, $templ[$i]['end_x'], $templ[$i]['end_y'], "FD");
                     } else {
                         $this->pdf->SetFillColor(255);
                         $this->pdf->Rect($templ[$i]['pos_x'] + $this->x, $templ[$i]['pos_y'] + $this->y, $templ[$i]['end_x'], $templ[$i]['end_y']);
                     }
                     break;
                 case 'line':
                     $this->pdf->SetDrawColor($templ[$i]["red"], $templ[$i]["green"], $templ[$i]["blue"]);
                     $this->pdf->Line($templ[$i]['pos_x'] + $this->x, $templ[$i]['pos_y'] + $this->y, $templ[$i]['end_x'] + $this->x, $templ[$i]['end_y'] + $this->y);
                     break;
                 case 'image':
                     $this->pdf->Image(IMAGE_PATH . $templ[$i]['text'], $templ[$i]['pos_x'] + $this->x, $templ[$i]['pos_y'] + $this->y, $templ[$i]['end_x'], $templ[$i]['end_y']);
                     break;
                 case 'barcode':
                     $imagename = mt_rand(100000, 999999);
                     $barcode->get_image($data['userid'], BARCODE_PATH . $imagename);
                     $this->pdf->Image(BARCODE_PATH . $imagename . ".png", $templ[$i]['pos_x'] + $this->x, $templ[$i]['pos_y'] + $this->y);
                     $barcode->kill_image(BARCODE_PATH . $imagename);
                 case 'data':
                     $this->pdf->SetFont($templ[$i]['font'], '', $templ[$i]["fontsize"]);
                     $this->pdf->SetTextColor($templ[$i]["red"], $templ[$i]["green"], $templ[$i]["blue"]);
                     if ($templ[$i]['end_x'] == "1") {
                         $this->pdf->Text($templ[$i]["pos_x"] - $this->pdf->GetStringWidth($data[$templ[$i]['text']]) + $this->x, $templ[$i]["pos_y"] + $this->y, $data[$templ[$i]['text']]);
                     } else {
                         $this->pdf->Text($templ[$i]["pos_x"] + $this->x, $templ[$i]["pos_y"] + $this->y, $data[$templ[$i]['text']]);
                     }
                     break;
             }
         }
     }
 }
Пример #2
0
$p->SetFont('Arial', '', 8);
$w = 10;
$h = 10;
$off_h = 5;
$off_w = 40;
//***************************Heading
for ($i = 0; $i < $ncols; $i++) {
    $colname = mysql_fetch_field($result);
    $nome = $colname->name;
    $tabella = $colname->table;
    if ($tabella == "") {
        $field = "{$nome}";
    } else {
        $field = "{$tabella}.{$nome}";
    }
    $p->Text($w, $h, $field);
    $w = $w + $off_w;
}
//****************************************
$w = 10;
$h = $h + $off_h;
while ($row = mysql_fetch_array($result)) {
    for ($i = 0; $i < $ncols; $i++) {
        $colvalue = $row[$i];
        $p->Text($w, $h, $colvalue);
        $w = $w + $off_w;
    }
    $h = $h + $off_h;
    $w = 10;
    if ($h > 200) {
        $p->AddPage();