在下面的C#代码中,我尝试确定页面的宽度,以便可以将3列的表拉伸到页面的整个宽度(减去边距)。最初,我认为我应该将每个表格列的宽度设置为页面宽度的1/3。然而,我发现,section.PageSetup.PageWidth
,section.PageSetup.LeftMargin
和section.PageSetup.RightMargin
在下面的代码返回0。PDFsharp/MigraDoc - 为什么是section.PageSetup.PageWidth = 0?
Section section = document.AddSection();
section.PageSetup.PageFormat = PageFormat.A4;
section.PageSetup.Orientation = Orientation.Portrait;
int sectionWidth = (int)Math.Ceiling(section.PageSetup.PageWidth -
section.PageSetup.LeftMargin -
section.PageSetup.RightMargin);
int columnWidth = (int)Math.Ceiling(sectionWidth/3);
值我认为设置页面格式PageFormat.A4
和定向Orientation.Portrait
将相应地设置的section.PageSetup.PageWidth
的值,将还将边距值设置为某些默认值。有人可以告诉我我做错了什么吗?我只是刚刚开始使用MigraDoc。非常感谢。
这可能会帮助你:http://stackoverflow.com/questions/15966672/pdfsharp-page-size-and-set-margin-issue-c-sharp(本标记答案表示包含的代码是migradoc)。 –
谢谢史蒂夫。是的,它有帮助。我已经了解到我可以使用这个:'PdfSharp.Drawing.XSize size = PdfSharp.PageSizeConverter.ToSize(PdfSharp.PageSize.A4)'来获得整个页面的宽度,包括页边距。现在我必须找到一种方法来减去默认边距以获得页面的“可用宽度”。 – user2430797