下推段落以不与 MigraDoc 1.5b3 中的页眉重叠

Push paragraphs down to not overlap with page header in MigraDoc 1.5b3

下面的代码旨在向页眉添加图像和日期戳,然后用一些文本填充页面(例如一个页眉和几个段落)。

问题是文本与页眉重叠,它的起始高度与页眉中日期戳段落的高度相同。我做错了什么?

Section section = document.AddSection();
section.PageSetup.StartingNumber = 1;

Image image = section.Headers.Primary.AddImage(GetImageFromDB("LogoPageHeader")); // creates base64 encoded image string
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Left;
image.WrapFormat.Style = WrapStyle.TopBottom; // to push date stamp to below the bottom of the image

HeaderFooter header = section.Headers.Primary;
Paragraph paragraph = header.AddParagraph(DateTime.Now.ToString("MM/dd/yyyy"));
paragraph.Format.Alignment = ParagraphAlignment.Right;

Paragraph paragraph = document.LastSection.AddParagraph("Question Summary:", "Heading3");

paragraph = document.LastSection.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Left;
paragraph.AddText("Question: " + q.Text.Trim());

paragraph = document.LastSection.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Left;
paragraph.AddText("Answer: " + (String.IsNullOrEmpty(q.ReplyText.Trim()) ? q.ReplyCode.ToString() : q.ReplyText.Trim()));
paragraph.Format.SpaceAfter = "8pt";

图像大约为 20x20mm。

您必须将 PageSetup 的 TopMargin 设置为 space 保留 header。

另请参阅:
http://forum.pdfsharp.net/viewtopic.php?p=3077