不方便跳转到“ fpdf” php行

如何解决不方便跳转到“ fpdf” php行

我正在使用“ fpdf”库生成pdf,我遇到的问题是,当它从第二行开始到第二页换行时,数组未按相同的顺序显示,并且每条记录占用一页

第一页上的阵列正在正常加载,但是当该阵列需要转到第2页时,从第2页开始每页的阵列中会出现一条记录,直到完成加载整个阵列为止。

factura.php

 <?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',20,'','jpg');
   
   $this->Ln(10);
    
     
   }
    
   public function footer()
   {
     $this->SetFont('Arial','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,"C");
        $colX += $pos;
        $this->Line( $colX,$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,$formText);
        if ( $maxSize < ($this->GetY()  ) )
            $maxSize = $this->GetY() ;
        $ordonnee += $pos;
    }
    return ( $maxSize - $ligne );
}




}
?>

PDF

Outcome link

第1页和第2页

第3页 Link

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-