dongyidao1461 2013-10-20 13:42
浏览 58

在所有页面中修复了tcpdf中的rtl方向

i have a problem with TCPDF library ,i'm generating pdf file usind TCPDF library in arabic language,the file direction is rtl so i used $pdf->setRTL(true); , and every thing is fine in the first page ,put in the second page or third the direction reseted to ltr!!!

this is apice of my code:

$pdf->AddPage();

$l = Array();
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = '';
$l['w_page'] = '';
$pdf->setLanguageArray($l);
$pdf->SetFont('almohanad', '', 16);
$pdf->setRTL(true); // cehck here if ar or en



$html = '
  <style>
    html{
      direction:rtl;
    }
  </style>

  <div style="direction:rtl">  
    <br/><br/>
    <img src="' . $image . '" />
    <br/>
    <span style="color:green">'.$date.'</span>
    <h5 style="color:gray">'.$title.'</h5>
    <div style="color:blue;direction:rtl">'.$content.'</div>
  </div>
';

$pdf->writeHTML($html, true, false, false, true, "");
$pdf->setRTL(true);
$pdf->lastPage();
#excute the file
$pdf->Output($fileName, 'I');

So my question is: how can I make all pages in tcpdf have the same direction as rtl ???

  • 写回答

1条回答 默认 最新

  • dop20345 2013-11-17 13:50
    关注

    This problem was fixed by Iranians in the TCPDF Class.
    Download TCPDF from http://www.tcpdf.org/
    and run example_018.php in examples

    //Before Write
    // set some language dependent data:
    $lg = Array();
    $lg['a_meta_charset'] = 'UTF-8';
    $lg['a_meta_dir'] = 'rtl';
    $lg['a_meta_language'] = 'fa';
    $lg['w_page'] = 'page';
    
    // set some language-dependent strings (optional)
    $pdf->setLanguageArray($lg);
    
    //After Write
    $pdf->setRTL(true);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答