我们有一个应用程序可以读取Word文档并将它们导入到我们的文件格式中。
最近发现了一个错误,页面计数仅在页面布局视图中可用,而Word 2010默认使用Web布局。
使用.NET c#,我们如何更改视图以返回页数?
发布于 2010-12-01 20:03:41
我相信你正在寻找的属性是Document.ActiveWindow.View.Type = wdPrintView;,你可以在MSDN上阅读更多。
发布于 2020-04-02 02:04:10
//Here is my code snipped based on 'DocumentFormat.OpenXml' nuget package.
//Open doc file
using (var wordDocument = WordprocessingDocument.Open(strInputFile,true))
{
SectionProperties sectionProps = new SectionProperties();
//Set page margins
PageMargin margin = new PageMargin() { Top = 1008,
Right = (UInt32Value)1008U,
Bottom = 1008,
Left = (UInt32Value)1008U,
Header = (UInt32Value)720U,
Footer = (UInt32Value)720U, `enter code here`
Gutter = (UInt32Value)0U };
sectionProps.Append(margin);
//Apply margin
wordDocument.MainDocumentPart.Document.Body.Append(sectionProps);
//Save changes
wordDocument.Save();
}https://stackoverflow.com/questions/4323888
复制相似问题