Arabic in zend pdf

2019-06-08 04:47发布

问题:

I am new in Zend framework. Now I have a problem with Zend pdf. I am trying to make a pdf document which contains arabic as well as english. But I can't print arabic in zend.

Please help me with any tutorials or sample code links.

回答1:

This is still an issue in Zend_pdf I would recommend you to use TCPDF here is the link for that http://www.tcpdf.org/

Go through there examples

http://www.tcpdf.org/examples.php

If you still want to stick with zend pdf may this link be helpful.

http://devzone.zend.com/1064/zend_pdf-tutorial/



回答2:

//Apply font file(.ttf) for zend pdf. for example below will allow arabic language in pdf file.

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/d7133c37aa7eda77090163c25c4bb89a.ttf');

// Apply Arabic word having issue of right to left display word by calling following function.

function converttext($part)
{ 
if (strlen($part) != strlen(utf8_decode($part)))
{ 
  preg_match_all('/./us', $part, $ar);
  $part = join('', array_reverse($ar[0]));
}

  return $part;

}

//Still having problem then, apply alternate solution add the following line in head.

ini_set('default_charset', 'utf-8');