2013-02-14 17 views
0

我從包含從.mhtml文件轉換而來的圖像導出Word文檔。 我參考下面的鏈接導出單詞。從MVC中的.mhtml導出帶有打印版面的文字

http://www.revium.com.au/articles/sandbox/aspnet-mvc-convert-view-to-word-document/

現在這個詞是獲取導出但其在網絡佈局。但我需要打印版面中的文檔。

任何人都可以幫助我解決這個問題。

編輯

我解決了以下鏈接

http://forums.aspfree.com/asp-development-5/open-ms-word-documents-print-layout-view-57860.html

幫助你總是可以逆向工程它的問題。用文字打開你的文檔。按照你想要的方式完成並保存爲html。用文本編輯器打開並使用你所需要的。

這就是我所做的。

<head> 
<meta http-equiv=Content-Type content="text/html; charset=us-ascii"> 
<meta name=ProgId content=Word.Document> 
<meta name=Generator content="Microsoft Word 9"> 
<meta name=Originator content="Microsoft Word 9"> 
<title></title> 
<!--[if gte mso 9]><xml> 
<o:DocumentProperties> 
</o:DocumentProperties> 
</xml><![endif]--><!--[if gte mso 9]><xml> 
<w:WordDocument> 
    <w:View>Print</w:View> 
</w:WordDocument> 
</xml><![endif]--> 
</head> 

我還添加了一些額外的代碼生成的我的話,只有我得到它正確。

希望這會幫助面臨同樣問題的人。

回答

0

將文件寫入響應庫,從流中獲取字節並嘗試。它應該強制下載文件

HttpResponseBase.OutputStream(fileBytes,0,fileBytes.GetLength(0)); 
+0

感謝您的快速響應。它顯示以下錯誤'不可調用成員'System.Web.HttpResponseBase.OutputStream'不能用於像方法'如何使用上述代碼。 – 2013-02-14 17:22:51

相關問題