简体   繁体   English

为什么在日语操作系统中字页数总是返回 1

[英]Why Word page count always returns 1 in Japanese Operating System

But it is works fine in English OS.但它在英文操作系统中运行良好。 Also it is returns the correct value for Excel and Power point document in English OS as well as Japanese OS.它还返回 Excel 和英语操作系统以及日语操作系统中的 Power point 文档的正确值。 Only the problem am facing page count for Word document in Japanese OS日语操作系统中 Word 文档的页数仅面临问题

I have tried three type of code but still i'm getting total Page count as 1 only.我已经尝试了三种类型的代码,但我仍然将总页数设为 1。

References version: Microsoft.Office.Interop.Word Version 15.0.0.0 Visual studio: 2013 Microsoft office: 2016参考版本:Microsoft.Office.Interop.Word 版本 15.0.0.0 Visual Studio:2013 Microsoft Office:2016

Method:1:-方法:1:-

Microsoft.Office.Interop.Word.ApplicationClass appWordPageCount = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
Microsoft.Office.Interop.Word.WdStatistic staticPages = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
object missing = System.Reflection.Missing.Value;
DocPageCount = appWordPageCount.Documents.Open(fileNames);
wordPageCount = DocPageCount.ComputeStatistics(staticPages, ref missing);  // fetches page count of word files

Method:2方法:2

Microsoft.Office.Interop.Word.Application appWordPageCount = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
DocPageCount = appWordPageCount.Documents.Open(wordFile);
wordPageCount = DocPageCount.ActiveWindow.ActivePane.Pages.Count;

Method:3方法:3

Microsoft.Office.Interop.Word.ApplicationClass appWordPageCount = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document DocPageCount = null;
Microsoft.Office.Interop.Word.WdStatistic staticPages = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
object encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8;
DocPageCount = appWordPageCount.Documents.Open(ref fileNames, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                                    ref encoding, ref missing, ref missing, ref missing, ref missing, ref missing);
wordPageCount = DocPageCount.ComputeStatistics(staticPages, ref missing); 

Thanks in advance for your guidances.提前感谢您的指导。

When Word application view mode is "Web layout" then, it always returning page count as 1. there are three three view mode in it, Read,Print Layout, Web Layout.当 Word 应用程序视图模式为“Web 布局”时,它总是返回页数为 1。其中有三种视图模式,读取,打印布局,Web 布局。 So while getting page count of word document, the mode should be in Print Layout.所以在获取word文档的页数时,模式应该是打印布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM