eureka2/acroforms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eureka2/acroforms

最新稳定版本:1.0.6

Composer 安装命令:

composer require eureka2/acroforms

包简介

PDF form filling

README 文档

README

This library is a complete rewrite for php> = 7.1 of script93 developed by Olivier, with additional features:

  • Supports linearized PDF forms
  • Supports multi-pages PDF forms
  • Supports PDF 'radio', 'check box' and 'choice' fields in addition to 'text' fields
  • UTF-8 support

With this library, you can merge (inject) data into a PDF form (AcroForm), either from a PHP array, or from a FDF file.

Dependency

Installation

composer require eureka2/acroforms

Usage

  • With a PHP array:
<?php

require_once 'path/to/src/autoload.php';

use acroforms\AcroForm;

$fields = [
    'text' => [ // text fields 
        'text_field1'    => 'value of text_field1',
        'text_field2'    => 'value of text_field2',
        ......
    ],
    'button' => [ // button fields
        'radio1' => 'value of radio1',
        'checkbox1' => 'value of checkbox1',
        ........
    ]
];

$pdf = new AcroForm('exemple.pdf', [
    'pdftk' => '/absolute/path/to/pdftk'
]);
$pdf->load($fields)->merge();
if (php_sapi_name() == 'cli') {
	file_put_contents("filled.pdf", $pdf->output('S'));
} else {
	$pdf->output('I', 'filled.pdf');
}
?>
  • With a pre-filled FDF file:
<?php

require_once 'path/to/src/autoload.php';

use acroforms\AcroForm;

$pdf = new AcroForm('example.pdf', [
    'fdf' => 'example.fdf',
    'pdftk' => '/absolute/path/to/pdftk'
]);
$pdf->merge();
if (php_sapi_name() == 'cli') {
    $pdf->output('F', 'filled.pdf');
} else {
    $pdf->output('I', 'filled.pdf');
    // or $pdf->output('D', 'filled.pdf');
}
?>

Methods

Name Arguments Description
allow 1. permissions : array (optional) Allow permissions
compress use the compress filter to restore compression
encrypt 1. bits : int (0, 40,or 128) define encrytion to the given bits
fix try to fix a corrupted PDF file
flatten flatten output to remove form from pdf file keeping field datas
getButtonFields Retrieve fields that are buttons
getField 1. fieldName Retrieve a form field by its name
getTextFields Retrieve fields that are text type
info Retrieve information from the pdf
load 1. data : array or string load a form data to be merged
merge 1. flatten : bool (optional) Merge the data with the PDF file
password 1. type : string ('owner' or 'user')
2. code : string (password code)
define a password code
setMode 1. mode : string
2. value : bool
set a mode
setSupport 1. support : string (native or pdftk) change the support
uncompress apply the uncompress filter
output 1. destination : char (I, D, F or S)
2. name : string (PDF file name)
output PDF to some destination

Copyright and license

© 2019 Eureka2 - Jacques Archimède. Code released under the MIT license.

统计信息

  • 总下载量: 4.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-01