2013-05-06 80 views

回答

3

既然你想要的條形碼是可視化的單元中寫入的名字裏面,你需要做一個小的定位。單元格和條形碼方法更新當前位置。如果您編寫條形碼,然後將位置重置爲條形碼調用之前的位置,然後寫入名稱單元格,它應該放在名稱單元格內的某個位置。

//I'll provide the cell width in write1DBarcode to center the barcode. 
$style['cellfitalign'] = 'C'; 
foreach ($pages as $pk => $p) { 
    // add a page 
    $pdf->AddPage(); 
    foreach ($p as $lk => $l) { 
     foreach ($l as $ck => $c) { 
      //Get current write position. 
      $x = $pdf->GetX(); 
      $y = $pdf->GetY(); 
      // The width is set to the the same as the cell containing the name. 
      // The Y position is also adjusted slightly. 
      $pdf->write1DBarcode($c->id, 'C128B', '', $y-8.5, 105, 18, 0.4, $style, 'M'); 
      //Reset X,Y so wrapping cell wraps around the barcode's cell. 
      $pdf->SetXY($x,$y); 
      $pdf->Cell(105, 51, $c->nome, 1, 0, 'C', FALSE, '', 0, FALSE, 'C', 'B'); 
     } 
     $pdf->Ln(); 
    } 
} 

這是結果我現在得到:

This is the result I get now

相關問題