如何使用 FPDF-php 根据我的图像大小增加纸张大小​​?

How to increase the paper size as per my image size using FPDF-php?

当我尝试使用 PHP 和 FPDF 插入图像时,图像未以 PDF 格式显示为原始图像。

我从这个 link

得到了 fPDF

使用上面的下面代码link

require('lib/fpdf.php');
        $image = MEDIA_DIR."uploads/".$report_img.".png";
        $pdf = new FPDF();
        $pdf->AddPage();
        $pdf->Image($image,10,10,200,500);
        $pdf->Output();

我无法按原样加载 1000px*10000px 大小的图像,它显示为压缩文件。

如何根据我的图像大小增加纸张大小​​?

我通过将我的图像添加到如下所示的单元格中得到它

require('lib/fpdf.php');
        $image = MEDIA_DIR."uploads/pdf_images/".$report_img.".png";
        list($width, $height, $type, $attr) = getimagesize($image);
        $pdf = new FPDF();
        $pdf->SetSize(($width/2)+110,($height*57/100)); //Custom function
        $pdf->AddPage('','custom');
        $pdf->cell(1000,1000,'',$pdf->Image($image,10,10,235,$height*18/100),'PNG');
        $pdf->Output();

将以下函数添加到 fpdf.php

function SetSize($width,$height)
{
    $this->StdPageSizes['custom']=array($width,$height);
}