tomi/pdf-forms-filler

使用纯PHP轻松填充Acrobat表单

1.2.1 2018-10-11 00:07 UTC

This package is auto-updated.

Last update: 2024-09-25 22:42:55 UTC


README

forthebadge forthebadge

Build Status Coverage Status Total Downloads License composer.lock

使用纯PHP轻松填充Acrobat表单

要求

  • PHP >= 7.1.0

安装

$ composer require tomi/pdf-forms-filler

示例

  • 克隆仓库
  • 转到示例文件夹
  • composer install
  • 运行 index.php

使用方法

您需要使用Acrobat创建PDF表单,并且要转换的字符串由本页面提供

查找表单字段坐标

使用转换器,该转换器提供了一个包含具有位置/页面的字段的JSON数组,这些字段可以用作生成器的形式

$converter = new Converter($string);
$converter->getPagesWithFieldsCount();
$json = $converter->formatFieldsAsJson($pages);

echo json;

使用PDF生成器,其中一个数组包含每个具有id -> value的字段,另一个数组包含每个具有id -> llx, lly, urx, ury, page的字段

$pdfGenerator = new PDFGenerator($coords, $data, 'P', 'pt', 'A4');
$pdfGenerator->start($original, $dest);

如果您的原始PDF不是由fpdf处理的,您可以使用此服务进行转换

将PDF转换为 "Acrobat 4.0 (PDF 1.3)"

对于要发送给生成器的文件中的表单字段,无需关心,位置是使用最新的PDF格式确定的。

如果您需要一个完整的示例: index.php

测试

$ ./vendor/bin/phpunit tests

代码覆盖率

$ ./vendor/bin/phpunit tests --coverage-text --coverage-clover build/logs/clover.xml

完成。 ;)