Beispiel #1
0
        public static void ExportShape(ShapeRange shapeRange, string exportPath)
        {
            int slideWidth  = (int)PowerPointPresentation.Current.SlideWidth;
            int slideHeight = (int)PowerPointPresentation.Current.SlideHeight;

            shapeRange.Export(exportPath, PpShapeFormat.ppShapeFormatPNG, slideWidth,
                              slideHeight, PpExportMode.ppScaleToFit);
        }
Beispiel #2
0
        public static void ExportShape(ShapeRange shapeRange, string exportPath)
        {
            var slideWidth = (int)PowerPointPresentation.Current.SlideWidth;
            var slideHeight = (int)PowerPointPresentation.Current.SlideHeight;

            shapeRange.Export(exportPath, PpShapeFormat.ppShapeFormatPNG, slideWidth,
                              slideHeight, PpExportMode.ppScaleToFit);
        }
        public FileInfo ExportSelectedShapes()
        {
            ShapeRange shapes   = _currentShape;
            int        hashCode = DateTime.Now.GetHashCode();
            string     pathName = TempPath.GetTempTestFolder() + "shapeName" + hashCode;

            shapes.Export(pathName, PpShapeFormat.ppShapeFormatPNG);
            return(new FileInfo(pathName));
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tfc"></param>
        /// <param name="shapes"></param>
        /// <param name="range"></param>
        /// <param name="deck"></param>
        /// <param name="slide"></param>
        /// <param name="disposition"></param>
        /// <param name="emfHeight"></param>
        /// <param name="startHeight">The starting height to place this sheet at</param>
        private static void ProcessLayer(List <TaggedShape> layer, TempFileCollection tfc, PowerPoint.Shapes shapes, Model.Presentation.DeckModel deck, Model.Presentation.SlideModel slide, float emfWidthRatio, float emfHeightRatio, int startHeight)
        {
            if (layer.Count < 1)
            {
                return;
            }

            //Create the image
            int[] range = PPTDeckIO.BuildIntRange(layer);
            PowerPoint.ShapeRange sr = shapes.Range(range);

            PowerPoint.PpShapeFormat format;
            string fileExt    = "";
            bool   bitmapMode = layer[0].isImage;

            if (bitmapMode)
            {
                format  = PowerPoint.PpShapeFormat.ppShapeFormatJPG;
                fileExt = "jpg";
            }
            else
            {
                format  = PowerPoint.PpShapeFormat.ppShapeFormatEMF;
                fileExt = "emf";
            }

            //Generate a new filename
            string dirpath  = tfc.BasePath;
            string filename = PPTDeckIO.GenerateFilename();

            filename = dirpath + "\\" + filename + "." + fileExt;
            while (File.Exists(filename))
            {
                filename = PPTDeckIO.GenerateFilename();
                filename = dirpath + "\\" + filename + "." + fileExt;
            }
            sr.Export(filename, format, 0, 0,
                      PowerPoint.PpExportMode.ppRelativeToSlide);
            tfc.AddFile(filename, false);
            //Compute the MD5 of the BG
            FileStream fs          = new FileStream(filename, FileMode.Open, FileAccess.Read);
            MD5        md5Provider = new MD5CryptoServiceProvider();

            byte[] md5 = md5Provider.ComputeHash(fs);
            fs.Seek(0, SeekOrigin.Begin);
            Image image = Image.FromStream(fs);

            if (bitmapMode)
            {
                image = DisassociateBitmap(image);
            }

            fs.Close();
            //Calculate the geometry
            int xCoord = 0;
            int yCoord = 0;
            int width  = 0;
            int height = 0;

            PPTDeckIO.CalculateGeometry(image, shapes, range, emfWidthRatio, emfHeightRatio, ref xCoord, ref yCoord, ref width, ref height);
            //Create the ImageSheet
            ImageSheetModel sheet = new ImageSheetModel(deck, Guid.NewGuid(), layer[0].disp,
                                                        new Rectangle(xCoord, yCoord, width, height), (ByteArray)md5, startHeight);

            //Add the ImageSheet to the Slide
            slide.ContentSheets.Add(sheet);
            //Add the Image+MD5 to the deck
            deck.AddSlideContent((ByteArray)md5, image);
        }