Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

line break problem with MultiCell in FPDF

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

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

What is the problem?

like image 810
user156073 Avatar asked Sep 14 '09 04:09

user156073


1 Answers

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

Something like that.

like image 133
Joshua Pinter Avatar answered Sep 25 '22 17:09

Joshua Pinter