首页 > 解决方案 > 使用 Laravel 8 和 FPDM 从数据库中填充 PDF

问题描述

我正在尝试使用存储在我的数据库中的数据填充 PDF。我在 Homestead 上运行 laravel 8 作为我的本地机器。我已经安装了这个包:https ://github.com/codeshell/fpdm来做 PDF 工作。这是我要填写的 PDF 的链接:https ://f.hubspotusercontent00.net/hubfs/7522909/Free%20Downloads/BSS-CMS-1500-Fillable.pdf 。我正在使用的代码如下。

$claim = $this->claim->findOrFail($claimId);
$this->authorize('view', $claim);

$fields = [
    'topmostSubform[0].CMS1500Form[0].PatientName[0]' => 'My name'
];

$filePath = asset('files/cms1500.pdf'); // This is correct

$pdf = new \FPDM($filePath);
$pdf->Load($fields, false);
$pdf->Merge();
return $pdf->Output();

当我运行此代码时,它给了我以下异常:

fopen(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL 
routines:tls_process_server_certificate:certificate verify failed

实例化 FPDM 类时似乎失败了。有没有人遇到过这个或修复过?

标签: pdf-generationlaravel-8

解决方案


推荐阅读