gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:08:03 27 4
gpt4 key购买 nike

有没有办法阻止接收者在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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com