tcpdf html表行超过500行导致空白页面

问题描述 投票:0回答:1

我正在使用TCPDF从数据库中获取PDF报告,但是当表格行限制达到400时,其结果为空白页面。是否有任何解决方案。请帮助

这是我的代码。

    <?php
$start = microtime(true);
ini_set('memory_limit','256M');
ini_set('max_execution_time', 300);
error_reporting(0);
 $username=$_GET['user'];
 $todate=$_GET['date'];
date_default_timezone_set("Asia/Karachi");

 /*** PDF Report CODE ****/

  require_once("tcpdf/tcpdf.php");

  class MYPDF extends TCPDF {

    //Page header
    public function Header() {
        // Logo
        $image_file = 'img/pdf_logo.JPG';
        $this->Image($image_file, 10, 10, 25, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $title='

        ';

        $this->Cell(0, 15, 'XYZ ', 0, false, 'C', 0, '', 0, false, 'M', 'M');


    }

    // Page footer
    public function Footer()
     {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
        $this->Ln(4);
        $xfooter=' <table cellspacing="0" cellpadding="1" border="0" align="left">
  <tr align="left"><td colspan="5">'.$_SERVER['HTTP_REFERER'].'</td></tr>
  </table>        <table cellspacing="0" cellpadding="1" border="0" align="right">
  <tr align="right"><td colspan="5">Printed by:'.$GLOBALS['username'].' ('.date("Y-m-d h:i:sa").')</td></tr>
  </table>';

        $this->writeHTML($xfooter);

    }
}
$pdf= new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

  // set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ERP Dashboard');
$pdf->SetTitle('XYZ');
$pdf->SetSubject('test Reports');
$pdf->SetKeywords('test, PDF, test, Reports, dashboard');



// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(5,24,2);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}

// ---------------------------------------------------------

// set font
$pdf->SetFont('times', '', 10);      
      $pdf->AddPage('P', 'A4');
      $content = '';
      $content.='
              <h2 style="text-decoration: underline;" align="center"><b> Allocated/Unallocated Stock Report for-'.$GLOBALS['todate'].'</b></h2>  
                                <table border="1px" cellspacing="0" cellpadding="0" width="95%">
                                <thead>
                                    <tr>    
                                        <th rowspan="2" style="vertical-align: middle;">Sr.</th>
                                        <th rowspan="2" style="vertical-align: middle;">Item Id</th>
                                        <th rowspan="2" style="vertical-align: middle;">Item Description</th>
                                        <th rowspan="2" style="vertical-align: middle;">Category</th>

                                        <th colspan="2" align="center" class="text-center">
                                            Allocated Qty 
                                        </th>
                                       <th colspan="2" align="center" valign="middle"  class="text-center">Unallocated Qty</th>
                                       <th rowspan="2" class="text-center" style="vertical-align: middle;">Total Stock Qty</th>
                                       <th rowspan="2" class="text-center" style="vertical-align: middle;">Avg Rate</th>
                                       <th rowspan="2" class="text-center" style="vertical-align: middle;">Value</th>
                                    </tr>
                                    <tr>
                                      <th  class="center"><small>FOC Wise</small></th>
                                      <th  class="center"><small>Without FOC</small></th>
                                      <th  class="center"><small>FOC Wise</small></th>
                                      <th  class="center"><small>Without FOC</small></th>
                                    </tr>
                                </thead>
      ';
      $content .= get_data();  
      $content .= '</table>';  
      $pdf->writeHTML($content);
  $pdf->Output('Allocated/Unallocated_Stock Report-('.$GLOBALS['todate'].').pdf', 'D'); 



 /**** End PDF CODE******/


 ?>

我正在使用TCPDF从数据库中获取PDF报告,但是当表格行限制达到400时,其结果为空白页面。是否有任何解决方案。请帮助

这是我的代码。

php pdf report tcpdf
1个回答
0
投票

试试这个......它会起作用。你必须将'memory_limit'设置为高。

set_time_limit(0);
ini_set('pcre.backtrack_limit', '10000000');
ini_set('memory_limit', '4060M');
© www.soinside.com 2019 - 2024. All rights reserved.