
// The path to the documents directory.
string dataDir = Server.MapPath("~") + "/";
// Load the document from disk.
Document doc = new Document(dataDir + "计算机语言信息技术框架参考资源.docx");
// Save the document in HTML format.
doc.Save(dataDir + "Aspose_Words2.html", SaveFormat.Html);
// Launch the HTML file in default associated application (web browser)
Response.Redirect("Aspose_Words2.html");
try
{
string sourcePath = dataDir + @"计算机语言信息技术框架参考资源.docx"; //很多页
string targetPath = dataDir + @"geovindu.pdf";
// 打开Word文档
Document docpdf = new Document(sourcePath);
// 将Word文档保存为PDF格式
docpdf.Save(targetPath, SaveFormat.Pdf);
Response.Write("转换成功!");
}
catch (Exception ex)
{
Response.Write("错误: " + ex.Message);
}