问题
I’m working with the FPDF library to generate PDFs.
At some point I include an image into the pdf (in the header) and do:
require_once APPPATH . '../vendor/setasign/fpdf/fpdf.php';
class cifpdf extends FPDF {
public function __construct($params = array())
{
$this->CI = &get_instance();
$orientation = array_key_exists('orientation', $params) ? $params['orientation'] : 'P';
$mesure = array_key_exists('mesure', $params) ? $params['mesure'] : 'mm';
$format = array_key_exists('format', $params) ? $params['format'] : 'A5';
parent::__construct($orientation, $mesure, $format);
}
public function Header()
{
$logo = base_url('assets/promoters-landingpage/img/logo-inverted.png');
// Logo
$this->Image($logo, 10, 6, 30);
$this->Rect(10, 17, 129, 0.1);
// Saut de ligne
$this->Ln(10);
}
My issue is coming from the $this->Image($logo, 10, 6, 30);
line
Looking at the Image function in the pdf vendor library, I tried to debug and found out the bug was coming from this part:
function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='')
{
// Some Code
if(!isset($this->images[$file]))
{
// Some Code
$type = strtolower($type);
if($type=='jpeg')
$type = 'jpg';
$mtd = '_parse'.$type;
if(!method_exists($this,$mtd))
$this->Error('Unsupported image type: '.$type);
$info = $this->$mtd($file);
// Some Code
}
// Some Code
}
So the exact line that causes the time out error is $info = $this->$mtd($file);
(line 885 in the library).
I;m not sure what $mtd is? It seems defined a few lines above in $mtd = '_parse'.$type;
but they do not associate it to $this. Not sure what is this.
I’m using Nginx. That same piece of code was working fine on Apache 2.
Thanks for your support.
来源:https://stackoverflow.com/questions/40163580/fpdf-script-timed-out