Unplanned
Last Updated: 21 Apr 2021 10:58 by ADMIN
n/a
Created on: 21 Apr 2021 10:55
Category: WordsProcessing
Type: Bug Report
1
WordsProcessing: PdfFormatProvider: Wrong measurement of header/footer height when exporting a document containing a FloatingImage in the header/footer

When exporting a document containing a FloatingImage in the header/footer the measurement of the header/footer height doesn't take into account the height of this image.

This leads to overlapping the page content with the image.

Workaround: Increase the Header (or Footer) top page margin by the height of the image:

foreach (Section section in this.document.Sections)
{
	double floatingImageHeight = 0;
	foreach (BlockBase block in section.Headers.Default.Blocks)
	{
		if (block is Paragraph paragraph)
		{
			FloatingImage floatingImage = (FloatingImage)paragraph.Inlines.FirstOrDefault(i => i is FloatingImage);
			floatingImageHeight = floatingImage.Image.Height;
		}
	}

	double left = section.PageMargins.Left;
	double top = section.PageMargins.Top + floatingImageHeight;
	double right = section.PageMargins.Right;
	double bottom = section.PageMargins.Bottom;
	section.PageMargins = new Telerik.Windows.Documents.Primitives.Padding(left, top, right, bottom);
}

0 comments