Hi,
I want to inform you that annotation preview takes more loading time.So is there any optimization way to prevent more loading time ? plz suggest me.
Hello,
Thnx pavel for quick response.
I am using mentioned code in my controller load action but it throws an exception at time of preview as 'The Document can not be loaded '. Here is my code
Please go through it and suggest me any solution ASAP.
public ActionResult Index(int fileId, string userName)
{
try
{
DocumentCache cache = new DocumentCache(Server.MapPath("~/GroupDocs.Annotation.for.NET.lic"), Server.MapPath("~/App_Data/temp"));
cache.RemoveOldEntries(new TimeSpan(0, 5, 0), @“c:\GDViewerTmp\cache_clean_log.txt”);
if (!String.IsNullOrEmpty(userName))
{
SessionFacade.CurrentUserName = userName;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(userName, true, 1439200);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
cookie.Expires = ticket.Expiration;
Response.Cookies.Add(cookie);
}
else
{
SessionFacade.CurrentUserName = “”;
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName) { Expires = DateTime.UtcNow.AddDays(-1) };
Response.Cookies.Add(cookie);
Session.Abandon();
}
System.Web.Security.Membership.ValidateUser(userName, null);
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;
Session[“FileName”] = fileName;
Session[“FileId”] = fileId;
string url = string.Empty;
url = HttpContext.Request.Url.AbsoluteUri;
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;
Groupdocs.Web.UI.DocumentCache cacheDocument = new Groupdocs.Web.UI.DocumentCache(null, Server.MapPath("~/App_Data"),
Server.MapPath("~/App_Data/temp"));
cacheDocument.GenerateImages(ms, ViewBag._File, “pdf”, false, null, null, null, null);
}
}
catch (Exception ex)
{
}
return View();
}
Hello,
@(Html.Groupdocs()
.Annotation()
.Stream((Stream)ViewBag._Stream, ViewBag._File)
.ElementId(“annotation-widget”)
.FilePath(“Quick_Start_Guide_To_Using_GroupDocs.pdf”)
.ShowZoom(true)
.ShowPaging(true)
.ShowThumbnails(true)
.OpenThumbnails(false)
//.Zoom(75)
.PreloadPageCount(1)
.EnableRightClickMenu(false)
.ShowFileExplorer(false)
.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)
.HighlightColor(0xFFFF00)
.TextFieldBackgroundColor(0xf0f0f0)
.MinimumImageWidth(100))
Hello,
Hii,
I am using .Stream remove filePath but still it takes 20 sec to preview a file which is enough time so can you plz suggest me how can i reduce this loading time.
Hello,
ok Thnx