tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.19k stars 1.51k forks source link

Images in HTML rtl not aligned correctly #303

Open julienfelixweb opened 3 years ago

julienfelixweb commented 3 years ago

Hi I'm meeting this issue, is there a simple fix to solve this ?

RTL

Thanks

OTW-DEV-1 commented 3 years ago

I am also facing same problem. rtl images

alibarrak commented 3 years ago

you need to split your HTML (setRTL(false) before images)

for example image is in the middle:

$pdf->setRTL(true);
$html = 'some rtl text......';
$pdf->writeHTML($html, true, false, true, false, '');

$pdf->setRTL(false);
$html = '<img ....>';
$pdf->writeHTML($html, true, false, true, false, '');

$pdf->setRTL(true);
$html = 'some rtl text.....';
$pdf->writeHTML($html, true, false, true, false, '');
julienfelixweb commented 3 years ago

Thanks @alibarrak for this work around, unfortunately it won't fix it in my case. But it demonstrates that the img tag is not well handle in RTL. I'm sure it's an easy fix but I can't figure out where it is. It seams that in RTL images are systematically push to the right and the amount of this translation is equal to the width.

julienfelixweb commented 3 years ago

I did found a fix which I'm still testing. see #165

ctadri commented 3 years ago

I have found the same issue after the change from https://github.com/tecnickcom/TCPDF/issues/165, in my use case, I am calling TCPDF->Image() function directly to print an image as background of the whole page (I am not using the writeHTML function and the width of the image is the same as the width of the page) I was able to fix it with this code: https://github.com/tecnickcom/TCPDF/commit/b543e4df6289be5918e0054b9cc2605d5e5f0889#commitcomment-54402407

This is just a quickfix, which could solve https://github.com/tecnickcom/TCPDF/issues/303 but maybe creates more problems with https://github.com/tecnickcom/TCPDF/issues/165

Maybe someone else can give it a try, if both issues are working we could submit a MR.

williamdes commented 2 years ago

Seems to be fixed with #510