Skip to content

Commit

Permalink
MDL-70093 dataformat_pdf: Fix row height calculation with high cells
Browse files Browse the repository at this point in the history
  • Loading branch information
golenkovm committed Nov 2, 2020
1 parent 3b0d958 commit 051cad2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dataformat/pdf/classes/writer.php
Expand Up @@ -135,14 +135,19 @@ public function write_record($record, $rownum) {
// height. Solution similar to that at https://stackoverflow.com/a/1943096.
$pdf2 = clone $this->pdf;
$pdf2->startTransaction();
$numpages = $pdf2->getNumPages();
$pdf2->AddPage('L');
$pdf2->writeHTMLCell($this->colwidth, 0, '', '', $cell, 1, 1, false, true, 'L');
$rowheight = max($rowheight, $pdf2->getY() - $pdf2->getMargins()['top']);
$pagesadded = $pdf2->getNumPages() - $numpages;
$pageheight = $pdf2->getPageHeight() - $pdf2->getMargins()['top'] - $pdf2->getMargins()['bottom'];
$cellheight = ($pagesadded - 1) * $pageheight + $pdf2->getLastH();
$rowheight = max($rowheight, $cellheight);
$pdf2->rollbackTransaction();
}

$margins = $this->pdf->getMargins();
if ($this->pdf->GetY() + $rowheight + $margins['bottom'] > $this->pdf->getPageHeight()) {
if ($this->pdf->getNumPages() > 1 &&
($this->pdf->GetY() + $rowheight + $margins['bottom'] > $this->pdf->getPageHeight())) {
$this->pdf->AddPage('L');
$this->print_heading();
}
Expand Down

0 comments on commit 051cad2

Please sign in to comment.