2015-12-23 59 views
0

在同一直線上阿拉伯文和英文文本,我需要使用HTML2PDF像如何顯示在HTML2PDF

<div><span> - English Translation 1 : </span><span> :  Arabic Translation 1</span></div> 
<div><span> - English Translation 2: </span><span> :  Arabic Translation 2</span></div> 
<div><span> - English Translation 3: </span><span> :  Arabic Translation 3</span></div> 

我從https://github.com/iafan/html2pdf/blob/master/_tcpdf_5.9.206/examples/example_018.php的例子寫在PDF表格文本,但似乎對於頁面明智頁的工作。

到目前爲止,我做了以下代碼。

$finder = new Zend_Dom_Query($htmlContent); 
$classname = "intl-text"; 
$nodes = $finder->query("*[class~=\"$classname\"]"); 

foreach($nodes as $node) { 
    foreach($features as $feature) { 
     $engText = $feature->getEnglishText(); 
     $arbText = $feature->getArabicText(); 

     $div = $dom->createElement("div"); 

     $span = $dom->createElement("span"); 
     $span->nodeValue = "- ".$engText; 
     $div->appendChild($span); 
     $span = $dom->createElement("span"); 
     $span->setAttribute("style", "direction: rtl;"); 
     //$span->setAttribute("dir", "rtl"); 
     $span->nodeValue = ": ".$arbText; 
     $div->appendChild($span); 

     //$div->nodeValue = "- ".$engText.": ".$arbText; 

     $node->appendChild($div); 
    } 
} 

$content = $nodes->getDocument()->saveHTML(); 

$html2pdf->writeHTML($content, false); 
$html2pdf->Output(__DIR__.'Output.pdf', 'F'); 

回答

1

更多搜索後,我通過以下更改獲得修復。

$span->setAttribute("style", "direction: rtl;display: inline-block;font-family:dejavusanscondensed;"); 

css中的字體家族做的伎倆和文本現在在pdf中顯示阿拉伯語。但它並不是一致的。但我懷疑這可能需要一些html修復。

來自:Indian currency symbol not show when convert html2pdf in php