如何减少 MigraDoc 文档的上边距?
我在文档的右上角添加了一个图像,但是文档顶部和图像之间的空间太大。
这是我设置图像的方法:
Section section = document.AddSection();
Image image = section.AddImage(@"C:\img\mentSmallLogo.png");
image.Height = "1.5cm";
image.Width = "4cm";
image.LockAspectRatio = true;
image.RelativeVertical = RelativeVertical.Line;
image.RelativeHorizontal = RelativeHorizontal.Margin;
image.Top = ShapePosition.Top;
image.Left = ShapePosition.Right;
image.WrapFormat.Style = WrapStyle.Through;
Run Code Online (Sandbox Code Playgroud)
以及文档样式:
Style style = document.Styles["Normal"];
style.Font.Name = "Verdana";
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called Table based on style Normal
style = document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Verdana";
style.Font.Name = "Times New Roman";
style.Font.Size = 8;
// Create a new style called Reference based on style Normal
style = document.Styles.AddStyle("Reference", "Normal");
style.ParagraphFormat.SpaceBefore = "5mm";
style.ParagraphFormat.SpaceAfter = "5mm";
style.ParagraphFormat.TabStops.AddTabStop("16cm", TabAlignment.Right);
style.ParagraphFormat.Font.Size = 8;
Run Code Online (Sandbox Code Playgroud)
如何减少图像与页面顶部之间的空间?
像这样的东西
document.DefaultPageSetup.LeftMargin = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(.8);
document.DefaultPageSetup.TopMargin = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(.5);
document.DefaultPageSetup.PageWidth = MigraDoc.DocumentObjectModel.Unit.FromCentimeter(11);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5820 次 |
最近记录: |