1

Hello,

When I use "SetProtection()" and UTF-8, all "&" characters are replaced with a "A" with an accent.
Here is an example:

$html2pdf = new HTML2PDF('P','A4', 'en', false, 'UTF-8');
$html2pdf->writeHTML($content);
$html2pdf->pdf->SetProtection(array("print", "copy"), "", "my_passwd");
$html2pdf->Output("exemple01.pdf", "F");

Using ISO-8859-15 instead, or not using SetProtection doesn't produced this error.
The text that i want to display is a simple " " or "&".

Thank you in advance.

2

maybe try an utf8_decode on the string given to setprotection ?
et la le mec il le pécho par le bras et il lui dit '

3

have you try directly with TCPDF ? because setProtection is a nativ method of TCPDF. Maybe ther is a bug in it.
Ancien pseudo : lolo

4

Hello,

Thank you for your replies.

I tried with "utf8_encode()" to transform ISO-8859-15 to UTF-8 and "utf8_decode()" to transform UTF-8 to ISO-8859-15, but I still got the same error.

I then directly call the TCPDF encryption method: echo "[" . $this->_RC4($this->_objectkey($this->n), "&") . "]";
But the encoded string result is the same for both encodings, so I think it's not a bug in TCPDF but surely in html2pdf.

Can you please provide me a solution or a workaround?
Thank you in advance.

5

Got some news:

It's not the single "&" character that doesn't work, but the whole HTML entity:  
If I use "&nbsp" (without the ";" at the end) it displays the right "&nbsp".
I also tried with the equivalent HTML entity  
but it produced the same error (displays "A" with an accent)

I also tried to add $html2pdf->setDefaultFont("Arial");
but it didn't work either... sad