日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

用Word写博客园文章

發(fā)布時(shí)間:2024/4/17 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用Word写博客园文章 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

http://www.cnblogs.com/dunitian/services/metablogapi.aspx

?

效果如下:

啦啦啦啦啦啦我是賣報(bào)的小行家

/// <summary>

/// Word轉(zhuǎn)換成PDF

/// </summary>

/// <param name="inputPath">載入路徑</param>

/// <param name="outputPath">保存路徑</param>

/// <param name="startPage">初始頁(yè)碼(默認(rèn)為第一頁(yè)[0]</param>

/// <param name="endPage">結(jié)束頁(yè)碼(默認(rèn)為最后一頁(yè))</param>

public static bool WordToPDF(string inputPath, string outputPath, int startPage = 0, int endPage = 0)

{

bool b = true;

?

#region初始化

//初始化一個(gè)application

Application wordApplication = new Application();

//初始化一個(gè)document

Document wordDocument = null;

#endregion

?

#region參數(shù)設(shè)置~~我去累死寶寶了~~

//word路徑

object wordPath = Path.GetFullPath(inputPath);

?

//輸出路徑

string pdfPath = Path.GetFullPath(outputPath);

?

//導(dǎo)出格式為PDF

WdExportFormat wdExportFormat = WdExportFormat.wdExportFormatPDF;

?

//導(dǎo)出大文件

WdExportOptimizeFor wdExportOptimizeFor = WdExportOptimizeFor.wdExportOptimizeForPrint;

?

//導(dǎo)出整個(gè)文檔

WdExportRange wdExportRange = WdExportRange.wdExportAllDocument;

?

//開始頁(yè)碼

int startIndex = startPage;

?

//結(jié)束頁(yè)碼

int endIndex = endPage;

?

//導(dǎo)出不帶標(biāo)記的文檔(這個(gè)可以改)

WdExportItem wdExportItem = WdExportItem.wdExportDocumentContent;

?

//包含word屬性

bool includeDocProps = true;

?

//導(dǎo)出書簽

WdExportCreateBookmarks paramCreateBookmarks = WdExportCreateBookmarks.wdExportCreateWordBookmarks;

?

//默認(rèn)值

object paramMissing = Type.Missing;

?

#endregion

?

#region轉(zhuǎn)換

try

{

//打開word

wordDocument = wordApplication.Documents.Open(ref wordPath, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing);

//轉(zhuǎn)換成指定格式

if (wordDocument != null)

{

wordDocument.ExportAsFixedFormat(pdfPath, wdExportFormat, false, wdExportOptimizeFor, wdExportRange, startIndex, endIndex, wdExportItem, includeDocProps, true, paramCreateBookmarks, true, true, false, ref paramMissing);

}

}

catch (Exception ex)

{

b = false;

}

finally

{

//關(guān)閉

if (wordDocument != null)

{

wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing);

wordDocument = null;

}

?

//退出

if (wordApplication != null)

{

wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing);

wordApplication = null;

}

}

?

return b;

#endregion

}

轉(zhuǎn)載于:https://www.cnblogs.com/dunitian/p/5041062.html

總結(jié)

以上是生活随笔為你收集整理的用Word写博客园文章的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。