.NET實現(xiàn)在網(wǎng)頁中預覽Office文件的3個方法(3)_.Net教程
推薦:asp.net中控制反轉(zhuǎn)怎么理解?對IOC的解釋為:Inversion of control is a common characteristic of frameworks, so saying that these lightweight containers are special because they use inversion of control is like saying my car is special because it has wheels. 我想對這一概念執(zhí)行
#region 2.01 讀取pdf文件的總頁數(shù) +GetPageCount(string pdf_filename)
/// <summary>
/// 讀取pdf文件的總頁數(shù)
/// </summary>
/// <param name="pdf_filename">pdf文件</param>
/// <returns></returns>
public static int GetPageCountByPDF(string pdf_filename)
{
int pageCount = 0;
if (System.IO.File.Exists(pdf_filename))
{
try
{
byte[] buffer = System.IO.File.ReadAllBytes(pdf_filename);
if (buffer != null && buffer.Length > 0)
{
pageCount = -1;
string pdfText = Encoding.Default.GetString(buffer);
Regex regex = new Regex(@"/Type\s*/Page[^s]");
MatchCollection conllection = regex.Matches(pdfText);
pageCount = conllection.Count;
}
}
catch (Exception ex)
{
Souxuexiao.API.Logger.error(string.Format("讀取pdf文件的總頁數(shù)執(zhí)行GetPageCountByPowerPoint函數(shù)發(fā)生異常原因是:{0}", ex.Message));
}
}
return pageCount;
}
#endregion
分享:delphi選擇文件夾例子所需單元 示例代碼
- asp.net中控制反轉(zhuǎn)怎么理解?
- delphi選擇文件夾例子
- asp.net中C++單例實現(xiàn)問題分析
- 簡單理解Web Service三種實現(xiàn)方式
- Asp.net中Ajax與JQuery的ready函數(shù)沖突怎么辦
- asp.net中Repeater控件用法筆記
- asp.net中導出excel數(shù)據(jù)的方法匯總
- Asp.Net 上傳圖片并生成高清晰縮略圖
- 服務器安全狗導致ASP.NET網(wǎng)站運行出錯的一個案例
- Asp.Net其他頁面如何調(diào)用Web用戶控件寫的分頁
- ASP.NET中上傳并讀取Excel文件數(shù)據(jù)示例
- asp.net SqlParameter如何根據(jù)條件有選擇的添加參數(shù)
- 相關鏈接:
- 教程說明:
.Net教程-.NET實現(xiàn)在網(wǎng)頁中預覽Office文件的3個方法(3)
。