madnh / fpdi-protection
Setasign FPDI-Protection 的 Composer 版本
1.0.6
2016-06-28 04:34 UTC
Requires
- php: >=5.3.0
- setasign/fpdi: ^1.6
This package is not auto-updated.
Last update: 2024-09-28 19:20:36 UTC
README
Setasign FPDI-Protection 和 FPDF 保护脚本的 Composer 版本 Setasign FPDI-Protection 以及 FPDF Protection script
此脚本允许保护 PDF,即防止人们复制其内容、打印或修改它。
安装
composer require madnh/fpdi-protection
用法
SetProtection([number permissions [, string user_pass [, string owner_pass]]])
- 权限:权限集合。默认为空(只有查看权限)。
- 用户密码:用户密码。默认为空。
- 所有者密码:所有者密码。如未指定,则使用随机值。
权限
权限数组包含以下列表中的值
- FPDI_Protection::CAN_PRINT:打印文档
- FPDI_Protection::CAN_MODIFY:修改(除注释和表单外)
- FPDI_Protection::CAN_COPY:复制文本和图像到剪贴板
- FPDI_Protection::CAN_ANNOT_FORMS:添加注释和表单
示例
$src_file = 'source.pdf'; $dest_file = 'protected.pdf'; $pdf = new \FPDI_Protection(); $pagecount = $pdf->setSourceFile($src_file); for ($loop = 1; $loop <= $pagecount; $loop++) { $tplidx = $pdf->importPage($loop); $pdf->addPage(); $pdf->useTemplate($tplidx); } $pdf->SetProtection(\FPDI_Protection::FULL_PERMISSIONS); //$pdf->SetProtection(\FPDI_Protection::FULL_PERMISSIONS, '123456'); //$pdf->SetProtection(\FPDI_Protection::FULL_PERMISSIONS, '123456', 'ABCDEF'); $pdf->Output($dest_file, 'F');
重要
一些 PDF 阅读器(如 Firefox)会忽略保护设置,这大大降低了此脚本的有用性。