【发布时间】:2022-12-15 18:34:54
【问题描述】:
我使用以下代码使用 php-pdftk 包填写 pdf 表单。
$pdf = new Pdf(public_path() . '/pdf/work_order.pdf');
$result = $pdf->fillForm([
'name_field' => 'sample name',
'email_field' => 'sample@ac.com',
'phone_field' => '0000000',
'enquiry_field' => 'Sample details page',
])
->needAppearances()
->saveAs(public_path() . '/pdf/work_order_filled.pdf');
这个代码库没有任何问题。我必须用字段名称填写另一个 pdf,如下所示,
/Fields [
<<
/V ()
/T (Client first and last name 2)
>>
<<
/V /Off
/T (Belting checkbox)
>>
<<
/V ()
/T (Confirmation time in)
>>
<<
/V ()
/T (Technician signature 2)
>>
<<
/V ()
/T (Client agreement number)
所以,我修改了代码库如下,
$pdf = new Pdf(public_path() . '/pdf/work_order.pdf');
$result = $pdf->fillForm([
'Client first and last name 2' => 'sample name',
'Belting checkbox' => 'sample@ac.com',
'Confirmation time in' => '0000000',
'Technician signature 2' => 'Sample details page',
])
->needAppearances()
->saveAs(public_path() . '/pdf/work_order_filled.pdf');
它会生成错误,而不会创建填充的 pdf 文件。上面给定的数组键(带有空格)中的问题。
所以,请帮我解决上述问题。
【问题讨论】: