Reputation: 5970
I am trying to keep track of the current Y position on a PDF
page created using FPDF
so that I can correctly start a new page ensuring tables do not cross a page break. Firstly am I right in using GetY
to monitor this and if so what is the correct syntax. I am trying
$currentYposition = GetY();
but it does not seem to work. Any advice?
Upvotes: 2
Views: 12751
Reputation: 116
I came to this question when programming in python and using the fpdf module. I'll post in case anyone else need this, I could not find this solution in the official documentation but for me following worked:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
current_y = FPDF.get_y(pdf)
Upvotes: 0
Reputation: 1548
No idea why this works - but it does: If you just grab Y after the call, it seems to be the value before the MultiCell. Grabbing it before and after and taking the difference gives you the height.
$oldY = $this->getY();
$this->MultiCell(150, 4, utf8_decode($description), 0, "L");
$newY = $this->getY();
$multiCellHeight = $newY-$oldY;
Upvotes: 1