diff --git a/views_pdf_template.php b/views_pdf_template.php index 6bfa601..dc74ebe 100644 --- a/views_pdf_template.php +++ b/views_pdf_template.php @@ -578,11 +578,12 @@ class PdfTemplate extends FPDI { // Set draw point to the indicated position: if (empty($options['position']['x'])) { - $options['position']['x'] = 0; + $options['position']['x'] = $this->lMargin; } + //Initial Y position. if (empty($options['position']['y'])) { - $options['position']['y'] = 0; + $options['position']['y'] = $this->tMargin; } if (isset($options['position']['last_writing_position']) && $options['position']['last_writing_position']) { @@ -604,7 +605,7 @@ class PdfTemplate extends FPDI { $sumWidth = 0; $numberOfColumnsWithoutWidth = 0; - // Set the definitiv width of a column + // Set the definitive width of a column. foreach ($columns as $id => $columnName) { if (isset($options['info'][$id]['position']['width']) && !empty($options['info'][$id]['position']['width'])) { $sumWidth += $options['info'][$id]['position']['width']; @@ -727,9 +728,9 @@ class PdfTemplate extends FPDI { // Get the page dimensions $pageDim = $this->getPageDimensions(); - if (($rowY + $this->bMargin + $options['position']['row_height']) > $pageDim['hk']) { - $rowY = $this->tMargin; + if (($rowY + $this->bMargin + $this->tMargin + $options['position']['row_height']) > $pageDim['hk']) { $this->addPage(); + $rowY = $this->tMargin; } if ($this->lastWritingPage != $this->getPage()) {