@@ -708,24 +708,26 @@ wxPdfTable::GetLastRowsOnPage() const
708
708
const double yMax = pageHeight - breakMargin;
709
709
const double firstBodyRowHeight = iterBodyFirst->second ;
710
710
const bool writeHeader = m_headRowLast > m_headRowFirst;
711
- double headerHeight = 0 ;
712
- // in case we have a line break and the table has a header, we need to consider the space of the header at the new page
713
- if (writeHeader)
711
+
712
+ // m_document->GetHeaderHeight() is header height minus top margin, so we have to consider top margin as well
713
+ const double topTotalMargin = m_document->GetTopMargin () + m_document->GetHeaderHeight () + m_headHeight;
714
+
715
+ if (topTotalMargin + firstBodyRowHeight > yMax)
714
716
{
715
- for (unsigned int headRow = m_headRowFirst; headRow < m_headRowLast; headRow++)
716
- {
717
- headerHeight += m_rowHeights.find (headRow)->second ;
718
- }
717
+ wxLogError (wxString (wxS (" wxPdfDocument::wxPdfTable: " )) +
718
+ wxString (_ (" Not possible to draw at least one table line on a page." )));
719
+ return lastRows;
719
720
}
721
+
720
722
double y = m_document->GetY ();
721
723
722
724
// this means basically that we have a line break before drawing the table
723
725
y += m_headHeight + firstBodyRowHeight;
724
726
if (y > yMax)
725
727
{
726
728
lastRows.Add (m_headRowLast);
727
- // Maybe we have a header at the top of the next page
728
- y = m_document-> GetHeaderHeight () ;
729
+
730
+ y = topTotalMargin ;
729
731
}
730
732
731
733
for (unsigned int row = m_bodyRowFirst + 1 ; row < m_bodyRowLast; ++row)
@@ -735,13 +737,8 @@ wxPdfTable::GetLastRowsOnPage() const
735
737
{
736
738
// since m_bodyRowLast and m_headRowLast are alway one behind last, last row on page is always one behind too.
737
739
lastRows.Add (row);
738
- // Maybe we have a header at the top of the next page
739
- y = m_document->GetHeaderHeight ();
740
- }
741
- if (writeHeader)
742
- {
743
- // consider the table header
744
- y += headerHeight;
740
+
741
+ y = topTotalMargin;
745
742
}
746
743
y += rowHeight;
747
744
}
0 commit comments