php - 防止复制使用 dompdf 创建的 pdf 中的内容

标签 php file email pdf dompdf

有没有办法阻止接收者在dompdf中选择和复制pdf文件的内容?

像其他pdf文件一样,打开后是图片,所有的字母和图片都无法选择?

最佳答案

您可以使用底层 CPDF 引擎来指定用户可以对文档执行的操作。根据 CPDF 文档:

Calling [the setEncryption()] function sets up the document to be encrypted, this is the only way to mark the document so that they user cannot use cut and paste, or printing.

Using the call without options, defaults to preventing the user from cut & paste or printing. There are no passwords require to open the document.

Setting either off the passwords will mean that the user will have to enter a password to open the document. If the owner password is entered when the document is opened then the user will be able to print etc. If the two passwords are set to be the same (or the owner password is left blank) then there is no owner password, and the document cannot be opened in the accesible mode.

The pc array can be used to allow specific actions. The following example, sets an owner password, a user password, and allows printing and cut & paste.

$pdf->setEncryption('trees','frogs',array('copy','print'));

使用上面的示例,您将首先使用 dompdf 呈现文档,然后按照以下行发出一些内容:

$dompdf->get_canvas()->get_cpdf()->setEncryption('trees','frogs',array('copy','print'));

( original on Google Groups )

关于php - 防止复制使用 dompdf 创建的 pdf 中的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190294/

相关文章:

c - 尝试创建txt文件,但提示无法打开文件

delphi - 我可以设置什么文件的创建/上次修改/上次访问?

php - 在 Php 中以带换行符的纯文本格式发送 XML 电子邮件

email - 如何在不向其发送任何内容的情况下检查电子邮件地址是否有效?

php - PHP 表单内的特定字体系列

php - 使用两行脚本记住页面位置

java - 在用java编写时限制文件大小

python - 从 Flask 中的用户获取正确的 IP 地址

php - 使用 PHPUnit 在 php 中测试关闭例程 (register_shutdown_function)

php - 子查询问题