2

I have an issue with aligning a multicell with fPDF. The 3rd column should be next to the 2nd column.

    foreach ($order_items as $item_id => $item) {

        $item_data = $item->get_data();

        $pdf->Cell(35, 5, get_post_meta($item_data['product_id'], 'bdsc_ean_code', true), 1, 0);


        $line_height = 2;
        $width = 60;
        $text = ("fjkbdshjbfbdsjhfbjesfbqwfbjqwefbhwfbhjwebjhfjhqwfbhqwefjbwfhbqwhjfbqwjfjfwqwfbjhefhbq");
        $height = (ceil(($pdf->GetStringWidth($text) / $width)) * $line_height);

        $pdf->Multicell($width,$height,$text,1,0);

        $pdf->Cell(40, 5, '', 1, 0);
        $pdf->Cell(20, 5, $item_data['quantity'], 1, 0);

        $pdf->Cell(34, 5, number_format(round($item_data['total'] + $item_data['subtotal_tax'], 2), 2), 1, 1, 'R');//end of line
    }

Screenshot of the result

Dave
  • 5,108
  • 16
  • 30
  • 40
Dylan
  • 21
  • 3
  • Please [edit] your question and include the code you use to create the instance of fPDF. Based on what you posted above the cells will take at least 189 units of width and there's a good chance that your instance of fPDF is not wide enough to accommodate that size (when you include margins etc). – Dave Jan 23 '20 at 11:21

1 Answers1

0

Maybe this example can you one the right track?

$pdf->Cell(40,5,' ','LTR',0,'L',0);   // empty cell with left,top, and right borders
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(40,5,'Words Here','LR',1,'C',0);  // cell with left and right borders
$pdf->Cell(50,5,'[ x ] abc',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox1',1,0,'L',0);
$pdf->Cell(40,5,'','LBR',1,'L',0);   // empty cell with left,bottom, and right borders
$pdf->Cell(50,5,'[ x ] def',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox2',1,0,'L',0);
  • Hey Mads Sander, It haves to stay an Multicell and not a nornal Cell, But thanks fore trying you're help. – Dylan Jan 22 '20 at 14:27
  • Aaah i see, let me see :) –  Jan 22 '20 at 14:27
  • align two multicells next to eachother: https://stackoverflow.com/questions/11982375/placing-two-multicells-next-to-each-other-using-fpdf-in-php –  Jan 22 '20 at 14:29
  • Already tried ever stackoverflow questions. But no one fixes my problem – Dylan Jan 22 '20 at 14:30