“对跳线造成的不便”;fpdf“;php
我正在使用“fpdf”库生成pdf,我遇到的问题是,当数组从那里开始换行到第二页时,它不会以相同的顺序显示,并且每条记录占用一页 第一页上的数组正在正常加载,但当此数组需要转到第2页时,从第2页开始,每页数组中都会出现一条记录,直到加载完整个数组为止 factura.php“对跳线造成的不便”;fpdf“;php,php,fpdf,Php,Fpdf,我正在使用“fpdf”库生成pdf,我遇到的问题是,当数组从那里开始换行到第二页时,它不会以相同的顺序显示,并且每条记录占用一页 第一页上的数组正在正常加载,但当此数组需要转到第2页时,从第2页开始,每页数组中都会出现一条记录,直到加载完整个数组为止 factura.php <?php //Activamos el almacenamiento en el buffer ob_start(); if (strlen(session_id()) < 1) session_st
<?php
//Activamos el almacenamiento en el buffer
ob_start();
if (strlen(session_id()) < 1)
session_start();
if (!isset($_SESSION["nombre"]))
{
echo 'Debe ingresar al sistema correctamente para visualizar el reporte';
}
else
{
if ($_SESSION['compras']==1)
{
require"../../modelos/Compras/Cotizacion.php";
$compras= new Cotizacion();
$rsptav = $compras->cotizacion_cabecera($_GET["id"]);
//Recorremos todos los valores obtenidos
$regv = $rsptav->fetch_object();
require('FacturaConfig.php');
$pdf = new PDF_Invoice( 'P', 'mm', 'A4' );
$pdf->AddPage();
$cols=array( "#"=>10,
"PRODUCTO"=>91,
"CANTIDAD"=>16,
"VALOR U."=>25,
"IVA%"=>12,
"IVA"=>14,
"SUBTOTAL"=>22);
$pdf->addCols( $cols);
$cols=array( "#"=>"L",
"PRODUCTO"=>"L",
"CANTIDAD"=>"C",
"VALOR U."=>"R",
"IVA%" =>"R",
"IVA" =>"R",
"SUBTOTAL"=>"C");
$pdf->addLineFormat( $cols);
$pdf->addLineFormat($cols);
$y= 89;
$rsptad = $compras->cotizacion_detalle($_GET["id"]);
while ($regd = $rsptad->fetch_object()) {
Static $a = 0;
$a++;
$line = array( "#"=> "$a",
"PRODUCTO"=> utf8_decode("$regd->nombre_producto"),
"CANTIDAD"=> "$regd->cantidad",
"VALOR U."=> "$regd->precio_ventax2",
"IVA%" => "$regd->porcentaje2",
"IVA" => "$regd->iva_calc",
"SUBTOTAL"=> "$regd->precio_ventax2");
$size = $pdf->addLine( $y, $line );
$y += $size + 2;
}
$pdf->Output();
}
else
{
echo 'No tiene permiso para visualizar el reporte';
}
}
ob_end_flush();
?>
FacturaConfig.php
<?php
require('../../public/fpdf181/fpdf.php');
define('EURO', chr(128) );
define('EURO_VAL', 6.55957 );
class PDF_Invoice extends FPDF
{
// private variables
var $colonnes;
var $format;
var $angle=0;
public function header()
{
$this->SetFont('Arial', 'B', '10');
$this->SetX(-40);
$this->write(5, 'codigo header');
$this->Image('logo.jpg', 0, 0, 20,'', 'jpg');
$this->Ln(10);
}
public function footer()
{
$this->SetFont('Arial', 'B', '10');
$this->SetY(-15);
$this->Write(5,'FOOTER');
}
// public functions
function sizeOfText( $texte, $largeur )
{
$index = 0;
$nb_lines = 0;
$loop = TRUE;
while ( $loop )
{
$pos = strpos($texte, "\n");
if (!$pos)
{
$loop = FALSE;
$ligne = $texte;
}
else
{
$ligne = substr( $texte, $index, $pos);
$texte = substr( $texte, $pos+1 );
}
$length = floor( $this->GetStringWidth( $ligne ) );
$res = 1 + floor( $length / $largeur) ;
$nb_lines += $res;
}
return $nb_lines;
}
function addCols( $tab )
{
global $colonnes;
$r1 = 10;
$r2 = $this->w - ($r1 * 2) ;
$y1 = 79;
$y2 = $this->h - 50 - $y1;
$this->SetXY( $r1, $y1 );
$this->Rect( $r1, $y1, $r2, $y2, "D");
$this->Line( $r1, $y1+6, $r1+$r2, $y1+6);
$colX = $r1;
$colonnes = $tab;
while ( list( $lib, $pos ) = each ($tab) )
{
$this->SetXY( $colX, $y1+2 );
$this->Cell( $pos, 1, $lib, 0, 0, "C");
$colX += $pos;
$this->Line( $colX, $y1, $colX, $y1+$y2);
}
}
function addLineFormat( $tab )
{
global $format, $colonnes;
while ( list( $lib, $pos ) = each ($colonnes) )
{
if ( isset( $tab["$lib"] ) )
$format[ $lib ] = $tab["$lib"];
}
}
function addLine( $ligne, $tab )
{
global $colonnes, $format;
$ordonnee = 10;
$maxSize = $ligne;
reset( $colonnes );
while ( list( $lib, $pos ) = each ($colonnes) )
{
$longCell = $pos -2;
$texte = $tab[ $lib ];
$length = $this->GetStringWidth( $texte );
$tailleTexte = $this->sizeOfText( $texte, $length );
$formText = $format[ $lib ];
$this->SetXY( $ordonnee, $ligne-1);
$this->MultiCell( $longCell, 4 , $texte, 0, $formText);
if ( $maxSize < ($this->GetY() ) )
$maxSize = $this->GetY() ;
$ordonnee += $pos;
}
return ( $maxSize - $ligne );
}
}
?>
PDF
第1页y 2
第3页