【发布时间】:2018-06-18 14:40:51
【问题描述】:
我对 PDF 创建(包括 MigraDoc)完全陌生。我已经走到了这一步,这真的很接近我现在想要的。我的问题是,我传递给“bodyParagraph”的文本字符串(myMessage)长达 100 行,这会导致创建三个页面,这很好。但是第一页的上边距略大于第二页和第三页。我不知道为什么...
基本上,我试图创建相同的每个页面。无论“bodyParagraph”内容中的行数如何,相同的页眉、页脚和正文占用相同的空间。如果我采取了完全错误的方法,我会接受建议。
另外,如果有一个好的教程可以让我指出那将是很棒的。除了样品,我真的找不到任何东西。我从示例中学到了一切,但部分、段落等对我来说都是新的,我想更好地了解我所做的事情。
public static Document CreateWorkOrderPDF2(Document document, string filename, string WorkOrderHeader, string myMessage)
{
Section section = document.AddSection();
section.PageSetup.PageFormat = PageFormat.Letter;
section.PageSetup.StartingNumber = 1;
section.PageSetup.LeftMargin = 40;
//Sets the height of the top margin
section.PageSetup.TopMargin = 100;
section.PageSetup.RightMargin = 40;
section.PageSetup.BottomMargin = 40;
//MARGIN
HeaderFooter header = section.Headers.Primary;
header.Format.Font.Size = 16;
header.Format.Font.Color = Colors.DarkBlue;
MigraDoc.DocumentObjectModel.Shapes.Image headerImage = header.AddImage("../../Fonts/castorgate.regular.png");
headerImage.Width = "2cm";
Paragraph headerParagraph = section.AddParagraph();
headerParagraph = header.AddParagraph(WorkOrderHeader);
//BODY PARAGRAPH
Paragraph bodyParagraph = section.AddParagraph();
bodyParagraph = section.AddParagraph(myMessage);
bodyParagraph.Format.Font.Size = 10;
bodyParagraph.Format.Font.Color = Colors.DarkRed;
//paragraph.Format.Distancne = "3cm";
Paragraph renderDate = section.AddParagraph();
renderDate = section.AddParagraph("Work Order Generated: ");
renderDate.AddDateField();
return document;
}
【问题讨论】: