FPDF中的MultiCell出现断线问题 [英] line break problem with MultiCell in FPDF

查看:69
本文介绍了FPDF中的MultiCell出现断线问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用fpdf的java端口.我遇到了以下错误.

I am using java port of fpdf. I am encountering fowwlowing errors.

1).每次将文本打印在新行上时,我两次调用多单元格.

1).When i call multicell 2 times every time the text is printed on a new line.

MultiCell(0, 1, "abcd", currentBorders, Alignment.LEFT, false); //prints on one line
 MultiCell(0, 1, "efg", currentBorders, Alignment.LEFT, false); //prints on next line

我希望在调用多单元格后没有换行符.我该怎么办?

I want that there is no line break after the call to multicell. How can i do it?

2)如果我执行以下操作,则我的字符串的一部分会打印在一行上,而另一些会打印在下一行.

2)If i do the following thing then some part of my string gets printed on one line and some on next.

 MultiCell(getStringWidth(myString), 1, myStringcurrentBorders, Alignment.LEFT, false);

3)如果我执行以下操作,则在打印myString的行之后有很多空白行.如果我使用一个1 ans第二个参数,它将正常工作

3)If i do the following thing then there are many blank lines after the line on which myString is printed. It works correctly if i use one 1 ans second parameter

 MultiCell(0, myFontSize, "123456", currentBorders, Alignment.LEFT, false);

出什么问题了?

推荐答案

在编写MultiCell之前,我将获得当前的Y位置,然后在Y位置>代.像这样:

I would get the current Y position before writing the MultiCell and then move the "cursor" back to that Y position after the MultiCell generation. Like this:

$current_y = $pdf->GetY();
$current_x = $pdf->GetX();

$cell_width = 50;
MultiCell($cell_width, 1, "abcd", currentBorders, Alignment.LEFT, false);

$pdf->SetXY($current_x + $cell_width, $current_y);

$current_x = $pdf->GetX();
MultiCell($cell_width, 1, "abcd", currentBorders, Alignment.LEFT, false);

类似的东西.

这篇关于FPDF中的MultiCell出现断线问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆