Example #1
0
        private void ConvertToImages(WordDocument wordDocument, string filename)
        {
            int i = 1;

            (this.sliderContent as Syncfusion.JavaScript.Web.Rotator).Items.Clear();

            List <string> urls     = new List <string>(4);
            string        name     = null;
            string        itemPath = "../Content/images/DocIO/";

            //Export the pages of the loaded document as bitmap images
            System.Drawing.Image[] images = wordDocument.RenderAsImages(Syncfusion.DocIO.DLS.ImageType.Metafile);

            foreach (System.Drawing.Image image in images)
            {
                //Resize the bitmap images.
                Bitmap   bitmap   = null;
                Metafile metafile = image as Metafile;
                //Set image width and height.
                bitmap = new Bitmap(793, 1122);
                bitmap.SetResolution((float)150, (float)150);
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.DrawImage(metafile, 0, 0, (float)793, (float)1122);
                    g.Dispose();
                }

                name = Path.GetFileNameWithoutExtension(filename);
                string dataPath = string.Format("{0}\\..\\..\\..\\Content\\images\\DocIO\\", Request.PhysicalPath.ToLower().Split(new string[] { "\\DocIO" }, StringSplitOptions.None)[0]);
                string fileName = Path.GetFullPath(dataPath) + name;
                Directory.CreateDirectory(fileName);
                urls.Add(itemPath + name + "/" + name + i + ".jpg");
                fileName = fileName + "\\" + name + i++ + ".jpg";

                //Saves the image
                bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                bitmap.Dispose();
            }
            //Add the images into the rotator.
            foreach (string url in urls)
            {
                Syncfusion.JavaScript.Web.RotatorItem rotatorItem = new Syncfusion.JavaScript.Web.RotatorItem();
                rotatorItem.Url     = url;
                rotatorItem.Caption = name + ".docx";
                (this.sliderContent as Syncfusion.JavaScript.Web.Rotator).Items.Add(rotatorItem);
            }
        }
Example #2
0
        private void ConvertToImages(IPresentation presentation, string filename)
        {
            int i = 1;

            (this.sliderContent as Syncfusion.JavaScript.Web.Rotator).Items.Clear();

            List <string> urls     = new List <string>(4);
            string        name     = null;
            string        itemPath = "../Content/images/presentation/";

            foreach (ISlide slide in presentation.Slides)
            {
                //Converts slide to image
                System.Drawing.Image image = System.Drawing.Image.FromStream(slide.ConvertToImage(Syncfusion.Drawing.ImageFormat.Emf));
                System.Drawing.Image.GetThumbnailImageAbort myCallback =
                    new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                System.Drawing.Image newImage = image.GetThumbnailImage(690, 400, myCallback, System.IntPtr.Zero);
                name = Path.GetFileNameWithoutExtension(filename);
                string dataPath = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..").FullName + "\\Content\\images\\presentation\\";

                string fileName = Path.GetFullPath(dataPath) + name;
                Directory.CreateDirectory(fileName);
                urls.Add(itemPath + name + "/" + name + i + ".jpg");
                fileName = fileName + "\\" + name + i++ + ".jpg";

                //Saves the image
                newImage.Save(fileName);
            }
            foreach (string url in urls)
            {
                Syncfusion.JavaScript.Web.RotatorItem rotatorItem = new Syncfusion.JavaScript.Web.RotatorItem();
                rotatorItem.Url     = url;
                rotatorItem.Caption = name + ".pptx";
                (this.sliderContent as Syncfusion.JavaScript.Web.Rotator).Items.Add(rotatorItem);
            }
        }