使用 FPDI 时使用正确的源 URL 出现“无法打开 pdf”错误

我正在尝试在 laravel 中编辑 pdf。我在我的控制器中创建了以下函数,它具有use FPDI和use FPDF


static function getHigherPDF() {


    $pdf = new FPDI();

    $pdf->AddPage();

    $pdf->setSourceFile('/pdf/higher.pdf');

    $tplIdx = $pdf->importPage(1);

    $pdf->useTemplate($tplIdx, 10, 10, 100);

    $pdf->Output();

    $pdf->SetFont('Helvetica');

    $pdf->SetTextColor(255, 0, 0);

    $pdf->SetXY(30, 30);

    $pdf->Write(0, 'This is just a simple text');


    return $pdf;


}

我不断收到以下错误,我不知道为什么,如果我将带有 http:// 等的完整路径放到 pdf 中,我什至会收到错误。当我转到该文件时,pdf 会在我的浏览器中打开。如果文件 url 是有效的 url,我找不到任何关于为什么会发生这种情况的信息


有任何想法吗?


{message: "Cannot open /pdf/higher.pdf !", exception: "InvalidArgumentException",...}

exception: "InvalidArgumentException"

file: "/home/vagrant/code/brainskills-at-work/vendor/setasign/fpdi/pdf_parser.php"

message: "Cannot open /pdf/higher.pdf !"


哆啦的时光机
浏览 291回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP