$res = mysql_query($str);
$no = 0;
while ($bar = mysql_fetch_object($res)) {
    $no += 1;
    $kodebarang = $bar->kodebarang;
    $satuan = $bar->satuan;
    $jumlah = $bar->jumlah;
    $namabarang = '';
    $strv = "select namabarang from " . $dbname . ".log_5masterbarang where kodebarang='" . $bar->kodebarang . "'";
    $resv = mysql_query($strv);
    while ($barv = mysql_fetch_object($resv)) {
        $namabarang = $barv->namabarang;
    }
    $pdf->Cell(8, 5, $no, 1, 0, 'L', 1);
    $pdf->Cell(30, 5, $kodebarang, 1, 0, 'L', 1);
    $pdf->Cell(85, 5, printSpecialChar($namabarang), 1, 0, 'L', 1);
    $pdf->Cell(18, 5, $satuan, 1, 0, 'L', 1);
    $pdf->Cell(20, 5, number_format($jumlah, 2, '.', ','), 1, 0, 'R', 1);
    $pdf->Cell(25, 5, $bar->kodeblok, 1, 1, 'C', 1);
}
$pdf->MultiCell(170, 5, "Note: " . $catatan, 0, 'L');
//footer================================
$pdf->Ln();
//get user;
$namakaryawan = namakaryawan($dbname, $conn, $userid);
$pdf->Cell(20, 4, $_SESSION['lang']['dbuat_oleh'], 0, 0, 'L');
$pdf->Cell(40, 4, ": " . $namakaryawan, 0, 1, 'L');
//get posted by
if ($posted != '') {
    $posted = namakaryawan($dbname, $conn, $posted);
} else {
$pdf->Cell(190, 1.5 * $height, $_SESSION['lang']['keterangan'], 'TBLR', 0, 'C');
$akhirXket = $pdf->GetX();
$pdf->Ln();
$awalYbanget = $pdf->GetY();
//echo $awalYbanget.__;
$no = 0;
foreach ($result as $data) {
    $pdf->SetFont('Arial', '', 7);
    $awalXno = $pdf->GetX();
    $no++;
    $pdf->SetY($awalYbanget);
    $pdf->Cell(20, $height, $no, 0, 0, 'L');
    $pdf->Cell(60, $height, $data['kodebarang'], 0, 0, 'L');
    $awalYnmbrg = $pdf->GetY();
    $awalXnmbrg = $pdf->GetX() + 165;
    $pdf->MultiCell(165, $height, printSpecialChar($data['namabarang']), '0', 'L');
    $akhirYnmbrg = $pdf->GetY();
    $pdf->SetXY($awalXnmbrg, $awalYnmbrg);
    //$pdf->Cell(80,$height,$data['spesifikasi'],'TBLR',0,'L');
    $pdf->Cell(35, $height, number_format($data['jumlah'], 2), 0, 0, 'C');
    $pdf->Cell(35, $height, $data['satuan'], '0', 0, 'C');
    $pdf->Cell(40, $height, tanggalnormal($data['tgl_sdt']), '0', 0, 'L');
    //$pdf->SetFont('Arial','',6.5);
    //$height=12;
    $akhirXket = $pdf->getX() + 190;
    $pdf->MultiCell(190, $height, $data['keterangan'], '0', 'L');
    $pdf->SetFont('Arial', 'I', 7);
    if ($data['keteranganubah'] != '') {
        $pdf->SetX(385);
        $pdf->SetFillColor(240, 240, 240);
        $pdf->MultiCell(150, $height, "- Barang diatas diubah dengan catatan: " . $data['keteranganubah'], '0', 'L');