Php FPDI略微压缩了我导入的PDF

Php FPDI略微压缩了我导入的PDF,php,pdf,fpdf,fpdi,Php,Pdf,Fpdf,Fpdi,我使用的是FPDI和FPDF,当我导入具有全尺寸、美观设计的pdf时,出于某种原因,我保存在文件夹中的生成的pdf的大小略有修改,底部和右/左侧的大小略小/裁剪。如何按原样导入PDF?和原版一样大?提前谢谢 <?php use setasign\Fpdi\Fpdi; require_once('FPDF/fpdf.php'); require_once('FPDI/src/autoload.php'); // initiate FPDI $pdf = new Fpdi(); $pdf

我使用的是FPDI和FPDF,当我导入具有全尺寸、美观设计的pdf时,出于某种原因,我保存在文件夹中的生成的pdf的大小略有修改,底部和右/左侧的大小略小/裁剪。如何按原样导入PDF?和原版一样大?提前谢谢

<?php
use setasign\Fpdi\Fpdi;

require_once('FPDF/fpdf.php');
require_once('FPDI/src/autoload.php');

// initiate FPDI
$pdf = new Fpdi();

$pdf->setSourceFile('file.pdf');
$tplidx = $pdf->importPage(1);

$pdf->addPage();
$pdf->useTemplate($tplidx);

$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
$pdf->Write(8, 'This is an example of inputted text.');

$filename="test8.pdf";
$pdf->Output($filename, 'F');

?>

这是一个很好的问题,表明FPDI不修改PDF,而是允许您将页面导入到可重用的结构中

您在构造函数或addPage()调用中未定义页面大小,因此生成的页面大小为(默认大小)

如果以字母格式导入页面,则此导入页面将不适合A4页面-确定

有一些解决方案:

答:获取导入页面的大小,并使用以下参数调用AddPage():

$pageId = $this->ImportPage($pageNo);
$s = $this->getTemplatesize($pageId);
$this->AddPage($s['orientation'], $s);
$this->useTemplate($pageId); 
B:将/method的$adjustPageSize参数设置为true:

$this->AddPage();
$pageId = $this->ImportPage($pageNo);
$this->useTemplate($pageId, ['adjustPageSize' => true); 
我会建议解决方案A,因为它是直截了当的