FPDF setSourceFile 源文件问题

FPDF setSourceFile source file issue

大家好,我是 codeigniter 的新手

我正在使用 fpdf 和 fpdfi 创建和附加 pdf 文件。

我有一些愚蠢的问题如下

当我将文件路径发送为

$pdfPath="./public/site/userdocuments/sagar/RetData/1.pdf";
$pdf -> setSourceFile($pdfPath);

然后它就可以工作了,但是当我尝试使 pdf 文件动态化时,如下所示

$filename="1.pdf";
$pdfPath="./public/site/userdocuments/sagar/RetData/".$filename;
$pdf -> setSourceFile($pdfPath);

然后它抛出如下错误

InvalidArgumentException: Cannot open http://10.0.11.114:8888/start.spaceParse/public/site/userdocuments/sagar/RetData/1.pdf in /Applications/MAMP/htdocs/start.spaceParse/application/libraries/pdfResources/pdf_parser.php on line 192

我已经研究过它以及与文件未找到问题相关的问题。我不明白它有什么问题。

感谢任何帮助..

提前致谢

抱歉英语不好..

使用本地路径而不是 URI。

您的代码看起来像本地路径,但错误消息 "says" 有所不同。

我尝试了 explode 功能。尝试将您的代码更改为如下内容:

$filename="1.pdf";
$newString= explode(".",$filename);
$pdfPath="./public/site/userdocuments/sagar/RetData/".newString[0].".pdf";