I need to write a tabular text in pdf using html2pdf like that
<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>
I get an example from https://github.com/iafan/html2pdf/blob/master/_tcpdf_5.9.206/examples/example_018.php But that seems work for page wise page.
I did following code so far.
$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');
After more searching I get fix through the following change.
$span->setAttribute("style", "direction: rtl;display: inline-block;font-family:dejavusanscondensed;");
Font Family in css done the trick and text is now showing in arabic in pdf. However it is not right aligned. But I suspect that may require some html fixing.
From : Indian currency symbol not show when convert html2pdf in php .