Hi,
i am previewing a file having file size 2 MB for previewing this file it will take min 5-7 minutes.But i want reduce this time within some seconds.Below i will describe my code which was provided by you .Plz go through it and let me inform where i am doing fault which was not affect any changes in previewing time rather provides an error at time of previewing as 'The Document cannot be loaded '. I am also attached file which takes time.Plz test using that file.
Code Inside Controller :
public ActionResult Index(int fileId, string userName)
{
string url = string.Empty;
HttpRequest request = System.Web.HttpContext.Current.Request;
url = “http://” + request[“HTTP_HOST”] + “/”;
Groupdocs.Web.UI.DocumentCache cacheDocument = new Groupdocs.Web.UI.DocumentCache(null, Server.MapPath("~/App_Data"),
Server.MapPath("~/App_Data/temp"));
cacheDocument.RemoveOldEntries(new TimeSpan(0, 5, 0), @“c:\GDViewerTmp\cache_clean_log.txt”);
Session[“DocumentId”] = null;
Session[“UserName”] = null;
Session[“FileName”] = null;
byte[] fileBytes = document.GetFileFromDB(fileId);
int documentId = document.GetDocumentId(fileId);
string fileName = document.GetFileName(fileId);
Session[“DocumentId”] = documentId;
Session[“UserName”] = userName;
SessionFacade.CurrentUserName = userName;
Session[“FileName”] = fileName;
Session[“FileId”] = fileId;
if (fileBytes != null)
{
System.IO.MemoryStream ms = new System.IO.MemoryStream(fileBytes);
ms.Position = 0;//note this line!!!
this.ByteStream = new System.IO.MemoryStream(fileBytes);
ViewBag._Stream = ms;
ViewBag.File = documentId+""+fileName;
cacheDocument.GenerateImages(ms, ViewBag._File, “.pdf”);
}
return View();
}
View : -
@(Html.Groupdocs()
.Annotation()
.Stream((Stream)ViewBag._Stream, ViewBag._File)
.ElementId(“annotation-widget”)
.AccessRights(Groupdocs.Common.AnnotationReviewerRights.CanAnnotate)
.ShowZoom(true)
.ShowPaging(true)
.ShowPrint(true)
.ShowThumbnails(true)
.OpenThumbnails(false)
.PreloadPageCount(1)
.EnableRightClickMenu(false)
.ShowFileExplorer(true)
.Tools(Groupdocs.Web.Annotation.AnnotationTools.All)
.ShowHeader(true)
.EnableTextSelection(true)
.StrikeoutMode(Groupdocs.Common.StrikeoutToolMode.Remove)
.ScrollOnFocus(true)
.ClickableAnnotations(true)
.ConnectorPos(Groupdocs.Web.Annotation.ConnectorPosition.Bottom)
.AreaToolOptions(new Groupdocs.Web.Annotation.DrawingOptions { PenWidth = 1, DashStyle = Groupdocs.Common.DashStyle.Solid, PenColor = 0xFF0000,BrushColor=16776960 })
.PolylineToolOptions(new Groupdocs.Web.Annotation.DrawingOptions { PenWidth = 1, DashStyle = Groupdocs.Common.DashStyle.Dash, PenColor = 0xFF0000 })
.ArrowToolOptions(new Groupdocs.Web.Annotation.DrawingOptions { PenWidth = 1, DashStyle = Groupdocs.Common.DashStyle.Solid, PenColor = 0xFF0000 })
.DisconnectUncommented(true)
.ShowToolbar(true)
.HighlightColor(0xFFFF00)
.TextFieldBackgroundColor(0xf0f0f0)
.MinimumImageWidth(100))