Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php TCPDF中的RTL联合问题_Php_Html_Tcpdf - Fatal编程技术网

Php TCPDF中的RTL联合问题

Php TCPDF中的RTL联合问题,php,html,tcpdf,Php,Html,Tcpdf,我正在研究TCPDF。在MultiCell中使用justify时,我有一个3行RTL文本,最后一行从左侧开始(应该从右侧开始) 当我尝试使用WriteHTML时,也是一样 $htmlpersian = '<p align="justify" dir="rtl" > السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام

我正在研究TCPDF。在MultiCell中使用justify时,我有一个3行RTL文本,最后一行从左侧开始(应该从右侧开始)

当我尝试使用WriteHTML时,也是一样

$htmlpersian = '<p align="justify" dir="rtl" >
السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكمالسلام عليكمالسلام عليكم   
</p>';
$pdf->WriteHTML($htmlpersian."\n", true, 0, true, 0);
$htmlpersian='

السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكم السلام عليكمالسلام عليكمالسلام عليكم

'; $pdf->WriteHTML($htmlpersian.\n',true,0,true,0);
“\n”被添加到字符串中,以防止证明最后一行是正确的


这是我提出的一个解决办法,但它需要使用不同的文本手动调整额外的灵敏度变量,基本上是将最后一行写在一个单独的单元格中,并向右对齐

$textexploded   =   explode(" ",$lettertext);                   // create array of words
$lettercount    =   mb_strlen($lettertext,'UTF-8');             // Get total number of characters of the whole text
$linesnum       =   $lettercount / $linechar;                    // divide number of characters over sensitivity number "how many letters per line"
$whole          =   floor($linesnum);                       // before decimal       
$fraction       =   $linesnum - $whole;                      // decimal
$last           =   $fraction * $linechar;                   // estimate number of characters of last line 
$last           =   $last - 3;                                  // refining

if (    $lettercount >= $linechar   ) {                     // Proceed of text characters are more than one line limit
    $total = 0;
    for ($x = count($textexploded); $total < $last; $x--) {   // Start at the end of the words array
        $total += mb_strlen($textexploded[$x-1],'UTF-8');    // Estimate at what array word last line starts
    }

    $slice_position = array_search($x, array_keys($textexploded));  // determine the slice position of the original text 
    $a1 = array_slice($textexploded, 0, $slice_position, true);     // Slice the first lines 
    $a2 = array_slice($textexploded, $slice_position, count($textexploded), true);  //slice the last line
    $a1 = implode(" ",$a1);                                         // recombine words 
    $a2 = implode(" ",$a2);                                         // recombine words 

    $pdf->MultiCell(190, 0, '       '.$a1, 0, 'J', 0, 1, '', '', false, 2, false, true, 0, 'M');
    $pdf->Cell(0, 6, $a2, 0, 0, 'R', 0, '', 0, false, 'T', 'M');
} else {
    $pdf->Cell(0, 6, $lettertext, 0, 0, 'R', 0, '', 0, false, 'T', 'M');
}
$textexploded=explode(“,$letterxt);//创建单词数组
$lettercount=mb_strlen($lettertext,'UTF-8');//获取整个文本的字符总数
$linesnum=$lettercount/$linechar;//将字符数除以敏感度数字“每行有多少个字母”
$total=地板($linesnum);//小数点前
$fraction=$linesnum-$whole;//十进制的
$last=$fraction*$linechar;//估计最后一行的字符数
$last=$last-3;//精炼
如果($lettercount>=$linechar){//文本字符的长度超过一行限制
$total=0;
对于($x=count($textexploded);$total<$last;$x--){//从单词数组的末尾开始
$total+=mbstrlen($textexploded[$x-1],'UTF-8');//估计数组单词最后一行的起始位置
}
$slice_position=array_search($x,array_keys($textexploded));//确定原始文本的切片位置
$a1=数组_切片($textexploded,0,$slice_position,true);//切片第一行
$a2=array_slice($textexploded,$slice_position,count($textexploded),true);//切片最后一行
$a1=内爆(“,$a1);//重新组合单词
$a2=内爆(“,$a2);//重新组合单词
$pdf->MultiCell(190,0,,.$a1,0,'J',0,1,','',false,2,false,true,0,'M');
$pdf->Cell(0,6,$a2,0,0,'R',0',0,false,'T',M');
}否则{
$pdf->Cell(0,6,$letterxt,0,0,'R',0',0,false,'T','M');
}

你到底想问什么?@sɐunıןqɐp将最后一行对齐到右边你是否尝试使用:

?如果你使用css:@sɐun௭qɐp它不起作用

$textexploded   =   explode(" ",$lettertext);                   // create array of words
$lettercount    =   mb_strlen($lettertext,'UTF-8');             // Get total number of characters of the whole text
$linesnum       =   $lettercount / $linechar;                    // divide number of characters over sensitivity number "how many letters per line"
$whole          =   floor($linesnum);                       // before decimal       
$fraction       =   $linesnum - $whole;                      // decimal
$last           =   $fraction * $linechar;                   // estimate number of characters of last line 
$last           =   $last - 3;                                  // refining

if (    $lettercount >= $linechar   ) {                     // Proceed of text characters are more than one line limit
    $total = 0;
    for ($x = count($textexploded); $total < $last; $x--) {   // Start at the end of the words array
        $total += mb_strlen($textexploded[$x-1],'UTF-8');    // Estimate at what array word last line starts
    }

    $slice_position = array_search($x, array_keys($textexploded));  // determine the slice position of the original text 
    $a1 = array_slice($textexploded, 0, $slice_position, true);     // Slice the first lines 
    $a2 = array_slice($textexploded, $slice_position, count($textexploded), true);  //slice the last line
    $a1 = implode(" ",$a1);                                         // recombine words 
    $a2 = implode(" ",$a2);                                         // recombine words 

    $pdf->MultiCell(190, 0, '       '.$a1, 0, 'J', 0, 1, '', '', false, 2, false, true, 0, 'M');
    $pdf->Cell(0, 6, $a2, 0, 0, 'R', 0, '', 0, false, 'T', 'M');
} else {
    $pdf->Cell(0, 6, $lettertext, 0, 0, 'R', 0, '', 0, false, 'T', 'M');
}