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');