0

I'm using html2pdf and passing $this->renderpartial('view',array(..),true) to the $content.

Here's the code:

$content = $this->renderpartial('view',array(..),true);     
$html2pdf = new HTML2PDF('P','A4','en');
$html2pdf->pdf->SetDisplayMode('real');
$html2pdf->WriteHTML($content);
$html2pdf->Output('/var/www/myapp/images/example.pdf','F');

The view declares an otf font.. which I have succesfully imported into tcpdf using an online-converter.

But the output of the pdf has some arabic, but some of the letters and weirdly english letters into squares. What's worse is that even though in my html there's the directive of RTL .. some parts of the document are still in LTR.

I have the output html with me if you need to see it.. without the html2pdf bit.. straight out from the $this->renderpartial. If you need it I'll paste it or attach as an image.

omar-ali
  • 507
  • 4
  • 14
  • remember you need a complete html in your view that is being renderParialed, like html opening an ending and body tag and ... – Developerium Dec 09 '13 at 08:06
  • All that's there.. ... There's some php stuff inside though, but that anyway renderpartial takes care of right? – omar-ali Dec 09 '13 at 08:08
  • Apparently html2pdf doesn't support arabic. See this thread http://stackoverflow.com/questions/12647917/converting-html-to-pdf-with-arabic – Joe Miller Dec 09 '13 at 08:10
  • html2pdf relies on tcpdf.. tcpdf supports Arabic.. I've been through that thread, and it says in a convoluted way, that yes, html2pdf should be supporting arabic.. I am getting a lot of arabic letters in the output.. the irony is that the english stuff isn't coming out and a few other letters..could it be my fonts file is not proper? – omar-ali Dec 09 '13 at 08:12

3 Answers3

2

Add this method, it will solve the Arabic problem in the PDF.

$html2pdf->setDefaultFont('aealarabiya');
bad_coder
  • 11,289
  • 20
  • 44
  • 72
1

html2pdf does support arabic I'm using it. You ave to specify the font in the page tag and wrap the rest of your HTML code within the tag.

<page backtop="10mm" backbottom="20mm" backleft="20mm" backright="20mm" style="font-family: dejavusans">

#rest of HTML code here

</page>
Kal
  • 11
  • 1
0

Ok, so there is no problem. It's just that the font I used didn't get converted to the desired tcpdf format fully. Some characters are missing, including the english character-set.

I tried with another arabic included font and things worked fine.

This is important: html2pdf does support utf-8 out of the box when used with the tcpdf library.

omar-ali
  • 507
  • 4
  • 14