Coder Social home page Coder Social logo

Comments (2)

mcarpenterjr avatar mcarpenterjr commented on July 17, 2024

I have this block that creates a set of TCPDF MultiCell()s in a multicolumn pdf.

$TColW0 = 29;
$DColW0 = 37;
$mbh = $pdf->getStringHeight($DColW0, $reqHeader['partPackingInfo'], false, true, '', 1);
$pdf->MultiCell($TColW0, $mbh, 'Packaging Details:', 1, 'R', '', 0, '', '', true, 0, false, false, '', 'M', false);
$pdf->MultiCell($DColW0, $mbh, $reqHeader['partPackingInfo'], 1, 'L', '', 1, '', '', true, 0, false, false, '', 'M', false);
  • The first line uses TCPDF's native function to get the height of the multi line string and sets the $mbh variable to later set both cells to the same height.
  • The $DColW0 and $TColW0 variables are predetermined and set column widths.

My problem is the result looks like this,

TCPDF Multiline Issue

I tried using the title column's width in the x value of the data cell, but that just shifts the content out of the column.

The content looks to be in the right place the border for the data cell is just drawn in the wrong spot. Is there a setting or something I'm missing when it comes to MultiCell() borders? Any help/suggestions much appreciated.


Updating the block to make use of SetX

$TColW0 = 29;
$DColW0 = 37;
$mbh = $pdf->getStringHeight($DColW0, $reqHeader['partPackingInfo'], false, true, '', 1);
$pdf->MultiCell($TColW0, $mbh, 'Packaging Details:', 1, 'R', '', 0, '', '', true, 0, false, false, '', 'M', false);
$pdf->SetX($TColW0);
$pdf->MultiCell($DColW0, $mbh, $reqHeader['partPackingInfo'], 1, 'L', '', 1, '', '', true, 0, false, false, '', 'M', false);

Shifts the content independent of where the border is drawn.
SETX Example


Using the x specification inside of MultiCell()

$TColW0 = 29;
$DColW0 = 37;
$mbh = $pdf->getStringHeight($DColW0, $reqHeader['partPackingInfo'], false, true, '', 1);
$pdf->MultiCell($TColW0, $mbh, 'Packaging Details:', 1, 'R', '', 0, '', '', true, 0, false, false, '', 'M', false);
$pdf->MultiCell($DColW0, $mbh, $reqHeader['partPackingInfo'], 1, 'L', '', 1, $TColW0, '', true, 0, false, false, '', 'M', false);

enter image description here

Again content shifts, border is drawn over previous cell.

MultiCell() Documentation.


Result with cell fill turned on.

$TColW0 = 29;
$DColW0 = 37;
$mbh = $pdf->getStringHeight($DColW0, $reqHeader['partPackingInfo'], false, true, '', 1);
$pdf->MultiCell($TColW0, $mbh, 'Packaging Details:', 1, 'R', 1, 0, '', '', true, 0, false, false, '', 'M', false);
$pdf->MultiCell($DColW0, $mbh, $reqHeader['partPackingInfo'], 1, 'L', 1, 1, '', '', true, 0, false, false, '', 'M', false);

FillExample

Turning fill on paints over all previously drawn borders for that row with the exception of the border for the last cell. The content of both cells is still in the expected position, the border is drawn to the expected size, but is drawn in the wrong position.

from tc-lib-pdf.

nicolaasuni avatar nicolaasuni commented on July 17, 2024

Please report this to:
https://github.com/tecnickcom/TCPDF/issues

from tc-lib-pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.