将段落向下推到不与MigraDoc 1.5b3中的页眉重叠

时间:2016-07-20 20:53:33

标签: c# migradoc

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

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

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。

1 个答案:

答案 0 :(得分:1)

您必须设置PageSetup的TopMargin以保留标题的空间。

另见:
http://forum.pdfsharp.net/viewtopic.php?p=3077