Ejemplo n.º 1
0
        public static ViewDocumentResponse ViewDocument(ViewDocumentParameters request)
        {
            if (Utils.IsValidUrl(request.Path))
            {
                request.Path = DownloadToStorage(request.Path);
            }
            else if (_streams.ContainsKey(request.Path))
            {
                request.Path = SaveStreamToStorage(request.Path);
            }

            var fileName = Path.GetFileName(request.Path);

            var result = new ViewDocumentResponse
            {
                pageCss        = new string[] { },
                lic            = true,
                pdfDownloadUrl = GetPdfDownloadUrl(request),
                pdfPrintUrl    = GetPdfPrintUrl(request),
                url            = GetFileUrl(request),
                path           = request.Path,
                name           = fileName
            };

            if (request.UseHtmlBasedEngine)
            {
                ViewDocumentAsHtml(request, result, fileName);
            }
            else
            {
                ViewDocumentAsImage(request, result, fileName);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult ViewDocument(ViewDocumentParameters request)
        {
            if (Utils.IsValidUrl(request.Path))
            {
                request.Path = DownloadToStorage(request.Path);
            }

            var result = new ViewDocumentResponse
            {
                pageCss        = new string[] { },
                lic            = true,
                pdfDownloadUrl = GetPdfDownloadUrl(request),
                pdfPrintUrl    = GetPdfPrintUrl(request),
                url            = GetFileUrl(request),
                path           = request.Path,
                name           = Path.GetFileName(request.Path)
            };

            if (request.UseHtmlBasedEngine)
            {
                ViewDocumentAsHtml(request, result);
            }
            else
            {
                ViewDocumentAsImage(request, result);
            }

            return(new LargeJsonResult {
                Data = result
            });
        }
        public ActionResult ViewDocument(ViewDocumentParameters request)
        {
            string fileName = Path.GetFileName(request.Path);

            ViewDocumentResponse result = new ViewDocumentResponse
            {
                pageCss        = new string[] { },
                lic            = true,
                pdfDownloadUrl = GetPdfDownloadUrl(request),
                url            = GetFileUrl(request),
                path           = request.Path,
                name           = fileName
            };

            DocumentInfoContainer docInfo = annotator.GetDocumentInfo(request.Path);

            result.documentDescription = new FileDataJsonSerializer(docInfo.Pages).Serialize(true);
            result.docType             = docInfo.DocumentType.ToLower();
            result.fileType            = docInfo.FileType.ToLower();

            string applicationHost = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/');

            var preloadCount = request.PreloadPagesCount;
            int pageCount    = preloadCount ?? 1;

            int[] pageNumbers = new int[docInfo.Pages.Count];
            for (int i = 0; i < pageNumbers.Length; i++)
            {
                pageNumbers[i] = i;
            }


            GetImageUrlsParameters imageUrlParameters = new GetImageUrlsParameters()
            {
                Path                = request.Path,
                FirstPage           = 0,
                PageCount           = pageNumbers.Length,
                UsePdf              = docInfo.Extension.ToLower().Equals("pdf"),
                Width               = docInfo.Pages[0].Width,
                SupportPageRotation = false,
                UseHtmlBasedEngine  = false
            };


            result.imageUrls = GetImageUrls(applicationHost, pageNumbers, imageUrlParameters);

            //result.imageUrls = urls.ToArray();

            JavaScriptSerializer serializer = new JavaScriptSerializer {
                MaxJsonLength = int.MaxValue
            };

            string serializedData = serializer.Serialize(result);

            // invoke event
            new DocumentOpenSubscriber().HandleEvent(request.Path);

            return(Content(serializedData, "application/json"));
        }
Ejemplo n.º 4
0
        public static ViewDocumentResponse ViewDocument(string path)
        {
            string request = path;

            string fileName             = Path.GetFileName(request);
            var    pathFinder           = new ApplicationPathFinder();
            string _appPath             = pathFinder.GetApplicationPath();
            ViewDocumentResponse result = new ViewDocumentResponse
            {
                pageCss        = new string[] { },
                lic            = true,
                pdfDownloadUrl = _appPath + "App_Data/" + request,
                url            = _appPath + "App_Data/" + request,
                path           = request,
                name           = fileName
            };
            DocumentInfoContainer docInfo = annotator.GetDocumentInfo(request);

            result.documentDescription = new FileDataJsonSerializer(docInfo.Pages).Serialize(true);
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;

            List <PageImage> imagePages = annotator.GetPages(request);

            // Provide images urls
            List <string> urls = new List <string>();

            // If no cache - save images to temp folder
            string tempFolderPath = Path.Combine(HttpContext.Current.Server.MapPath("~"), "Content", "TempStorage");

            foreach (PageImage pageImage in imagePages)
            {
                string docFoldePath = Path.Combine(tempFolderPath, request);

                if (!Directory.Exists(docFoldePath))
                {
                    Directory.CreateDirectory(docFoldePath);
                }

                string pageImageName = string.Format("{0}\\{1}.png", docFoldePath, pageImage.PageNumber);

                using (Stream stream = pageImage.Stream)
                    using (FileStream fileStream = new FileStream(pageImageName, FileMode.Create))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        stream.CopyTo(fileStream);
                    }
                string baseUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/";
                urls.Add(string.Format("{0}Content/TempStorage/{1}/{2}.png", baseUrl, request, pageImage.PageNumber));
            }

            result.imageUrls = urls.ToArray();

            // invoke event
            new DocumentOpenSubscriber().HandleEvent(request, _annotationSvc);

            return(result);
        }
Ejemplo n.º 5
0
        private static void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result, string fileName)
        {
            var htmlHandler = (ViewerHtmlHandler)HttpContext.Current.Session["htmlHandler"];

            var docInfo = htmlHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

            var maxWidth  = 0;
            var maxHeight = 0;

            foreach (var pageData in docInfo.Pages)
            {
                if (pageData.Height > maxHeight)
                {
                    maxHeight = pageData.Height;
                    maxWidth  = pageData.Width;
                }
            }
            var fileData = new FileData
            {
                DateCreated  = DateTime.Now,
                DateModified = docInfo.LastModificationDate,
                PageCount    = docInfo.Pages.Count,
                Pages        = docInfo.Pages,
                MaxWidth     = maxWidth,
                MaxHeight    = maxHeight
            };

            result.documentDescription = new FileDataJsonSerializer(fileData, new FileDataOptions()).Serialize(false);
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;

            var htmlOptions = new HtmlOptions
            {
                // IsResourcesEmbedded = Utils.IsImage(fileName),
                IsResourcesEmbedded = false,
                HtmlResourcePrefix  = string.Format("/GetResourceForHtml.aspx?documentPath={0}", fileName) + "&pageNumber={page-number}&resourceName=",
            };

            if (request.PreloadPagesCount.HasValue && request.PreloadPagesCount.Value > 0)
            {
                htmlOptions.PageNumber          = 1;
                htmlOptions.CountPagesToConvert = request.PreloadPagesCount.Value;
            }

            List <string> cssList;



            var htmlPages = GetHtmlPages(fileName, htmlOptions, out cssList);

            result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();
            result.pageCss  = new[] { string.Join(" ", cssList) };
        }
Ejemplo n.º 6
0
        public ViewDocumentViewModel Present(ViewDocumentResponse response)
        {
            var project = RepositoryProvider.Project.Read(response.Project);

            return(new ViewDocumentViewModel
            {
                Id = response.Id.ToPresentationIdentity(),
                Name = response.Name,
                Project = project.ToViewModel(),
                Content = response.Content,
                DocumentType = DocumentKindToUserType(response.Kind),
                Links = response.Links.ToArray(),
                Tasks = response.Tasks.Select(x => RepositoryProvider.WorkTask.Read(x).ToViewModel()).ToArray(),
                Meetings = response.Meetings.Select(x => RepositoryProvider.Meeting.Read(x).ToViewModel()).ToArray(),
                Sprints = response.Sprints.Select(x => RepositoryProvider.Sprint.Read(x).ToViewModel()).ToArray(),
            });
        }
Ejemplo n.º 7
0
        public JsonResult LoadDocument(string fullName)
        {
            if (!string.IsNullOrEmpty(fullName))
            {
                var result = new ViewDocumentResponse
                {
                    pageCss = new string[] {},
                    lic     = true,
                    url     = fullName,
                    path    = fullName,
                    name    = fullName
                };


                var docInfo = _htmlHandler.GetDocumentInfo(new GroupDocs.Viewer.Domain.Options.DocumentInfoOptions(fullName));

                result.documentDescription =
                    new FileDataJsonSerializer(docInfo.Pages, new FileDataOptions()).Serialize(false);
                result.docType  = docInfo.DocumentType;
                result.fileType = docInfo.FileType;

                var htmlOptions = new HtmlOptions {
                    IsResourcesEmbedded = true
                };

                var htmlPages = _htmlHandler.GetPages(fullName, htmlOptions);
                result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();

                //NOTE: Fix for incomplete cells document
                for (int i = 0; i < result.pageHtml.Length; i++)
                {
                    var html          = result.pageHtml[i];
                    var indexOfScript = html.IndexOf("script");
                    if (indexOfScript > 0)
                    {
                        result.pageHtml[i] = html.Substring(0, indexOfScript);
                    }
                }

                AjaxResponse ajaxResponse = AjaxResponse.Successful(string.Empty, result);

                return(Json(ajaxResponse));
            }
            return(null);
        }
        public ActionResult ViewDocument(ViewDocumentParameters request)
        {
            try
            {
                if (Utils.IsValidUrl(request.Path))
                {
                    request.Path = DownloadToStorage(request.Path);
                }
                else if (_streams.ContainsKey(request.Path))
                {
                    request.Path = SaveStreamToStorage(request.Path);
                }

                var fileName = Path.GetFileName(request.Path);

                var result = new ViewDocumentResponse
                {
                    pageCss        = new string[] { },
                    lic            = true,
                    pdfDownloadUrl = GetPdfDownloadUrl(request),
                    pdfPrintUrl    = GetPdfPrintUrl(request),
                    url            = GetFileUrl(request),
                    path           = request.Path,
                    name           = fileName
                };

                if (request.UseHtmlBasedEngine)
                {
                    ViewDocumentAsHtml(request, result, fileName);
                }
                else
                {
                    ViewDocumentAsImage(request, result, fileName);
                }

                return(ToJsonResult(result));
            }
            catch (Exception e)
            {
                return(this.JsonOrJsonP(new FailedResponse {
                    Reason = e.Message
                }, null));
            }
        }
Ejemplo n.º 9
0
        private static void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result, string fileName)
        {
            var docInfo = _imageHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

            var maxWidth  = 0;
            var maxHeight = 0;

            foreach (var pageData in docInfo.Pages)
            {
                if (pageData.Height > maxHeight)
                {
                    maxHeight = pageData.Height;
                    maxWidth  = pageData.Width;
                }
            }
            var fileData = new FileData
            {
                DateCreated  = DateTime.Now,
                DateModified = docInfo.LastModificationDate,
                PageCount    = docInfo.Pages.Count,
                Pages        = docInfo.Pages,
                MaxWidth     = maxWidth,
                MaxHeight    = maxHeight
            };

            result.documentDescription = new FileDataJsonSerializer(fileData, new FileDataOptions()).Serialize(true);
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;

            DocumentInfoOptions   documentInfoOptions   = new DocumentInfoOptions(request.Path);
            DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions);

            int[] pageNumbers = new int[documentInfoContainer.Pages.Count];
            for (int i = 0; i < documentInfoContainer.Pages.Count; i++)
            {
                pageNumbers[i] = documentInfoContainer.Pages[i].Number;
            }

            string applicationHost = GetApplicationHost();

            result.imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, request);
        }
Ejemplo n.º 10
0
        private void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result)
        {
            var guid     = request.Path;
            var fileName = Path.GetFileName(request.Path);

            // Get document info
            var documentInfo = _htmlHandler.GetDocumentInfo(guid);

            // Serialize document info
            SerializationOptions serializationOptions = new SerializationOptions
            {
                UsePdf                       = false,
                IsHtmlMode                   = true,
                SupportListOfBookmarks       = request.SupportListOfBookmarks,
                SupportListOfContentControls = request.SupportListOfContentControls
            };
            var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions).Serialize();

            // Build html options
            var htmlOptions = new HtmlOptions
            {
                IsResourcesEmbedded = Utils.IsImage(fileName),
                HtmlResourcePrefix  = GetHtmlResourcePrefix(guid),
                PageNumber          = 1,
                CountPagesToRender  = request.PreloadPagesCount.GetValueOrDefault(1)
            };
            var htmlPageContents = GetHtmlPageContents(guid, htmlOptions);

            // Build result
            result.pageHtml = htmlPageContents
                              .Select(_ => _.Html)
                              .ToArray();
            result.pageCss = htmlPageContents
                             .Where(_ => !string.IsNullOrEmpty(_.Css))
                             .Select(_ => _.Css)
                             .ToArray();
            result.documentDescription = documentInfoJson;
            result.docType             = documentInfo.DocumentType;
            result.fileType            = GetFileTypeOrEmptyString(documentInfo.FileType);
        }
Ejemplo n.º 11
0
        private void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result)
        {
            var guid = request.Path;

            // Get document info
            var documentInfo = _imageHandler.GetDocumentInfo(guid);

            // Serialize document info
            SerializationOptions serializationOptions = new SerializationOptions
            {
                UsePdf = request.UsePdf,
                SupportListOfBookmarks       = request.SupportListOfBookmarks,
                SupportListOfContentControls = request.SupportListOfContentControls
            };
            var documentInfoJson = new DocumentInfoJsonSerializer(documentInfo, serializationOptions)
                                   .Serialize();

            // Build result
            result.documentDescription = documentInfoJson;
            result.docType             = documentInfo.DocumentType;
            result.fileType            = documentInfo.FileType;
            int[] pageNumbers = documentInfo.Pages.Select(_ => _.Number).ToArray();
            result.imageUrls = ImageUrlHelper.GetImageUrls(GetApplicationHost(), pageNumbers, request);
        }
Ejemplo n.º 12
0
        private static void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result, string fileName)
        {
            var htmlHandler = (ViewerHtmlHandler)HttpContext.Current.Session["htmlHandler"];

            var docInfo = htmlHandler.GetDocumentInfo(request.Path);

            var maxWidth  = 0;
            var maxHeight = 0;

            foreach (var pageData in docInfo.Pages)
            {
                if (pageData.Height > maxHeight)
                {
                    maxHeight = pageData.Height;
                    maxWidth  = pageData.Width;
                }
            }
            var fileData = new FileData
            {
                DateCreated  = DateTime.Now,
                DateModified = docInfo.LastModificationDate,
                PageCount    = docInfo.Pages.Count,
                Pages        = docInfo.Pages,
                MaxWidth     = maxWidth,
                MaxHeight    = maxHeight
            };



            var htmlOptions = new HtmlOptions
            {
                // IsResourcesEmbedded = Utils.IsImage(fileName),
                IsResourcesEmbedded = false,
                HtmlResourcePrefix  = string.Format("/GetResourceForHtml.aspx?documentPath={0}", fileName) + "&pageNumber={page-number}&resourceName=",
            };

            if (request.PreloadPagesCount.HasValue && request.PreloadPagesCount.Value > 0)
            {
                htmlOptions.PageNumber         = 1;
                htmlOptions.CountPagesToRender = request.PreloadPagesCount.Value;
            }

            List <string> cssList;
            var           htmlPages = GetHtmlPages(fileName, fileName, htmlOptions, out cssList);

            foreach (AttachmentBase attachment in docInfo.Attachments)
            {
                var attachmentPath         = _tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name;
                var attachmentResourcePath = HttpUtility.UrlEncode(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name.Replace(".", "_"));
                var attachmentHtmlOptions  = new HtmlOptions()
                {
                    IsResourcesEmbedded = Utils.IsImage(fileName),
                    HtmlResourcePrefix  = string.Format("/GetResourceForHtml.aspx?documentPath={0}", HttpUtility.UrlEncode(attachmentPath)) + "&pageNumber={page-number}&resourceName=",
                };
                List <PageHtml> pages          = _htmlHandler.GetPages(attachment, attachmentHtmlOptions);
                var             attachmentInfo = _htmlHandler.GetDocumentInfo(attachmentPath);
                fileData.PageCount += attachmentInfo.Pages.Count;
                fileData.Pages.AddRange(attachmentInfo.Pages);
                List <string> attachmentCSSList;
                var           attachmentPages = GetHtmlPages(attachmentPath, attachmentResourcePath, attachmentHtmlOptions, out attachmentCSSList);
                cssList.AddRange(attachmentCSSList);
                htmlPages.AddRange(attachmentPages);
            }
            SerializationOptions serializationOptions = new SerializationOptions
            {
                UsePdf = request.UsePdf,
                SupportListOfBookmarks       = request.SupportListOfBookmarks,
                SupportListOfContentControls = request.SupportListOfContentControls
            };
            var documentInfoJson = new DocumentInfoJsonSerializer(docInfo, serializationOptions).Serialize();

            result.documentDescription = documentInfoJson;
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;
            result.pageHtml            = htmlPages.Select(_ => _.HtmlContent).ToArray();
            result.pageCss             = new[] { string.Join(" ", cssList) };
        }
Ejemplo n.º 13
0
        private static void ViewDocumentAsImage(ViewDocumentParameters request, ViewDocumentResponse result, string fileName)
        {
            var docInfo = _imageHandler.GetDocumentInfo(request.Path);

            var maxWidth  = 0;
            var maxHeight = 0;

            foreach (var pageData in docInfo.Pages)
            {
                if (pageData.Height > maxHeight)
                {
                    maxHeight = pageData.Height;
                    maxWidth  = pageData.Width;
                }
            }
            var fileData = new FileData
            {
                DateCreated  = DateTime.Now,
                DateModified = docInfo.LastModificationDate,
                PageCount    = docInfo.Pages.Count,
                Pages        = docInfo.Pages,
                MaxWidth     = maxWidth,
                MaxHeight    = maxHeight
            };

            int[] pageNumbers = new int[docInfo.Pages.Count];
            for (int i = 0; i < docInfo.Pages.Count; i++)
            {
                pageNumbers[i] = docInfo.Pages[i].Number;
            }
            string applicationHost = GetApplicationHost();
            var    documentUrls    = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, request);

            string[] attachmentUrls = new string[0];
            foreach (AttachmentBase attachment in docInfo.Attachments)
            {
                List <PageImage> pages = _imageHandler.GetPages(attachment);
                var attachmentInfo     = _imageHandler.GetDocumentInfo(_tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name);
                fileData.PageCount += pages.Count;
                fileData.Pages.AddRange(attachmentInfo.Pages);

                ViewDocumentParameters attachmentResponse = request;
                attachmentResponse.Path = attachmentInfo.Guid;
                int[] attachmentPageNumbers = new int[pages.Count];
                for (int i = 0; i < pages.Count; i++)
                {
                    attachmentPageNumbers[i] = pages[i].PageNumber;
                }
                Array.Resize <string>(ref attachmentUrls, (attachmentUrls.Length + pages.Count));
                string[] attachmentImagesUrls = new string[pages.Count];
                attachmentImagesUrls = ImageUrlHelper.GetImageUrls(applicationHost, attachmentPageNumbers, attachmentResponse);
                attachmentImagesUrls.CopyTo(attachmentUrls, (attachmentUrls.Length - pages.Count));
            }
            SerializationOptions serializationOptions = new SerializationOptions
            {
                UsePdf = request.UsePdf,
                SupportListOfBookmarks       = request.SupportListOfBookmarks,
                SupportListOfContentControls = request.SupportListOfContentControls
            };
            var documentInfoJson = new DocumentInfoJsonSerializer(docInfo, serializationOptions).Serialize();

            result.documentDescription = documentInfoJson;

            result.docType  = docInfo.DocumentType;
            result.fileType = docInfo.FileType;
            if (docInfo.Attachments.Count > 0)
            {
                var imagesUrls = new string[attachmentUrls.Length + documentUrls.Length];
                documentUrls.CopyTo(imagesUrls, 0);
                attachmentUrls.CopyTo(imagesUrls, documentUrls.Length);
                result.imageUrls = imagesUrls;
            }
            else
            {
                result.imageUrls = documentUrls;
            }
        }
        public ActionResult ViewDocument(ViewDocumentParameters request)
        {
            var fileName = Path.GetFileName(request.Path);

            var result = new ViewDocumentResponse
            {
                pageCss        = new string[] {},
                lic            = true,
                pdfDownloadUrl = GetPdfDownloadUrl(request),
                pdfPrintUrl    = GetPdfPrintUrl(request),
                url            = GetFileUrl(request),
                path           = request.Path,
                name           = fileName
            };

            var docInfo = _imageHandler.GetDocumentInfo(new DocumentInfoOptions(request.Path));

            result.documentDescription = new FileDataJsonSerializer(docInfo.Pages, new FileDataOptions()).Serialize(true);
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;

            var imageOptions = new ImageOptions {
                Watermark = GetWatermark(request)
            };
            var imagePages = _imageHandler.GetPages(request.Path, imageOptions);

            // Provide images urls
            var urls = new List <string>();

            // If no cache - save images to temp folder
            //var tempFolderPath = Path.Combine(Microsoft.SqlServer.Server.MapPath("~"), "Content", "TempStorage");
            var tempFolderPath = Path.Combine(HttpContext.Server.MapPath("~"), "Content", "TempStorage");

            foreach (var pageImage in imagePages)
            {
                var docFoldePath = Path.Combine(tempFolderPath, request.Path);

                if (!Directory.Exists(docFoldePath))
                {
                    Directory.CreateDirectory(docFoldePath);
                }

                var pageImageName = string.Format("{0}\\{1}.png", docFoldePath, pageImage.PageNumber);

                using (var stream = pageImage.Stream)
                    using (FileStream fileStream = new FileStream(pageImageName, FileMode.Create))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        stream.CopyTo(fileStream);
                    }

                var baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') +
                              "/";
                urls.Add(string.Format("{0}Content/TempStorage/{1}/{2}.png", baseUrl, request.Path, pageImage.PageNumber));
            }

            result.imageUrls = urls.ToArray();

            var serializer = new JavaScriptSerializer {
                MaxJsonLength = int.MaxValue
            };

            var serializedData = serializer.Serialize(result);

            return(Content(serializedData, "application/json"));
        }
        private void ViewDocumentAsHtml(ViewDocumentParameters request, ViewDocumentResponse result, string fileName)
        {
            var docInfo = _htmlHandler.GetDocumentInfo(request.Path);

            var maxWidth  = 0;
            var maxHeight = 0;

            foreach (var pageData in docInfo.Pages)
            {
                if (pageData.Height > maxHeight)
                {
                    maxHeight = pageData.Height;
                    maxWidth  = pageData.Width;
                }
            }
            var fileData = new FileData
            {
                DateCreated  = DateTime.Now,
                DateModified = docInfo.LastModificationDate,
                PageCount    = docInfo.Pages.Count,
                Pages        = docInfo.Pages,
                MaxWidth     = maxWidth,
                MaxHeight    = maxHeight
            };

            var htmlOptions = new HtmlOptions()
            {
                IsResourcesEmbedded = false,
                HtmlResourcePrefix  = string.Format(
                    "/document-viewer/GetResourceForHtml?documentPath={0}", HttpUtility.UrlEncode(fileName)) + "&pageNumber={page-number}&resourceName=",
                Watermark = Utils.GetWatermark(request.WatermarkText, request.WatermarkColor,
                                               request.WatermarkPosition, request.WatermarkWidth, request.WatermarkOpacity),
            };

            if (request.PreloadPagesCount.HasValue && request.PreloadPagesCount.Value > 0)
            {
                htmlOptions.PageNumber         = 1;
                htmlOptions.CountPagesToRender = request.PreloadPagesCount.Value;
            }
            /////
            List <string> cssList;
            var           htmlPages = GetHtmlPages(fileName, htmlOptions, out cssList);

            foreach (AttachmentBase attachment in docInfo.Attachments)
            {
                var attachmentPath        = _tempPath + "\\" + Path.GetFileNameWithoutExtension(docInfo.Guid) + Path.GetExtension(docInfo.Guid).Replace(".", "_") + "\\attachments\\" + attachment.Name;
                var attachmentHtmlOptions = new HtmlOptions()
                {
                    IsResourcesEmbedded = Utils.IsImage(fileName),
                    HtmlResourcePrefix  = string.Format("/document-viewer/GetResourceForHtml?documentPath={0}", HttpUtility.UrlEncode(attachmentPath)) + "&pageNumber={page-number}&resourceName=",
                };
                List <PageHtml> pages          = _htmlHandler.GetPages(attachment, attachmentHtmlOptions);
                var             attachmentInfo = _htmlHandler.GetDocumentInfo(attachmentPath);
                fileData.PageCount += attachmentInfo.Pages.Count;
                fileData.Pages.AddRange(attachmentInfo.Pages);
                List <string> attachmentCSSList;
                var           attachmentPages = GetHtmlPages(attachmentInfo.Guid, attachmentHtmlOptions, out attachmentCSSList);
                cssList.AddRange(attachmentCSSList);
                htmlPages.AddRange(attachmentPages);
            }
            /////
            result.documentDescription = new FileDataJsonSerializer(fileData, new FileDataOptions()).Serialize(false);
            result.docType             = docInfo.DocumentType;
            result.fileType            = docInfo.FileType;

            result.pageHtml = htmlPages.Select(_ => _.HtmlContent).ToArray();
            result.pageCss  = new[] { string.Join(" ", cssList) };
        }