轉(zhuǎn)帖|對比評測|編輯:況魚杰|2019-06-21 11:18:29.243|閱讀 408 次
概述:本文章對比三款HTML5文檔查看器,最終選出干凈簡便的文檔查看器——GroupDocs.Viewer。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
GroupDocs.Viewer是一個(gè)在線文檔查看器,不管是否安裝了創(chuàng)建某個(gè)文檔的軟件,GroupDocs.Viewer都允許使用瀏覽器查看這個(gè)文檔。GroupDocs.Viewer支持查看多種文件文檔(DOC、DOCX、TXT、RTF、ODT),演示文檔(PPT、PPTX),電子表格(XLS、XLSX),便攜式文件(PDF)以及圖像文件(JPG、BMP、TIFF)。
我們這個(gè)項(xiàng)目就是探尋一款干凈簡便的HTML5文檔查看器,關(guān)于這方面的產(chǎn)品是很多的,所以這個(gè)探索過程是很繁瑣的,很多人的第一想法就是是使用Google Docs Viewer或類似的解決方案,但由于應(yīng)用程序?qū)⒃诳蛻舳薎ntranet上運(yùn)行,申請和文件都不允許暴露在互聯(lián)網(wǎng)上,所以這是不可行的。
經(jīng)過探討,我們制定了以下標(biāo)準(zhǔn):
適用于Windows Server和.NET。
支持PDF,包括新舊MS Office格式。
在不離開觸摸應(yīng)用程序環(huán)境的情 最好支持從URL或.NET流中讀取文檔。
無需在客戶端計(jì)算機(jī)上安裝額外的插件。
探索
接下來就是大量的研究探索,最終我們尋找到了三個(gè)備選產(chǎn)品。
Accusofts Prizm Client Connect
這款產(chǎn)品符合我們的大多數(shù)標(biāo)準(zhǔn),支持各種格式,但有一些缺點(diǎn)。它需要安裝一個(gè)單獨(dú)的服務(wù)器來進(jìn)行文檔轉(zhuǎn)換。從他們提供下載的示例項(xiàng)目來判斷,它需要編寫大量代碼才能使其打勾。除此之外,它只提供從文件路徑加載文檔的可能性。
Snowbounds Virtualviewer
這款產(chǎn)品的必須作為服務(wù)器上的單獨(dú)網(wǎng)站運(yùn)行,可以通過添加提供程序來擴(kuò)展文檔的加載方式,在示例項(xiàng)目中支持文件和URL。但是用戶界面有點(diǎn)擁擠,視覺體驗(yàn)不太好,而且還有許多不常用的功能。
雖然這兩種產(chǎn)品可能已經(jīng)完成了這項(xiàng)工作,但我測試的第三種產(chǎn)品能夠彌補(bǔ)以上兩種產(chǎn)品的缺點(diǎn)。
與其他產(chǎn)品相比,這是很輕便的一個(gè)產(chǎn)品,只需添加一個(gè)DLL即可,它有一個(gè)非常簡潔的API。 最初不支持我們想要的打印的要求,但在與Groupdocs.交談并解釋需要的功能后,他們很快就推出了解決它的新版本。
添加代碼
在ASP.NET MVC應(yīng)用程序中使用GroupDocs Viewer,必須完成四個(gè)步驟。
第一步:引用dll到項(xiàng)目中去
第二步:將以下項(xiàng)目加入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" />
第四步:在視圖中加入以下內(nèi)容
//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") )
如對以上內(nèi)容存有疑惑,可以點(diǎn)擊解答疑惑
年中活動(dòng),優(yōu)惠多多,點(diǎn)擊就可領(lǐng)取 MyEclipse 、.NET Reactor、FastReport .Net、VMProtect等超多在線訂購產(chǎn)品優(yōu)惠券!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn