轉帖|對比評測|編輯:況魚杰|2019-06-21 11:18:29.243|閱讀 408 次
概述:本文章對比三款HTML5文檔查看器,最終選出干凈簡便的文檔查看器——GroupDocs.Viewer。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
GroupDocs.Viewer是一個在線文檔查看器,不管是否安裝了創建某個文檔的軟件,GroupDocs.Viewer都允許使用瀏覽器查看這個文檔。GroupDocs.Viewer支持查看多種文件文檔(DOC、DOCX、TXT、RTF、ODT),演示文檔(PPT、PPTX),電子表格(XLS、XLSX),便攜式文件(PDF)以及圖像文件(JPG、BMP、TIFF)。
我們這個項目就是探尋一款干凈簡便的HTML5文檔查看器,關于這方面的產品是很多的,所以這個探索過程是很繁瑣的,很多人的第一想法就是是使用Google Docs Viewer或類似的解決方案,但由于應用程序將在客戶端Intranet上運行,申請和文件都不允許暴露在互聯網上,所以這是不可行的。
經過探討,我們制定了以下標準:
適用于Windows Server和.NET。
支持PDF,包括新舊MS Office格式。
在不離開觸摸應用程序環境的情 最好支持從URL或.NET流中讀取文檔。
無需在客戶端計算機上安裝額外的插件。
探索
接下來就是大量的研究探索,最終我們尋找到了三個備選產品。
Accusofts Prizm Client Connect
這款產品符合我們的大多數標準,支持各種格式,但有一些缺點。它需要安裝一個單獨的服務器來進行文檔轉換。從他們提供下載的示例項目來判斷,它需要編寫大量代碼才能使其打勾。除此之外,它只提供從文件路徑加載文檔的可能性。
Snowbounds Virtualviewer
這款產品的必須作為服務器上的單獨網站運行,可以通過添加提供程序來擴展文檔的加載方式,在示例項目中支持文件和URL。但是用戶界面有點擁擠,視覺體驗不太好,而且還有許多不常用的功能。
雖然這兩種產品可能已經完成了這項工作,但我測試的第三種產品能夠彌補以上兩種產品的缺點。
與其他產品相比,這是很輕便的一個產品,只需添加一個DLL即可,它有一個非常簡潔的API。 最初不支持我們想要的打印的要求,但在與Groupdocs.交談并解釋需要的功能后,他們很快就推出了解決它的新版本。
添加代碼
在ASP.NET MVC應用程序中使用GroupDocs Viewer,必須完成四個步驟。
第一步:引用dll到項目中去
第二步:將以下項目加入Global.asax.
Viewer.InitRoutes(); Viewer.SetRootStoragePath(Server.MapPath("SomePath")); // Documents will also be cached here Viewer.SetLicensePath(Server.MapPath("SomePathToYourLisenceFile"));
第三步:在web.config文件中添加一些處理程序。
<add name="ViewDocumentHandler" verb="GET,POST" path="document-viewer/ViewDocumentHandler" type="Groupdocs.Web.UI.Handlers.ViewDocumentHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetDocumentPageImageHandler" verb="GET,POST" path="document-viewer/GetDocumentPageImageHandler" type="Groupdocs.Web.UI.Handlers.GetDocumentPageImageHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="LoadFileBrowserTreeDataHandler" verb="GET,POST" path="document-viewer/LoadFileBrowserTreeDataHandler" type="Groupdocs.Web.UI.Handlers.LoadFileBrowserTreeDataHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetImageUrlsHandler" verb="GET,POST" path="document-viewer/GetImageUrlsHandler" type="Groupdocs.Web.UI.Handlers.GetImageUrlsHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetCssHandler" verb="GET" path="document-viewer/CSS/GetCssHandler" type="Groupdocs.Web.UI.Handlers.CssHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="images" verb="GET" path="document-viewer/images/*" type="Groupdocs.Web.UI.Handlers.EmbeddedImageHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetScriptHandler" verb="GET,POST" path="document-viewer/GetScriptHandler" type="Groupdocs.Web.UI.Handlers.ScriptHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetFileHandler" verb="GET" path="document-viewer/GetFileHandler" type="Groupdocs.Web.UI.Handlers.GetFileHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetPdf2JavaScriptHandler" verb="GET,POST" path="document-viewer/GetPdf2JavaScriptHandler" type="Groupdocs.Web.UI.Handlers.GetPdf2JavaScriptHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetPdfWithPrintDialogHandler" verb="POST" path="document-viewer/GetPdfWithPrintDialogHandler" type="Groupdocs.Web.UI.Handlers.GetPdfWithPrintDialogHandler, Groupdocs.Viewer, Culture=neutral" /> <add name="GetPrintableHtmlHandler" verb="GET,POST" path="document-viewer/GetPrintableHtmlHandler" type="Groupdocs.Web.UI.Handlers.GetPrintableHtmlHandler, Groupdocs.Viewer, Culture=neutral" />
第四步:在視圖中加入以下內容
//loads the javascripts that groupsdocs viewer needs@Html.CreateViewerScriptLoadBlock().LoadJquery().LoadJqueryUi() @(Html.ViewerClientCode() .TargetElementSelector("#documentContainer") .Stream(SomeDotNetStream) // fetch document from a stream //.Url("SomeUrl") fetch from a url //.FilePath("SomeFile") fetch from filepath .DocViewerId("SomeViewerId") //different functionality can be turned on and off, this is just an example on how we have set them .EnableRightClickMenu(true) .ShowThumbnails(false) .OpenThumbnails(false) .ShowFolderBrowser(false) .ShowDownload(false) .ShowViewerStyleControl(false) .ShowSearch(false) .UsePdfPrinting(false) .BackgroundColor("black") .Width(960) .Height(900) .ZoomToFitWidth(true) .Locale("nb-no") )
如對以上內容存有疑惑,可以點擊解答疑惑
年中活動,優惠多多,點擊就可領取 MyEclipse 、.NET Reactor、FastReport .Net、VMProtect等超多在線訂購產品優惠券!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn