为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
哆啦的时光机 2021-06-29 15:05:50
我正在尝试在 laravel 中编辑 pdf。我在我的控制器中创建了以下函数,它具有use FPDI和use FPDFstatic 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 !"
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 290 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信