TCPDF SetProtection problem

I followed the tutorial TCPDF example 16 to create a protected pdf document. The pdf was generated but the SetProtection properties did not seem to work. Did I miss anything? here is the example code.

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, ‘UTF-8’, false);
$pdf->SetProtection(array(‘print’), ‘’, null, 0, null);
$pdf->SetFont(‘times’, ‘’, 16);
$pdf->Write(0, ‘Can I copy?’, ‘’, 0, ‘L’, true, 0, false, false, 0);

Thanks!

I think this is more related to ask on TCPDF community

Thanks for your reply. It is a Scriptcase problem. For some reason, the SetProtection() method isn’t called within the PDF Report. I fixed it by changing the grid class php source code. But I will have to change the code again everytime the report is regenerated.

And what exactly did you has to change?

xx_grid.class.php, look for line

$pdf->SetProtection(array(‘copy’), ‘’, null, 0, null);

and change to

$this->Pdf->SetProtection(array(‘copy’), ‘’, null, 0, null);

If you add one more parameter at the end of the class-instantiation for switching off PDFA-mode, then the setProtection-function does it’s thing.

As in:

//TCPDF::__construct($orientation = ?P?,$unit = ?mm?,$format = ?A4?,$unicode = true,$encoding = ?UTF-8?,$diskcache = false,$pdfa = false );
$pdf = new TCPDF(‘P’, ‘mm’, ‘A4’, FALSE, ‘ISO-8859-15’, false, false);

And then after printing the generated and secured PDF-document to a PDF-printer all protection set by setProtection is lost again… :slight_smile: