如何用C#获取获取WORD文件页数,谢谢
解决方案 »
- C#正则表达式提取一段代码的内容得不到结果,请进来解答
- 有没有这样的word分割工具
- 怎么比较字符串相似度呢?酬谢 50元话费
- 线程问题,急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!
- 在作注册页面时,上面的注册信息完成以后,有个按钮要提交嘛,点提交按钮后,按钮中的提交二字消失,按钮上出现10 ,9,8,7,6,5,4,3
- 如何阻止WINFORM中捕获的键盘输入再传给控件
- 菜单问题解决不了!
- 谁能介绍一下remote objects的Garbage collection机制?
- DataGridViewCheckBoxColumn添加事件,在线等,谢谢!!!
- 哪里能够下载C#的代码我想学习C#
- ◆◇◆ 请问一下大家都用什么变量命名规范表示数组? ◆◇◆
- 如何当焦点不在窗体上,标题栏依旧保持蓝色?
Coming with MS Office 2003, the MODI library offers you an easy but effective way to integrate Optical Character Recognition (OCR) functionality into your own applications.
ref:
http://www.codeproject.com/csharp/modi.asp
(自己没有测试过..楼主可以参考一下..)using System;
using System.Threading;
using System.Reflection;
using Microsoft.Office.Interop.Word; namespace DocPageCounter
{
/// <summary>
/// Summary description for Class.
/// </summary>
class PageCounter
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
ApplicationClass WordApp = new ApplicationClass(); // give any file name of your choice.
object fileName = "E:\\abc\\test.doc";
object readOnly = false;
object isVisible = true; // the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value; // Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Document aDoc = WordApp.Documents.Open(
ref fileName,
ref missing,ref readOnly, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref isVisible,ref missing,
ref missing, ref missing); WdStatistic stat = WdStatistic.wdStatisticPages ;
int num = aDoc.ComputeStatistics(stat,ref missing);
System.Console.WriteLine ("The number of pages in doc is {0}",
num);
System.Console.ReadLine(); }
}
}