FPDF mssql数组,单元格分页错误中的图像

时间:2015-05-20 00:07:36

标签: php fpdf

我试图用fpdf每页显示4张图片。我使用单元格和GetX和GetY来订购,这对我来说很有用,但是当创建一个新页面时,第一个单元格总是空的,它在所有页面中都很明显,只需在第一页显示就可以了。请帮我! 这是我的代码:

class PDF extends FPDF {
}
$pdf = new PDF('P','mm','Letter');
$pdf->SetFont('Times','',12);
$pdf->AddPage();
$con = mssql_connect(DB_HOST3, DB_USER3, DB_PASS3, DB_NAME3);
mssql_select_db("SBO_Amarillo", $con);
$result = mssql_query(" select ValeNo from dbo._SBOF_WebPage_ValesPorFactura ( CONVERT(VARCHAR,'$a')) order by ValeNo");
while($rows = mssql_fetch_array($result))
    {
        $documento = $rows['ValeNo'];
        $x = '.gif'; 
        $pdf->Cell( 160, 60, $pdf->Image(LAGGER.$documento.$x, $pdf->GetX(), $pdf->GetY(), 160,60), 1, 2, 'C', false );
        $pdf->ln(5);
    }
$pdf->Output('Boletas.pdf','I');

1 个答案:

答案 0 :(得分:0)

解决!我用这个:

$pdf = new PDF('P','mm','Letter');
$pdf->SetFont('Times','',10);
$pdf->AliasNbPages();
$pdf->SetMargins(15,15,10);
$image_height = 150;
$image_width = 58;
$pdf->AddPage();
$con = mssql_connect(DB_HOST3, DB_USER3, DB_PASS3, DB_NAME3);
mssql_select_db("SBO_Amarillo", $con);
$result = mssql_query(" select ValeNo,Nombre from dbo._SBOF_WebPage_ValesPorFactura ( CONVERT(VARCHAR,'$a')) order by ValeNo");
while($rows = mssql_fetch_array($result))
    {
        $documento = $rows['ValeNo'];
        $name = $rows['Nombre'];            
        $x = '.gif'; 
        $rr = '   ';            

        $start_x = $pdf->GetX();
        $start_y = $pdf->GetY();
        $pdf->Cell(10,10,$name.$rr.$documento,0,1,'L');
        $pdf->Image(LAGGER.$documento.$x, $pdf->GetX(), $pdf->GetY() ,$image_height, $image_width) ;
        $pdf->SetXY( $start_x , $start_y + $image_width + 10);
            if ($start_y  >= 150) 
                {
                    $pdf->AddPage();
                }
    }
$pdf->Output('Boletas.pdf','I');
谢谢你!