Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,16 @@ Rectangle CalcContentRect(int page)

XUnitPt height = pageSetup.PageHeight.Point;

height -= pageSetup.TopMargin.Point;
height -= pageSetup.BottomMargin.Point;
double topMargin = pageSetup.TopMargin.Point;
if (_formattedHeaders.TryGetValue(new HeaderFooterPosition(_sectionNumber, CurrentPagePosition), out FormattedHeaderFooter? header))
topMargin = Math.Max(topMargin, header.ContentRect.Y.Point + header.ContentRect.Height.Point);
height -= topMargin;
double bottomMargin = pageSetup.BottomMargin.Point;
if (_formattedFooters.TryGetValue(new HeaderFooterPosition(_sectionNumber, CurrentPagePosition), out FormattedHeaderFooter? footer))
bottomMargin = Math.Max(bottomMargin, pageSetup.PageHeight.Point - footer.ContentRect.Y.Point);
height -= bottomMargin;
XUnitPt x;
XUnitPt y = pageSetup.TopMargin.Point;
XUnitPt y = topMargin;
if (pageSetup.MirrorMargins)
x = page % 2 == 0 ? pageSetup.RightMargin.Point : pageSetup.LeftMargin.Point;
else
Expand Down Expand Up @@ -380,8 +386,9 @@ Area IAreaProvider.GetNextArea()
++_sectionPages;
InitFieldInfos();
FormatHeadersFooters();
Rectangle rect = CalcContentRect(_currentPage);
_isNewSection = false;
return CalcContentRect(_currentPage);
return rect;
}

int _currentPage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ internal void Format(XGraphics gfx)
_formatter = new TopDownFormatter(this, _documentRenderer, _headerFooter.Elements);
_formatter.FormatOnAreas(gfx, false);
_contentHeight = RenderInfo.GetTotalHeight(GetRenderInfos());
if (_headerFooter.IsHeader)
ContentRect.Height = _contentHeight;
if (_headerFooter.IsFooter)
{
ContentRect.Y = ContentRect.Y + ContentRect.Height - _contentHeight;
ContentRect.Height = _contentHeight;
}
}

Area? IAreaProvider.GetNextArea()
Expand Down