我想保护我的pdf密码。
我正在使用kartik \ mpdf \ Pdf扩展名来生成pdf。
$pdf = new Pdf([
// set to use core fonts only
'mode' => Pdf::MODE_CORE,
// A4 paper format
'format' => Pdf::FORMAT_A4,
// portrait orientation
'orientation' => Pdf::ORIENT_PORTRAIT,
// stream to browser inline
'destination' => Pdf::DEST_FILE,
// your html content input
'content' => $html,
// any css to be embedded if required
'cssFile' => '@api/web/css/notes.css',
// set mPDF properties on the fly
'options' => ['title' => $note['title']],
// call mPDF methods on the fly
'methods' => [
'SetHeader' => [''],
'SetFooter' => [''],
],
]);
$pdf->content = $html;
$file_name = "test" . rand(7, 100).pdf";
$password = "122":
$pdf->setProtection(array(),$password);
$pdf->filename = "uploads/" . $file_name;
echo $pdf->render();
但是它给我类似以下错误:调用未知方法:kartik \ mpdf \ Pdf :: setProtection();
我也尝试过下面的将文件名放在方法后面的代码:
$pdf->filename->setProtection(array(), $password);
但是它也会给我类似以下错误:在字符串上调用成员函数setProtection()。
我知道setProtection方法在供应商的kartik库中可用,但我不确定如何使用它。
[如果有人有想法,请帮助我。
尝试
$pdf->getApi()->setProtection();
方法getApi()
是直接调用MPDF对象,也就是SetProtection()
方法所在的位置。