110,538
社区成员
发帖
与我相关
我的任务
分享
Document doc = new Document(@"1.doc");
doc.Save(@"1.pdf", Aspose.Words.SaveFormat.Pdf);
private string WordToHtm(string wordFile)
{
ApplicationClass word = new ApplicationClass();
Document doc = word.Documents.Open(wordFile, true, true);
string saveFile = wordFile.Substring(0, wordFile.LastIndexOf('.')) + ".htm";
doc.SaveAs2(saveFile, WdSaveFormat.wdFormatFilteredHTML);
doc.Close();
word.Quit();
return saveFile;
}
注意到最后一个参数是枚举
doc.SaveAs2(saveFile, WdSaveFormat.wdFormatFilteredHTML);
点进去,果然有PDF
namespace Microsoft.Office.Interop.Word
{
//
// 摘要:
// Specifies the format to use when saving a document.
[Guid("6AEEBC10-0420-3FB1-8A04-5F2053C4DAE9")]
public enum WdSaveFormat
{
//
// 摘要:
// Microsoft Word format.
wdFormatDocument = 0,
//
// 摘要:
// Microsoft Word 97 document format.
wdFormatDocument97 = 0,
//
// 摘要:
// Microsoft Word template format.
wdFormatTemplate = 1,
//
// 摘要:
// Word 97 template format.
wdFormatTemplate97 = 1,
//
// 摘要:
// Microsoft Windows text format.
wdFormatText = 2,
//
// 摘要:
// Microsoft Windows text format with line breaks preserved.
wdFormatTextLineBreaks = 3,
//
// 摘要:
// Microsoft DOS text format.
wdFormatDOSText = 4,
//
// 摘要:
// Microsoft DOS text with line breaks preserved.
wdFormatDOSTextLineBreaks = 5,
//
// 摘要:
// Rich text format (RTF).
wdFormatRTF = 6,
//
// 摘要:
// Unicode text format.
wdFormatUnicodeText = 7,
//
// 摘要:
// Encoded text format.
wdFormatEncodedText = 7,
//
// 摘要:
// Standard HTML format.
wdFormatHTML = 8,
//
// 摘要:
// Web archive format.
wdFormatWebArchive = 9,
//
// 摘要:
// Filtered HTML format.
wdFormatFilteredHTML = 10,
//
// 摘要:
// Extensible Markup Language (XML) format.
wdFormatXML = 11,
//
// 摘要:
// XML document format.
wdFormatXMLDocument = 12,
//
// 摘要:
// XML template format with macros enabled.
wdFormatXMLDocumentMacroEnabled = 13,
//
// 摘要:
// XML template format.
wdFormatXMLTemplate = 14,
//
// 摘要:
// XML template format with macros enabled.
wdFormatXMLTemplateMacroEnabled = 15,
//
// 摘要:
// Word default document file format. For Microsoft Office Word 2007, this is the
// DOCX format.
wdFormatDocumentDefault = 16,
//
// 摘要:
// PDF format.
wdFormatPDF = 17,
//
// 摘要:
// XPS format.
wdFormatXPS = 18,
//
// 摘要:
// Reserved for internal use.
wdFormatFlatXML = 19,
//
// 摘要:
// Reserved for internal use.
wdFormatFlatXMLMacroEnabled = 20,
//
// 摘要:
// Reserved for internal use.
wdFormatFlatXMLTemplate = 21,
//
// 摘要:
// Reserved for internal use.
wdFormatFlatXMLTemplateMacroEnabled = 22,
//
wdFormatOpenDocumentText = 23,
//
wdFormatStrictOpenXMLDocument = 24
}
}