static void Main(string[] args)
        {
            //Loading a presentation
            using (Presentation pres = new Presentation("example.pptx"))
            {
                const string path = "path";
                const string fileName = "video.html";
                const string baseUri = "http://www.example.com/";

                VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path: path, fileName: fileName, baseUri: baseUri);

                //Setting HTML options
                HtmlOptions htmlOptions = new HtmlOptions(controller);
                SVGOptions svgOptions = new SVGOptions(controller);

                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller);
                htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions);

                //Saving the file
                pres.Save(path + fileName, SaveFormat.Html, htmlOptions);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Loading a presentation
            using (Presentation pres = new Presentation(dataDir + "Media File.pptx"))
            {
                string path = dataDir;
                const string fileName = "ExportMediaFiles_out.html";
                const string baseUri = "http://www.example.com/";

                VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path, fileName, baseUri);

                // Setting HTML options
                HtmlOptions htmlOptions = new HtmlOptions(controller);
                SVGOptions svgOptions = new SVGOptions(controller);

                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller);
                htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions);

                // Saving the file
                pres.Save(Path.Combine(path, fileName), SaveFormat.Html, htmlOptions);
            }
        }
Example #3
0
        /// <summary>
        /// Creates a HTML fragment for the selected text.
        /// </summary>
        public string CreateHtmlFragment(TextArea textArea, HtmlOptions options)
        {
            if (textArea == null)
            {
                throw new ArgumentNullException("textArea");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            IHighlighter  highlighter = textArea.GetService(typeof(IHighlighter)) as IHighlighter;
            StringBuilder html        = new StringBuilder();
            bool          first       = true;

            foreach (ISegment selectedSegment in this.Segments)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    html.AppendLine("<br>");
                }
                html.Append(HtmlClipboard.CreateHtmlFragment(textArea.Document, highlighter, selectedSegment, options));
            }
            return(html.ToString());
        }
        public HttpResponseMessage Get(string file, int page)
        {
            ViewerHtmlHandler handler             = Utils.CreateViewerHtmlHandler();
            List <int>        pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = (String.Format(
                                         "/page/resource?file=%s&page=%d&resource=",
                                         file,
                                         page
                                         ));

            List <PageHtml> list = Utils.LoadPageHtmlList(handler, file, o);

            string fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;
            var response = new HttpResponseMessage();

            response.Content = new StringContent(fullHtml);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }
        public static void Run()
        {
            //ExStart:ConvertingPresentationToHtmlWithEmbedAllFontsHtmlController
            string dataDir = RunExamples.GetDataDir_Conversion();

            using (Presentation pres = new Presentation(dataDir + "presentation.pptx"))
            {
                // exclude default presentation fonts
                string[] fontNameExcludeList = { "Calibri", "Arial" };


                Paragraph para = new Paragraph();

                EmbedAllFontsHtmlController embedFontsController = new EmbedAllFontsHtmlController(fontNameExcludeList);

                LinkAllFontsHtmlController linkcont = new LinkAllFontsHtmlController(fontNameExcludeList, @"C:\Windows\Fonts\");

                HtmlOptions htmlOptionsEmbed = new HtmlOptions
                {
                    //                    HtmlFormatter = HtmlFormatter.CreateCustomFormatter(embedFontsController)
                    HtmlFormatter = HtmlFormatter.CreateCustomFormatter(linkcont)
                };

                pres.Save("pres.html", SaveFormat.Html, htmlOptionsEmbed);
                //ExEnd:ConvertingPresentationToHtmlWithEmbedAllFontsHtmlController
            }
        }
Example #6
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Loading a presentation
            using (Presentation pres = new Presentation(dataDir + "Media File.pptx"))
            {
                string       path     = dataDir;
                const string fileName = "ExportMediaFiles_out.html";
                const string baseUri  = "http://www.example.com/";

                VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path, fileName, baseUri);

                // Setting HTML options
                HtmlOptions htmlOptions = new HtmlOptions(controller);
                SVGOptions  svgOptions  = new SVGOptions(controller);

                htmlOptions.HtmlFormatter    = HtmlFormatter.CreateCustomFormatter(controller);
                htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions);

                // Saving the file
                pres.Save(Path.Combine(path, fileName), SaveFormat.Html, htmlOptions);
            }
        }
Example #7
0
        public static object GetDocumentPageHtml(GetDocumentPageHtmlParameters parameters)
        {
            if (Utils.IsValidUrl(parameters.Path))
            {
                parameters.Path = Utils.GetFilenameFromUrl(parameters.Path);
            }

            if (String.IsNullOrWhiteSpace(parameters.Path))
            {
                throw new ArgumentException("A document path must be specified", "path");
            }

            List <string> cssList;
            int           pageNumber = parameters.PageIndex + 1;

            var htmlOptions = new HtmlOptions
            {
                PageNumber          = parameters.PageIndex + 1,
                CountPagesToRender  = 1,
                IsResourcesEmbedded = false,
                HtmlResourcePrefix  = string.Format(
                    "/GetResourceForHtml.aspx?documentPath={0}", parameters.Path) +
                                      "&pageNumber={page-number}&resourceName=",
            };

            var htmlPages = GetHtmlPages(parameters.Path, parameters.Path, htmlOptions, out cssList);

            var pageHtml = htmlPages.Count > 0 ? htmlPages[0].HtmlContent : null;
            var pageCss  = cssList.Count > 0 ? new[] { string.Join(" ", cssList) } : null;

            var result = new { pageHtml, pageCss };

            return(result);
        }
        public JsonResult <List <string> > Get(string file, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity)
        {
            if (Utils.IsValidUrl(file))
            {
                file = Utils.DownloadToStorage(file);
            }
            ViewerHtmlHandler handler = Utils.CreateViewerHtmlHandler();

            List <int> pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions options = new HtmlOptions();

            //options.PageNumbersToRender = pageNumberstoRender;
            //options.PageNumber = page;
            //options.CountPagesToRender = 1;
            //options.HtmlResourcePrefix = "/pageresource?file=" + file + "&page=" + page + "&resource=";
            options.EmbedResources = true;
            if (watermarkText != "")
            {
                options.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }

            List <PageHtml> list        = Utils.LoadPageHtmlList(handler, file, options);
            List <string>   lstPageHtml = new List <string>();

            foreach (PageHtml pageHtml in list)
            {
                lstPageHtml.Add(pageHtml.HtmlContent);
            }
            ;

            return(Json(lstPageHtml));
        }
        public ActionResult Get(string file, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity)
        {
            if (Utils.IsValidUrl(file))
            {
                file = Utils.DownloadToStorage(file);
            }
            ViewerHtmlHandler handler = Utils.CreateViewerHtmlHandler();

            List <int> pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions options = new HtmlOptions();

            options.PageNumbersToRender = pageNumberstoRender;
            options.PageNumber          = page;
            options.CountPagesToRender  = 1;
            options.HtmlResourcePrefix  = "/page/resource?file=" + file + "&page=" + page + "&resource=";
            if (watermarkText != "")
            {
                options.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }

            List <PageHtml> list     = Utils.LoadPageHtmlList(handler, file, options);
            string          fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;
            return(Content(fullHtml));
        }
        /// <summary>
        /// Get document html representation with embedded resources
        /// </summary>
        public static void Get_Html_EmbeddedResources()
        {
            Console.WriteLine("***** {0} *****", "Get document html representation with embedded resources");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            HtmlOptions options = new HtmlOptions();
            options.IsResourcesEmbedded = true;

            List<PageHtml> pages = htmlHandler.GetPages(guid, options);

            foreach (PageHtml page in pages)
            {
                Console.WriteLine("Page number: {0}", page.PageNumber);
                Console.WriteLine("Html content: {0}", page.HtmlContent);
            }
        }
Example #11
0
        public ActionResult Get(string file, int page)
        {
            if (Utils.IsValidUrl(file))
            {
                file = Utils.DownloadToStorage(file);
            }
            ViewerHtmlHandler handler = Utils.CreateViewerHtmlHandler();

            List <int> pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = (String.Format(
                                         "/page/resource?file=%s&page=%d&resource=",
                                         file,
                                         page
                                         ));

            List <PageHtml> list     = Utils.LoadPageHtmlList(handler, file, o);
            string          fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;
            return(Content(fullHtml));
        }
Example #12
0
        public ActionResult GetDocumentPageHtml(GetDocumentPageHtmlParameters parameters)
        {
            if (Utils.IsValidUrl(parameters.Path))
            {
                parameters.Path = Utils.GetFilenameFromUrl(parameters.Path);
            }
            if (string.IsNullOrWhiteSpace(parameters.Path))
            {
                throw new ArgumentException("A document path must be specified", "path");
            }

            string guid       = parameters.Path;
            int    pageNumber = parameters.PageIndex + 1;

            HtmlOptions htmlOptions = new HtmlOptions
            {
                PageNumber          = pageNumber,
                CountPagesToRender  = 1,
                IsResourcesEmbedded = false,
                HtmlResourcePrefix  = GetHtmlResourcePrefix(guid),
                CellsOptions        = { OnePagePerSheet = false }
            };

            HtmlPageContent pageContent = GetHtmlPageContents(guid, htmlOptions).Single();

            var result = new GetDocumentPageHtmlResult
            {
                pageHtml = pageContent.Html,
                pageCss  = pageContent.Css
            };

            return(ToJsonResult(result));
        }
        public override string ToHTML(string path)
        {
            //获取不带扩展的文件名
            string name         = Path.GetFileNameWithoutExtension(path);
            string destFilePath = Path.Combine(Path.GetDirectoryName(path), name);
            string htmlFileName = $"{name}.html";
            var    buffer       = File.ReadAllBytes(path);

            using (MemoryStream ms = new MemoryStream())
            {
                ms.Write(buffer, 0, buffer.Length);
                if (ms.Length <= 0)
                {
                    return("false");
                }

                using (Presentation pres = new Presentation(path))
                {
                    HtmlOptions htmlOpt = new HtmlOptions();
                    htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter(Css, false);
                    if (!Directory.Exists(destFilePath))
                    {
                        Directory.CreateDirectory(destFilePath);
                    }
                    //hmtl文件保存地址
                    string htmlFilePath = Path.Combine(destFilePath, htmlFileName);
                    pres.Save(htmlFilePath, SaveFormat.Html, htmlOpt);
                    string htmlString = File.ReadAllText(htmlFilePath);
                    //XElement xhtml = XElement.Load(htmlFilePath);

                    return(JsonConvert.SerializeObject(new { htmlString = htmlString, Size = pres.SlideSize }));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var file = GetValueFromQueryString("file");
            var page = Convert.ToInt32(GetValueFromQueryString("page"));

            ViewerHtmlHandler handler             = Utils.CreateViewerHtmlHandler();
            List <int>        pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = (String.Format(
                                         "/page/resource?file=%s&page=%d&resource=",
                                         file,
                                         page
                                         ));

            List <PageHtml> list = Utils.LoadPageHtmlList(handler, file, o);

            string fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;

            HttpContext.Current.Response.ContentType = "text/html";
            HttpContext.Current.Response.Write(fullHtml);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
        public HttpResponseMessage Get(string file, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity)
        {
            if (Utils.IsValidUrl(file))
            {
                file = Utils.DownloadToStorage(file);
            }
            ViewerHtmlHandler handler             = Utils.CreateViewerHtmlHandler();
            List <int>        pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = "/PageResource?file=" + file + "&page=" + page + "&resource=";
            if (watermarkText != "")
            {
                o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }
            List <PageHtml> list     = Utils.LoadPageHtmlList(handler, file, o);
            string          fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;
            var response = new HttpResponseMessage();

            response.Content = new StringContent(fullHtml);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }
        /// <summary>
        /// Render a document in html representation whom located at web/remote location.
        /// </summary>
        /// <param name="DocumentURL">URL of the document</param>
        /// <param name="DocumentPassword">Password Parameter is optional</param>
        public static void RenderDocumentAsHtml(Uri DocumentURL, String DocumentPassword = null)
        {
            //ExStart:RenderRemoteDocAsHtml
            //Get Configurations
            ViewerConfig config = Utilities.GetConfigurations();

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

            //Instantiate the HtmlOptions object
            HtmlOptions options = new HtmlOptions();

            if (!String.IsNullOrEmpty(DocumentPassword))
            {
                options.Password = DocumentPassword;
            }

            //Get document pages in html form
            List <PageHtml> pages = htmlHandler.GetPages(DocumentURL, options);

            foreach (PageHtml page in pages)
            {
                //Save each page at disk
                Utilities.SaveAsHtml(page.PageNumber + "_" + Path.GetFileName(DocumentURL.LocalPath), page.HtmlContent);
            }
            //ExEnd:RenderRemoteDocAsHtml
        }
        /// <summary>
        /// Render document in html representation with watermark
        /// </summary>
        /// <param name="DocumentName">file/document name</param>
        /// <param name="WatermarkText">watermark text</param>
        /// <param name="WatermarkColor"> System.Drawing.Color</param>
        /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param>
        /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param>
        /// <param name="DocumentPassword">Password Parameter is optional</param>
        public static void RenderDocumentAsHtml(String DocumentName, String WatermarkText, Color WatermarkColor, WatermarkPosition position = WatermarkPosition.Diagonal, int WatermarkWidth = 100, String DocumentPassword = null)
        {
            //ExStart:RenderAsHtmlWithWaterMark
            //Get Configurations
            ViewerConfig config = Utilities.GetConfigurations();

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

            // Guid implies that unique document name
            string guid = DocumentName;

            //Instantiate the HtmlOptions object
            HtmlOptions options = new HtmlOptions();

            options.IsResourcesEmbedded = false;
            // Set password if document is password protected.
            if (!String.IsNullOrEmpty(DocumentPassword))
            {
                options.Password = DocumentPassword;
            }

            // Call AddWatermark and pass the reference of HtmlOptions object as 1st parameter
            Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, position, WatermarkWidth);

            //Get document pages in html form
            List <PageHtml> pages = htmlHandler.GetPages(guid, options);

            foreach (PageHtml page in pages)
            {
                //Save each page at disk
                Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent);
            }
            //ExEnd:RenderAsHtmlWithWaterMark
        }
        /// <summary>
        /// Render simple document in html representation
        /// </summary>
        /// <param name="DocumentName">File name</param>
        /// <param name="DocumentPassword">Optional</param>
        public static void RenderDocumentAsHtml(String DocumentName, String DocumentPassword = null)
        {
            //ExStart:RenderAsHtml
            //Get Configurations
            ViewerConfig config = Utilities.GetConfigurations();

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

            // Guid implies that unique document name
            string guid = DocumentName;

            //Instantiate the HtmlOptions object
            HtmlOptions options = new HtmlOptions();

            //to get html representations of pages with embedded resources
            options.IsResourcesEmbedded = true;

            // Set password if document is password protected.
            if (!String.IsNullOrEmpty(DocumentPassword))
            {
                options.Password = DocumentPassword;
            }
            //  options.PageNumbersToConvert = Enumerable.Range(1, 3).ToList();
            //Get document pages in html form
            List <PageHtml> pages = htmlHandler.GetPages(guid, options);

            foreach (PageHtml page in pages)
            {
                //Save each page at disk
                Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent);
            }
            //ExEnd:RenderAsHtml
        }
        /// <summary>
        /// Add Watermark to Html page representation
        /// </summary>
        public static void Add_Watermark_For_Html()
        {
            Console.WriteLine("***** {0} *****", "Add Watermark to Html page representation");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            HtmlOptions options = new HtmlOptions();

            // Set watermark properties
            Watermark watermark = new Watermark("This is watermark text");
            watermark.Color = System.Drawing.Color.Blue;
            watermark.Position = WatermarkPosition.Diagonal;
            watermark.Width = 100;

            options.Watermark = watermark;

            // Get document pages html representation with watermark
            List<PageHtml> pages = htmlHandler.GetPages(guid, options);
        }
        public static void InHtmlRepresentation()
        {
            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "document.xlsx";

            // Set html options to show grid lines
            HtmlOptions options = new HtmlOptions();
            options.CellsOptions.ShowHiddenSheets = true;

            DocumentInfoContainer container = htmlHandler.GetDocumentInfo(new DocumentInfoOptions(guid));

            foreach (PageData page in container.Pages)
                Console.WriteLine("Page number: {0}, Page Name: {1}, IsVisible: {2}", page.Number, page.Name, page.IsVisible);

            List<PageHtml> pages = htmlHandler.GetPages(guid, options);

            foreach (PageHtml page in pages)
            {
                Console.WriteLine("Page number: {0}", page.PageNumber);
                //Console.WriteLine("Html content: {0}", page.HtmlContent);
            }
        }
Example #21
0
        public string GetHtml(string camId, IPCameraBase cam)
        {
            PTZProfile profile = GetProfile();

            if (profile == null)
            {
                return("PTZ Profile Not Found");
            }
            if (typeof(PTZSpecV1) == profile.spec.GetType())
            {
                PTZSpecV1 spec = (PTZSpecV1)profile.spec;

                HtmlOptions options = new HtmlOptions();
                options.showPtzArrows    = true;
                options.showPtzDiagonals = spec.EnableDiagonals;

                options.panDelay  = (int)(spec.PanRunTimeMs * 0.9);
                options.tiltDelay = (int)(spec.TiltRunTimeMs * 0.9);

                options.showZoomButtons = spec.EnableZoom;

                options.showZoomInLong   = !string.IsNullOrWhiteSpace(spec.zoomInLong);
                options.showZoomInMedium = !string.IsNullOrWhiteSpace(spec.zoomInMedium);
                options.showZoomInShort  = !string.IsNullOrWhiteSpace(spec.zoomInShort);

                options.showZoomOutLong   = !string.IsNullOrWhiteSpace(spec.zoomOutLong);
                options.showZoomOutMedium = !string.IsNullOrWhiteSpace(spec.zoomOutMedium);
                options.showZoomOutShort  = !string.IsNullOrWhiteSpace(spec.zoomOutShort);

                options.zoomShortDelay  = spec.ZoomRunTimeShortMs;
                options.zoomMediumDelay = spec.ZoomRunTimeMediumMs;
                options.zoomLongDelay   = spec.ZoomRunTimeLongMs;

                options.showPresets = spec.EnablePresets;
                int i = 0;
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_1);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_2);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_3);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_4);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_5);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_6);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_7);
                options.gettablePresets[i++] = !string.IsNullOrWhiteSpace(spec.load_preset_8);
                i = 0;
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_1);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_2);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_3);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_4);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_5);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_6);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_7);
                options.settablePresets[i++] = !string.IsNullOrWhiteSpace(spec.save_preset_8);

                options.showZoomLevels = false;

                return(PTZHtml.GetHtml(camId, cam, options));
            }
            return("Unsupported PTZ Profile");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlCreatePagesCacheRequest"/> class.
 /// </summary>
 /// <param name="fileName">The file name.</param>
 /// <param name="htmlOptions">The HTML rendering options.</param>
 /// <param name="fontsFolder">The folder with custom fonts in storage.</param>
 /// <param name="folder">The folder which contains specified file in storage.</param>
 /// <param name="storage">The file storage which have to be used.</param>
 public HtmlCreatePagesCacheRequest(string fileName, HtmlOptions htmlOptions = null, string fontsFolder = null, string folder = null, string storage = null)
 {
     this.FileName    = fileName;
     this.HtmlOptions = htmlOptions;
     this.FontsFolder = fontsFolder;
     this.Folder      = folder;
     this.Storage     = storage;
 }
            /// <summary>
            /// add a watermark text to all rendered Html pages.
            /// </summary>
            /// <param name="options">HtmlOptions by reference</param>
            /// <param name="text">Watermark text</param>
            /// <param name="color">System.Drawing.Color</param>
            /// <param name="position"></param>
            /// <param name="width"></param>
            public static void AddWatermark(ref HtmlOptions options, String text, Color color, WatermarkPosition position, int width)
            {
                Watermark watermark = new Watermark(text);

                watermark.Color    = color;
                watermark.Position = position;
                watermark.Width    = width;
                options.Watermark  = watermark;
            }
            /// <summary>
            /// add a watermark text to all rendered Html pages.
            /// </summary>
            /// <param name="options">HtmlOptions by reference</param>
            /// <param name="text">Watermark text</param>
            /// <param name="color">System.Drawing.Color</param>
            /// <param name="position"></param>
            /// <param name="width"></param>
            public static void AddWatermark(ref HtmlOptions options, String text, Color color, WatermarkPosition position, int width)
            {
                Watermark watermark = new Watermark(text);

                watermark.Color    = color;
                watermark.Position = position;
                watermark.Width    = width;
                watermark.FontName = "\"Comic Sans MS\", cursive, sans-serif";
                options.Watermark  = watermark;
            }
Example #25
0
        /// <summary>
        /// Produces HTML code for a section of the line, with &lt;span style="..."&gt; tags.
        /// </summary>
        public string ToHtml(int offset, int length, HtmlOptions options = null)
        {
            StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture);

            using (var htmlWriter = new HtmlRichTextWriter(stringWriter, options))
            {
                htmlWriter.Write(this, offset, length);
            }
            return(stringWriter.ToString());
        }
        public void Page_Load(object sender, EventArgs e)
        {
            var file       = GetValueFromQueryString("file");
            var page       = Convert.ToInt32(GetValueFromQueryString("page"));
            var attachment = GetValueFromQueryString("attachment");

            string            watermarkText     = GetValueFromQueryString("watermarkText");
            int?              watermarkColor    = Convert.ToInt32(GetValueFromQueryString("watermarkColor"));
            WatermarkPosition watermarkPosition = (WatermarkPosition)Enum.Parse(typeof(WatermarkPosition), GetValueFromQueryString("watermarkPosition"), true);
            string            widthFromQuery    = GetValueFromQueryString("watermarkWidth");
            int?              watermarkWidth    = GetValueFromQueryString("watermarkWidth") == "null" ? null : (int?)Convert.ToInt32(GetValueFromQueryString("watermarkWidth"));
            byte              watermarkOpacity  = Convert.ToByte(GetValueFromQueryString("watermarkOpacity"));


            ViewerHtmlHandler handler             = Utils.CreateViewerHtmlHandler();
            List <int>        pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = (String.Format(
                                         "/page/resource?file=%s&page=%d&resource=",
                                         file,
                                         page
                                         ));
            if (watermarkText != "")
            {
                o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }
            var docInfo = handler.GetDocumentInfo(file);

            List <PageHtml> list = Utils.LoadPageHtmlList(handler, file, o);

            string fullHtml = "";

            foreach (AttachmentBase attachmentBase in docInfo.Attachments.Where(x => x.Name == attachment))
            {
                // Get attachment document html representation
                List <PageHtml> pages = handler.GetPages(attachmentBase, o);
                foreach (PageHtml pageHtml in pages.Where(x => x.PageNumber == page))
                {
                    fullHtml += pageHtml.HtmlContent;
                }
                ;
            }

            HttpContext.Current.Response.ContentType = "text/html";
            HttpContext.Current.Response.Write(fullHtml);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
        static void Main(string[] args)
        {
            string MyDir = @"Files\";
            //Instantiate a Presentation object that represents a presentation file
            Presentation pres = new Presentation(MyDir + "Conversion.ppt");

            HtmlOptions htmlOpt = new HtmlOptions();
            htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

            //Saving the presentation to HTML
            pres.Save(MyDir + "Converted.html", Aspose.Slides.Export.SaveFormat.Html, htmlOpt);
        }
Example #28
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) };
        }
Example #29
0
        public static void Run()
        {
            //ExStart:ExportToHTMLWithResponsiveLayout
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            Presentation presentation = new Presentation(dataDir + "SomePresentation.pptx");
            HtmlOptions  saveOptions  = new HtmlOptions();

            saveOptions.SvgResponsiveLayout = true;
            presentation.Save(dataDir + "SomePresentation-out.html", SaveFormat.Html, saveOptions);
            //ExEnd:ExportToHTMLWithResponsiveLayout
        }
Example #30
0
        static void Main(string[] args)
        {
            string MyDir = @"Files\";
            //Instantiate a Presentation object that represents a presentation file
            PresentationEx pres = new PresentationEx(MyDir + "Conversion.ppt");

            HtmlOptions htmlOpt = new HtmlOptions();

            htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

            //Saving the presentation to HTML
            pres.Save(MyDir + "Converted.html", Aspose.Slides.Export.SaveFormat.Html, htmlOpt);
        }
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Conversion();

            using (Presentation presentation = new Presentation(dataDir + "Individual-Slide.pptx"))
            {
                HtmlOptions htmlOptions = new HtmlOptions();
                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(new CustomFormattingController());

                // Saving File              
                for (int i = 0; i < presentation.Slides.Count; i++)
                    presentation.Save(dataDir + "Individual Slide" + (i + 1) + "_out.html", new[] { i + 1 }, SaveFormat.Html, htmlOptions);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var file = GetValueFromQueryString("file");
            var page = Convert.ToInt32(GetValueFromQueryString("page"));

            string            watermarkText     = GetValueFromQueryString("watermarkText");
            int?              watermarkColor    = Convert.ToInt32(GetValueFromQueryString("watermarkColor"));
            WatermarkPosition watermarkPosition = (WatermarkPosition)Enum.Parse(typeof(WatermarkPosition), GetValueFromQueryString("watermarkPosition"), true);
            string            widthFromQuery    = GetValueFromQueryString("watermarkWidth");
            int?              watermarkWidth    = GetValueFromQueryString("watermarkWidth") == "null" ? null : (int?)Convert.ToInt32(GetValueFromQueryString("watermarkWidth"));
            byte              watermarkOpacity  = Convert.ToByte(GetValueFromQueryString("watermarkOpacity"));

            if (Utils.IsValidUrl(file))
            {
                file = Utils.DownloadToStorage(file);
            }
            ViewerHtmlHandler handler             = Utils.CreateViewerHtmlHandler();
            List <int>        pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = (String.Format(
                                         "/page/resource?file=%s&page=%d&resource=",
                                         file,
                                         page
                                         ));
            if (watermarkText != "")
            {
                o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }

            List <PageHtml> list = Utils.LoadPageHtmlList(handler, file, o);

            string fullHtml = "";

            foreach (PageHtml pageHtml in list.Where(x => x.PageNumber == page))
            {
                fullHtml = pageHtml.HtmlContent;
            }
            ;

            HttpContext.Current.Response.ContentType = "text/html";
            HttpContext.Current.Response.Write(fullHtml);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
Example #33
0
        public HttpResponseMessage Get(string file, string attachment, int page, string watermarkText, int?watermarkColor, WatermarkPosition?watermarkPosition, int?watermarkWidth, byte watermarkOpacity)
        {
            var attachmentPath             = "cache\\" + Path.GetFileNameWithoutExtension(file) + Path.GetExtension(file).Replace(".", "_") + "\\attachments\\" + attachment;
            ViewerHtmlHandler handler      = Utils.CreateViewerHtmlHandler();
            var        docInfo             = handler.GetDocumentInfo(file);
            List <int> pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o = new HtmlOptions();

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            o.HtmlResourcePrefix  = "/AttachmentResource?file=" + file + "&attachment=" + attachment + "&page=" + page + "&resource=";
            if (watermarkText != "")
            {
                o.Watermark = Utils.GetWatermark(watermarkText, watermarkColor, watermarkPosition, watermarkWidth, watermarkOpacity);
            }
            string fullHtml       = "";
            var    attachmentFile = _cachePath + "\\" + Path.GetFileNameWithoutExtension(file) + Path.GetExtension(file).Replace(".", "_") + "\\attachments";

            if (Directory.Exists(attachmentFile.Replace(@"\\", @"\")))
            {
                List <PageHtml> pages = handler.GetPages(attachmentPath, o);
                foreach (PageHtml pageHtml in pages.Where(x => x.PageNumber == page))
                {
                    fullHtml += pageHtml.HtmlContent;
                }
                ;
            }
            else
            {
                foreach (AttachmentBase attachmentBase in docInfo.Attachments.Where(x => x.Name == attachment))
                {
                    // Get attachment document html representation
                    List <PageHtml> pages = handler.GetPages(attachmentBase, o);
                    foreach (PageHtml pageHtml in pages.Where(x => x.PageNumber == page))
                    {
                        fullHtml += pageHtml.HtmlContent;
                    }
                    ;
                }
            }
            var response = new HttpResponseMessage();

            response.Content = new StringContent(fullHtml);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Instantiate a Presentation object that represents a presentation file
            using (Presentation presentation = new Presentation(dataDir + "Convert_HTML.pptx"))
            {
                HtmlOptions htmlOpt = new HtmlOptions();
                htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

                // Saving the presentation to HTML
                presentation.Save(dataDir + "ConvertWholePresentationToHTML_out.html", SaveFormat.Html, htmlOpt);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Instantiate a Presentation object that represents a presentation file
            using (Presentation presentation = new Presentation(dataDir + "Convert_HTML.pptx"))
            {
                ResponsiveHtmlController controller = new ResponsiveHtmlController();
                HtmlOptions htmlOptions = new HtmlOptions { HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller) };

                // Saving the presentation to HTML
                presentation.Save(dataDir + "ConvertPresentationToResponsiveHTML_out.html", SaveFormat.Html, htmlOptions);
            }
        }
        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string srcFileName = FilePath + "Conversion.pptx";
            string destFileName = FilePath + "Converting to HTML.html";
            
            //Instantiate a Presentation object that represents a presentation file
            Presentation pres = new Presentation(srcFileName);

            HtmlOptions htmlOpt = new HtmlOptions();
            htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

            //Saving the presentation to HTML
            pres.Save(destFileName, Aspose.Slides.Export.SaveFormat.Html, htmlOpt);
        }
Example #37
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Instantiate a Presentation object that represents a presentation file
            using (Presentation presentation = new Presentation(dataDir + "Convert_HTML.pptx"))
            {
                HtmlOptions htmlOpt = new HtmlOptions();
                htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

                // Saving the presentation to HTML
                presentation.Save(dataDir + "ConvertWholePresentationToHTML_out.html", SaveFormat.Html, htmlOpt);
            }
        }
Example #38
0
        public HttpResponseMessage Get(string file, string attachment, int page, string resource)
        {
            var attachmentPath                        = "cache\\" + Path.GetFileNameWithoutExtension(file) + Path.GetExtension(file).Replace(".", "_") + "\\attachments\\" + attachment;
            ViewerHtmlHandler     handler             = Utils.CreateViewerHtmlHandler();
            DocumentInfoContainer info                = handler.GetDocumentInfo(file);
            List <int>            pageNumberstoRender = new List <int>();

            pageNumberstoRender.Add(page);
            HtmlOptions o          = new HtmlOptions();
            int         pageNumber = page;

            o.PageNumbersToRender = pageNumberstoRender;
            o.PageNumber          = page;
            o.CountPagesToRender  = 1;
            List <PageHtml>     pages         = handler.GetPages(attachmentPath, o);
            List <HtmlResource> htmlResources = pages.Where(x => x.PageNumber == page).Select(x => x.HtmlResources).FirstOrDefault();
            var    fileResource = htmlResources.Where(x => x.ResourceName == resource).FirstOrDefault();
            string type         = "";

            if (fileResource != null)
            {
                switch (fileResource.ResourceType)
                {
                case HtmlResourceType.Font:
                    type = "application/font-woff";
                    break;

                case HtmlResourceType.Style:

                    type = "text/css";
                    break;

                case HtmlResourceType.Image:
                    type = "image/jpeg";
                    break;

                case HtmlResourceType.Graphics:
                    type = "image/svg+xml";
                    break;
                }
                Stream stream = handler.GetResource(attachmentPath, fileResource);
                var    result = new HttpResponseMessage(HttpStatusCode.OK);
                result.Content = new StreamContent(stream);
                result.Content.Headers.ContentType = new MediaTypeHeaderValue(type);
                return(result);
            }
            return(null);
        }
        static void Main(string[] args)
        {
            string FilePath     = @"..\..\..\Sample Files\";
            string srcFileName  = FilePath + "Conversion.pptx";
            string destFileName = FilePath + "Converting to HTML.html";

            //Instantiate a Presentation object that represents a presentation file
            Presentation pres = new Presentation(srcFileName);

            HtmlOptions htmlOpt = new HtmlOptions();

            htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false);

            //Saving the presentation to HTML
            pres.Save(destFileName, Aspose.Slides.Export.SaveFormat.Html, htmlOpt);
        }
Example #40
0
        //ExStart:ConvertIndividualSlide
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Conversion();

            using (Presentation presentation = new Presentation(dataDir + "Individual-Slide.pptx"))
            {
                HtmlOptions htmlOptions = new HtmlOptions();
                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(new CustomFormattingController());

                // Saving File
                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    presentation.Save(dataDir + "Individual Slide" + (i + 1) + "_out.html", new[] { i + 1 }, SaveFormat.Html, htmlOptions);
                }
            }
        }
        public static void InHtmlRepresentation()
        {
            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "document.xlsx";

            // Set html options to show grid lines
            HtmlOptions options = new HtmlOptions();
            options.CellsOptions.ShowGridLines = true;
            List<PageHtml> pages = htmlHandler.GetPages(guid, options);

            foreach (PageHtml page in pages)
            {
                Console.WriteLine("Page number: {0}", page.PageNumber);
                Console.WriteLine("Html content: {0}", page.HtmlContent);
            }
        }
        /// <summary>
        /// Perform multiple transformations in Html mode
        /// </summary>
        public static void Multiple_Transformations_For_Html()
        {
            Console.WriteLine("***** {0} *****", "Perform multiple transformations in Html mode");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            // Rotate first page 90 degrees
            htmlHandler.RotatePage(new RotatePageOptions(guid, 1, 90));

            // Rotate second page 180 degrees
            htmlHandler.RotatePage(new RotatePageOptions(guid, 2, 180));

            // Reorder first and second pages
            htmlHandler.ReorderPage(new ReorderPageOptions(guid, 1, 2));

            // Set options to include rotate and reorder transformations
            HtmlOptions options = new HtmlOptions { Transformations = Transformation.Rotate | Transformation.Reorder };

            // Set watermark properties
            Watermark watermark = new Watermark("This is watermark text")
            {
                Color = System.Drawing.Color.Blue,
                Position = WatermarkPosition.Diagonal,
                Width = 100
            };

            options.Watermark = watermark;

            // Get document pages html representation with multiple transformations
            List<PageHtml> pages = htmlHandler.GetPages(guid, options);
        }
        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string srcFileName = FilePath + "Conversion.pptx";
            string destFileName =  "video.html";
            
            //Loading a presentation
            using (Presentation pres = new Presentation(srcFileName))
            {
                const string baseUri = "http://www.example.com/";

                VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path: FilePath, fileName: destFileName, baseUri: baseUri);

                //Setting HTML options
                HtmlOptions htmlOptions = new HtmlOptions(controller);
                SVGOptions svgOptions = new SVGOptions(controller);

                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller);
                htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions);

                //Saving the file
                pres.Save(destFileName, SaveFormat.Html, htmlOptions);
            }
        }
        private List<HtmlPageContent> GetHtmlPageContents(string guid, HtmlOptions htmlOptions)
        {
            var pageContents = new List<HtmlPageContent>();

            var documentInfo = _htmlHandler.GetDocumentInfo(guid);

            var htmlPages = _htmlHandler.GetPages(guid, htmlOptions);
            foreach (var page in htmlPages)
            {
                var html = page.HtmlContent;

                var indexOfBodyOpenTag = html.IndexOf("<body>", StringComparison.InvariantCultureIgnoreCase);
                if (indexOfBodyOpenTag > 0)
                    html = html.Substring(indexOfBodyOpenTag + "<body>".Length);

                var indexOfBodyCloseTag = html.IndexOf("</body>", StringComparison.InvariantCultureIgnoreCase);
                if (indexOfBodyCloseTag > 0)
                    html = html.Substring(0, indexOfBodyCloseTag);

                string css = string.Empty;
                foreach (var resource in page.HtmlResources.Where(_ => _.ResourceType == HtmlResourceType.Style))
                {
                    var resourceStream = _htmlHandler.GetResource(guid, resource);
                    var resourceContent = new StreamReader(resourceStream).ReadToEnd();

                    if (!string.IsNullOrEmpty(css))
                        css += " ";

                    css += resourceContent;
                }

                // wrap single image tags
                var match = Regex.Match(html, "^<img.+?src=[\"'](.+?)[\"'].*?>$", RegexOptions.IgnoreCase);
                if (match.Success)
                {
                    var src = match.Groups[1].Value;
                    var pageData = documentInfo.Pages.Single(_ => _.Number == page.PageNumber);

                    css = ".grpdx .ie .doc-page {font-size:0;}";
                    if (documentInfo.DocumentType == DocumentTypeName.DIAGRAM)
                    {
                        html = string.Format("<div style='width:{0}px;height:{1}px;font-size:0'>" +
                         "<img style='width:{0}px;height:{1}px;font-size:0' src='{2}'/>" +
                         "</div>",
                         600,
                         800,
                         src);
                    }
                    else
                    {
                        html = string.Format("<div style='width:{0}px;height:{1}px;font-size:0'>" +
                        "<img style='width:{0}px;height:{1}px;font-size:0' src='{2}'/>" +
                        "</div>",
                        pageData.Width,
                        pageData.Height,
                        src);
                    }
                }

                //wrap svg tags
                if (html.StartsWith("<svg"))
                    html = "<div>" + html + "</div>";

                pageContents.Add(new HtmlPageContent(html, css));
            }

            return pageContents;
        }
        /// <summary>
        /// Rotate page in Html mode
        /// </summary>
        public static void Rotate_Page_In_Html_Mode()
        {
            Console.WriteLine("***** {0} *****", "Rotate page in Html mode");

            /* ********************* SAMPLE ********************* */

            string licensePath = @"D:\GroupDocs.Viewer.lic";

            // Setup license
            GroupDocs.Viewer.License lic = new GroupDocs.Viewer.License();
            lic.SetLicense(licensePath);

            /* ********************  SAMPLE BEGIN ************************ */
            /* ********************  Rotate 1st page of the document by 90 deg *********************** */
            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";

            // Set rotation angle 90 for page number 1
            RotatePageOptions rotateOptions = new RotatePageOptions(guid, 1, 90);

            // Perform page rotation
            htmlHandler.RotatePage(rotateOptions);


            /* ********************  Retrieve all document pages including transformation *********************** */
            // Set html options to include rotate transformations
            HtmlOptions htmlOptions = new HtmlOptions
            {
                Transformations = Transformation.Rotate
            };

            // Get html representation of all document pages, including rotate transformations 
            List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions);


            /* ********************  Retrieve all document pages excluding transformation *********************** */
            // Set html options NOT to include ANY transformations
            HtmlOptions noTransformationsOptions = new HtmlOptions
            {
                Transformations = Transformation.None // This is by default
            };

            // Get html representation of all document pages, without transformations 
            List<PageHtml> pagesWithoutTransformations = htmlHandler.GetPages(guid, noTransformationsOptions);

            // Get html representation of all document pages, without transformations
            List<PageHtml> pagesWithoutTransformations2 = htmlHandler.GetPages(guid);

            /*********************  SAMPLE END *************************/
            //foreach (PageHtml page in pages)
            //{
            //    // Page number
            //    Console.WriteLine("Page number: {0}", page.PageNumber);
            //}
        }
        public static void Reorder_Pages_In_Html_Mode()
        {
            Console.WriteLine("***** {0} *****", "Reorder pages in Html mode");

            /* ********************* SAMPLE ********************* */
            /* ********************   Reorder 1st and 2nd pages  *********************** */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // Create html handler
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
            string guid = "word.doc";
            int pageNumber = 1;
            int newPosition = 2;

            // Perform page reorder
            ReorderPageOptions options = new ReorderPageOptions(guid, pageNumber, newPosition);
            htmlHandler.ReorderPage(options);


            /* ********************  Retrieve all document pages including transformation *********************** */

            // Set html options to include reorder transformations
            HtmlOptions htmlOptions = new HtmlOptions
            {
                Transformations = Transformation.Reorder
            };

            // Get html representation of all document pages, including reorder transformations 
            List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions);


            /* ********************  Retrieve all document pages excluding transformation *********************** */

            // Set html options NOT to include ANY transformations
            HtmlOptions noTransformationsOptions = new HtmlOptions
            {
                Transformations = Transformation.None // This is by default
            };

            // Get html representation of all document pages, without transformations 
            List<PageHtml> pagesWithoutTransformations = htmlHandler.GetPages(guid, noTransformationsOptions);

            // Get html representation of all document pages, without transformations
            List<PageHtml> pagesWithoutTransformations2 = htmlHandler.GetPages(guid);
        }
        public ActionResult GetDocumentPageHtml(GetDocumentPageHtmlParameters parameters)
        {
            if (Utils.IsValidUrl(parameters.Path))
                parameters.Path = Utils.GetFilenameFromUrl(parameters.Path);
            if (string.IsNullOrWhiteSpace(parameters.Path))
                throw new ArgumentException("A document path must be specified", "path");

            string guid = parameters.Path;
            int pageNumber = parameters.PageIndex + 1;

            HtmlOptions htmlOptions = new HtmlOptions
            {
                PageNumber = pageNumber,
                CountPagesToConvert = 1,
                IsResourcesEmbedded = false,
                HtmlResourcePrefix = GetHtmlResourcePrefix(guid),
            };

            htmlOptions.CellsOptions.OnePagePerSheet = false;

            HtmlPageContent pageContent = GetHtmlPageContents(guid, htmlOptions).Single();

            var result = new GetDocumentPageHtmlResult
            {
                pageHtml = pageContent.Html,
                pageCss = pageContent.Css
            };
            return ToJsonResult(result);
        }
        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,
                CountPagesToConvert = 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);
        }