Example #1
0
        private void SetShapeNonVisualProperties(SlidePart slidePart, Shape shape)
        {
            if (shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick != null)
            {
                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
                {
                    if (link.Id.Equals(shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnClick.Id))
                    {
                        ClickLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
                    }
                }
            }
            if (shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover != null)
            {
                foreach (HyperlinkRelationship link in slidePart.HyperlinkRelationships)
                {
                    if (link.Id.Equals(shape.NonVisualShapeProperties.NonVisualDrawingProperties.HyperlinkOnHover.Id))
                    {
                        HoverLinkUrl = link.Uri.IsAbsoluteUri ? link.Uri.AbsoluteUri : link.Uri.OriginalString;
                    }
                }
            }

            var nonVisualShapeProp = new PPTNonVisualShapeProp
            {
                Id = "s1s" +                              //HARD CODED: we split it into separate HTML files!
                     shape.NonVisualShapeProperties.NonVisualDrawingProperties.Id,
                Name = shape.LocalName,
                Type = "PPTShape"
            };

            base.NonVisualShapeProp = nonVisualShapeProp;
        }
Example #2
0
        private bool GetParagraphChildElements(Shape shape, PPTParagraph par, bool hasText, OpenXmlElement obj)
        {
            if (obj is Run)
            {
                Run run = (Run)obj;
                hasText = true;
                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
                runProp.Text = run.Text.Text;
                runProp.SetRunProperties(run.RunProperties, shape, ref effectShapes);
                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
                par.RunPropList.Add(runProp);
            }

            else if (obj is Field)
            {
                Field run = (Field)obj;
                hasText = true;
                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
                runProp.Text = run.Text.Text;
                runProp.SetRunProperties(run.RunProperties, shape, ref effectShapes);
                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
                par.RunPropList.Add(runProp);
            }

            else if (obj is Break)
            {
                Break            aBreak  = (Break)obj;
                PPTRunProperties runProp = new PPTRunProperties(par.defaultRunProperties);
                runProp.SetRunProperties(aBreak.RunProperties, shape, ref effectShapes);
                runProp.FontSize = Math.Round(fontScale * runProp.FontSize / Globals.PercentageConstant);
                runProp.isBreak  = true;
                par.RunPropList.Add(runProp);
            }
            return(hasText);
        }
        private void FillPlaceholder(P.Shape placeholderElement, Dictionary <string, string> dataRow)
        {
            Match match = Regex.Match(placeholderElement.InnerText, PlaceholderPattern);

            if (!match.Success)
            {
                throw new InvalidDataException("placeholderElement.InnerText has to match the PlaceholderPattern");
            }

            string fieldName = match.Groups[PatternGroupKey].Value;
            string value     = dataRow[fieldName];

            placeholderElement.TextBody = new P.TextBody(
                new BodyProperties(),
                new ListStyle(),
                new Paragraph(
                    new Run()
            {
                Text = new D.Text(value)
            },
                    new EndParagraphRunProperties()
            {
                Language = "en-US"
            }));
        }
Example #4
0
        private void SetShapeVisualProperties(SlidePart slidePart, Shape shape)
        {
            if (shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.PlaceholderShape != null)
            {
                placeholder = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.
                              PlaceholderShape;
                if (placeholder.Type == null)
                {
                    placeholder.Type = PlaceholderValues.Body;
                }
            }


            base.VisualShapeProp = new PPTVisualPPTShapeProp();
            base.SetSlideLayoutVisualShapeProperties(slidePart, shape);
            if (shape.ShapeProperties.Transform2D != null)
            {
                Int32Value rot = shape.ShapeProperties.Transform2D.Rotation;
                if (rot != null)
                {
                    double degrees = Math.Round(rot / RotationIndex);
                    if (degrees < 0)
                    {
                        degrees = 360 + degrees;
                    }
                    base.VisualShapeProp.Rotate = degrees;
                }

                base.VisualShapeProp.Extents = shape.ShapeProperties.Transform2D.Extents;
                base.VisualShapeProp.Offset  = shape.ShapeProperties.Transform2D.Offset;
            }
        }
Example #5
0
        public void SetRunProperties(RunProperties runProperties,
                                     DocumentFormat.OpenXml.Presentation.Shape shape,
                                     ref LinkedList <string> effectShapes)
        {
            if (runProperties != null)
            {
                EffectList   effects  = runProperties.GetFirstChild <EffectList>();
                GradientFill gradient = runProperties.GetFirstChild <GradientFill>();

                if ((shape.TextBody.BodyProperties != null && shape.TextBody.BodyProperties.FromWordArt != null && shape.TextBody.BodyProperties.FromWordArt) ||
                    (effects != null && effects.HasChildren) ||
                    (gradient != null && gradient.HasChildren))
                {
                    UInt32Value id = shape.NonVisualShapeProperties.NonVisualDrawingProperties.Id;
                    effectShapes.AddLast(slide.slideIndex + "_" + id.Value);
                }


                //get the text color.
                var solidFill = runProperties.GetFirstChild <SolidFill>();
                if (solidFill != null)
                {
                    this.ReadSolidFillColors(solidFill);
                }
                if (runProperties.FontSize != null)
                {
                    FontSize = runProperties.FontSize / Globals.FontPoint;
                }
                if (runProperties.Bold != null)
                {
                    Bold = runProperties.Bold;
                }

                if (runProperties.Italic != null)
                {
                    Italic = runProperties.Italic;
                }
                if (runProperties.Underline != null)
                {
                    Underline = runProperties.Underline.Value.ToString();
                }
                if (runProperties.Spacing != null)
                {
                    Spacing = runProperties.Spacing.Value;
                }

                var latinFonts        = runProperties.GetFirstChild <LatinFont>();
                var coplexScriptFonts = runProperties.Descendants <ComplexScriptFont>();

                if (latinFonts != null)
                {
                    this.ReadFontFamilyFromTheme(latinFonts);
                }
                else if (coplexScriptFonts.GetEnumerator().Current != null)
                {
                    FontFamily = coplexScriptFonts.GetEnumerator().Current.Typeface;
                }
            }
        }
Example #6
0
        public PPTShape(SlidePart slidePart, Shape shape, PPTSlide slide) : base()
        {
            this.slide = slide;

            SetShapeVisualProperties(slidePart, shape);
            SetShapeNonVisualProperties(slidePart, shape);
            SetSpecificProperties(slidePart, shape);
        }
Example #7
0
        public SCImage FromSlidePart(SlidePart slidePart, OpenXmlCompositeElement compositeElement)
        {
            P.Shape    pShape          = (P.Shape)compositeElement;
            A.BlipFill aBlipFill       = pShape.ShapeProperties.GetFirstChild <A.BlipFill>();
            SCImage    backgroundImage = TryFromBlipFill(slidePart, aBlipFill);

            return(backgroundImage);
        }
Example #8
0
 // ReSharper disable once UnusedParameter.Local
 private static void UpdatePowerPointBlock(OpenXmlPartContainer container, OpenXmlElement block, string content)
 {
     OXP.Shape shape = (OXP.Shape)block.CloneNode(true);
     OXD.Run   run   = (OXD.Run)shape.TextBody.Descendants <OXD.Run>().First().CloneNode(true);
     run.Text = new OXD.Text(content);
     OXD.Paragraph paragraph = shape.TextBody.GetFirstChild <OXD.Paragraph>();
     paragraph.RemoveAllChildren <OXD.Run>();
     OXD.EndParagraphRunProperties endP = paragraph.GetFirstChild <OXD.EndParagraphRunProperties>();
     paragraph.InsertBefore(run, endP);
     block.Parent.ReplaceChild(shape, block);
 }
Example #9
0
        private void SetSpecificProperties(SlidePart slidePart, Shape shape)
        {
            IsText = true;
            //Check if this is text
            if (shape.TextBody == null)
            {
                IsText = false;
                return;
            }

            if (shape.TextBody.BodyProperties != null)
            {
                if (shape.TextBody.BodyProperties.Anchor != null)
                {
                    VerticalAlign = shape.TextBody.BodyProperties.Anchor;
                }
                if (shape.TextBody.BodyProperties.GetFirstChild <NormalAutoFit>() != null &&
                    shape.TextBody.BodyProperties.GetFirstChild <NormalAutoFit>().FontScale != null)
                {
                    fontScale = shape.TextBody.BodyProperties.GetFirstChild <NormalAutoFit>().FontScale.Value;
                }
            }
            int index = 0;

            foreach (var paragraph in shape.TextBody.Descendants <Paragraph>())
            {
                var par = new PPTParagraph(slide, placeholder)
                {
                    Paragraph = index++
                };

                if (paragraph.ParagraphProperties != null)
                {
                    int level = paragraph.ParagraphProperties.Level == null ?
                                -1 : paragraph.ParagraphProperties.Level.Value;
                    par.Level = level;
                }

                par.SetParagraphProperties(paragraph, slidePart,
                                           shapeListStyleMaster, shapeListStyleLayout);
                bool hasText = false;
                foreach (var obj in paragraph.ChildElements)
                {
                    hasText = GetParagraphChildElements(shape, par, hasText, obj);
                }
                //This is because when we set paragraph properties we add the bullet to the text runs.
                //If we don't have text it still outputs the bullet character.
                if (par.bullet != null && hasText)
                {
                    par.RunPropList.Insert(0, par.bullet);
                }
                Texts.AddLast(par);
            }
        }
Example #10
0
 public static P.NonVisualDrawingProperties GetNonVisualDrawingProperties(
     this OpenXmlCompositeElement compositeElement)
 {
     // Get <p:cNvSpPr>
     return(compositeElement switch
     {
         P.GraphicFrame pGraphicFrame => pGraphicFrame.NonVisualGraphicFrameProperties
         .NonVisualDrawingProperties,
         P.Shape pShape => pShape.NonVisualShapeProperties.NonVisualDrawingProperties,
         P.Picture pPicture => pPicture.NonVisualPictureProperties.NonVisualDrawingProperties,
         P.GroupShape pGroupShape => pGroupShape.NonVisualGroupShapeProperties.NonVisualDrawingProperties,
         _ => throw new ShapeCrawlerException()
     });
Example #11
0
        private void fillPropertiesFromMasterShape(DocumentFormat.OpenXml.Presentation.Shape masterShape, bool isLayout, bool addListStyle)
        {
            if (null != masterShape.TextBody)
            {
                if (masterShape.TextBody.ListStyle != null && addListStyle)
                {
                    if (isLayout)
                    {
                        shapeListStyleLayout = masterShape.TextBody.ListStyle;
                    }
                    else
                    {
                        shapeListStyleMaster = masterShape.TextBody.ListStyle;
                    }
                }
                if (masterShape.TextBody.BodyProperties != null && masterShape.TextBody.BodyProperties.Anchor != null)
                {
                    VerticalAlign = masterShape.TextBody.BodyProperties.Anchor;
                }
                if (masterShape.TextBody.BodyProperties.TopInset != null)
                {
                    TopInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.TopInset.Value / 12700);
                }
                if (masterShape.TextBody.BodyProperties.BottomInset != null)
                {
                    BottomInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.BottomInset.Value / 12700);
                }
                if (masterShape.TextBody.BodyProperties.RightInset != null)
                {
                    RightInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.RightInset.Value / 12700);
                }
                if (masterShape.TextBody.BodyProperties.LeftInset != null)
                {
                    LeftInset = (int)Math.Round((double)masterShape.TextBody.BodyProperties.LeftInset.Value / 12700);
                }

                if (masterShape.TextBody.BodyProperties != null &&
                    masterShape.TextBody.BodyProperties.GetFirstChild <DocumentFormat.OpenXml.Drawing.NormalAutoFit>() != null &&
                    masterShape.TextBody.BodyProperties.GetFirstChild <DocumentFormat.OpenXml.Drawing.NormalAutoFit>().FontScale != null)
                {
                    fontScale = masterShape.TextBody.BodyProperties.GetFirstChild <DocumentFormat.OpenXml.Drawing.NormalAutoFit>().FontScale.Value;
                }
            }
            if (masterShape.ShapeProperties.Transform2D != null)
            {
                VisualShapeProp.Extents = masterShape.ShapeProperties.Transform2D.Extents;
                VisualShapeProp.Offset  = masterShape.ShapeProperties.Transform2D.Offset;
            }
        }
        /// <summary>
        /// Get the title of the slide.
        /// Returns String.Empty if it can't find it
        /// </summary>
        /// <param name="slidePart"></param>
        /// <returns></returns>
        private string GetSlideTitle(SlidePart slidePart)
        {
            if (slidePart == null || slidePart.Slide == null)
            {
                return(String.Empty);
            }

            Shape shape = slidePart.Slide.Descendants <Shape>().FirstOrDefault(IsTitleShape);

            if (shape == null || shape.TextBody == null)
            {
                return(String.Empty);
            }

            return(shape.TextBody.InnerText);
        }
        /// <summary>
        /// Gets if this shape is for body or not
        /// </summary>
        /// <param name="shape">Shape of interest</param>
        /// <returns>True if it is body shape, false otherwise</returns>
        private bool IsBodyShape(Shape shape)
        {
            if (shape == null ||
                shape.NonVisualShapeProperties == null ||
                shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties == null)
            {
                return(false);
            }

            PlaceholderShape phShape = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.GetFirstChild <PlaceholderShape>();

            return(phShape != null &&
                   phShape.Type != null &&
                   phShape.Type.HasValue &&
                   phShape.Type.Value == PlaceholderValues.Body);
        }
Example #14
0
        private PlaceholderFontData FromLayoutMasterElement(P.Shape sdkShape)
        {
            var placeholderFontData = _placeholderService.PlaceholderFontDataFromCompositeElement(sdkShape);

            placeholderFontData.LvlFontHeights = FontHeightParser.FromCompositeElement(sdkShape.TextBody.ListStyle);

            if (!placeholderFontData.LvlFontHeights.Any()) // font height is still not known
            {
                var endParaRunPrFs = sdkShape.TextBody.GetFirstChild <A.Paragraph>().GetFirstChild <A.EndParagraphRunProperties>()?.FontSize;
                if (endParaRunPrFs != null)
                {
                    placeholderFontData.LvlFontHeights.Add(1, endParaRunPrFs.Value);
                }
            }

            return(placeholderFontData);
        }
        private static PlaceholderFontData FromLayoutMasterElement(P.Shape xmlShape)
        {
            var ph = FromSlideXmlElement(xmlShape);

            ph.LvlFontHeights = FontHeightParser.FromCompositeElement(xmlShape.TextBody.ListStyle);

            if (!ph.LvlFontHeights.Any()) // font height is still not known
            {
                var endParaRunPrFs = xmlShape.TextBody.GetFirstChild <A.Paragraph>().GetFirstChild <A.EndParagraphRunProperties>()?.FontSize;
                if (endParaRunPrFs != null)
                {
                    ph.LvlFontHeights.Add(1, endParaRunPrFs.Value);
                }
            }

            return(ph);
        }
Example #16
0
        public bool WriteOnSlide()
        {
            string filePath = System.Web.HttpContext.Current.Server.MapPath("~/TemplatePPT/Plantilla1.ppsx");
            string imagen1  = System.Web.HttpContext.Current.Server.MapPath("~/Images/zima1.jpeg");
            string imagen2  = System.Web.HttpContext.Current.Server.MapPath("~/Images/zima2.jpeg");

            string tituloText    = "Este es el titulo de la diapositiva: " + DateTime.Now.ToString();
            string subTituloText = "Este es el subtitulo de la diapositiva: " + Environment.NewLine + "Prueba de contexto del manejo de presentaciones PowerPoint con el Nuget \n DOCUMENT FORMAT OPEN XML " + Environment.NewLine + DateTime.Now.ToString();

            try
            {
                using (PresentationDocument documentoPP = PresentationDocument.Open(filePath, true))
                {
                    PresentationPart      partesDocumento  = documentoPP.PresentationPart;
                    Presentation          presentacion     = partesDocumento.Presentation;
                    OpenXmlElementList    diapositivas     = partesDocumento.Presentation.SlideIdList.ChildElements;
                    string                idDiapositiva    = (diapositivas[1] as SlideId).RelationshipId;//DIAPOSITIVA ACTUAL
                    SlidePart             diapositiva      = (SlidePart)partesDocumento.GetPartById(idDiapositiva);
                    List <OpenXmlElement> itemsdiapositiva = diapositiva.Slide.CommonSlideData.ShapeTree.ChildElements.ToList();

                    DocumentFormat.OpenXml.Presentation.Shape titulo    = (DocumentFormat.OpenXml.Presentation.Shape)itemsdiapositiva[2];
                    DocumentFormat.OpenXml.Presentation.Shape subTitulo = (DocumentFormat.OpenXml.Presentation.Shape)itemsdiapositiva[3];
                    // DocumentFormat.OpenXml.Presentation.Picture imagen = (DocumentFormat.OpenXml.Presentation.Picture)itemsdiapositiva[4];
                    titulo.InnerXml    = GetXmlStringBody(titulo.InnerXml, tituloText);
                    subTitulo.InnerXml = GetXmlStringBody(subTitulo.InnerXml, subTituloText);
                    byte[] nuevaImagen = GetBytesImagen(imagen1);//CAMBIAR IMAGEN
                    ReplacePicture("", nuevaImagen, "image/jpeg", diapositiva);

                    partesDocumento.Presentation.Save();
                }


                ReadWriteTxt(filePath);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
Example #17
0
        // Determines whether the shape is a title shape.
        private static bool IsTitleShape(Shape shape)
        {
            var placeholderShape = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.GetFirstChild <PlaceholderShape>();

            if (placeholderShape != null && placeholderShape.Type != null && placeholderShape.Type.HasValue)
            {
                switch ((PlaceholderValues)placeholderShape.Type)
                {
                // Any title shape.
                case PlaceholderValues.Title:

                // A centered title.
                case PlaceholderValues.CenteredTitle:
                    return(true);

                default:
                    return(false);
                }
            }
            return(false);
        }
Example #18
0
        /// <summary>
        /// Change the fill color of a shape, docName must have a filled shape as the first shape on the first slide.
        /// </summary>
        /// <param name="docName">path to the file</param>
        public static void SetPPTShapeColor(string docName)
        {
            using (PresentationDocument ppt = PresentationDocument.Open(docName, true))
            {
                // Get the relationship ID of the first slide.
                PresentationPart   part     = ppt.PresentationPart;
                OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements;
                string             relId    = (slideIds[0] as SlideId).RelationshipId;

                // Get the slide part from the relationship ID.
                SlidePart slide = (SlidePart)part.GetPartById(relId);

                if (slide != null)
                {
                    // Get the shape tree that contains the shape to change.
                    ShapeTree tree = slide.Slide.CommonSlideData.ShapeTree;

                    // Get the first shape in the shape tree.
                    PShape shape = tree.GetFirstChild <PShape>();

                    if (shape != null)
                    {
                        // Get the style of the shape.
                        ShapeStyle style = shape.ShapeStyle;

                        // Get the fill reference.
                        FillReference fillRef = style.FillReference;

                        // Set the fill color to SchemeColor Accent 6;
                        fillRef.SchemeColor = new SchemeColor
                        {
                            Val = SchemeColorValues.Accent6
                        };

                        // Save the modified slide.
                        slide.Slide.Save();
                    }
                }
            }
        }
Example #19
0
 public GeometryType ForShape(P.Shape sdkShape)
 {
     Check.NotNull(sdkShape, nameof(sdkShape));
     return(ForCompositeElement(sdkShape, sdkShape.ShapeProperties));
 }
Example #20
0
        /// <summary>
        /// Check the notes page size and reset values
        /// </summary>
        /// <param name="pDoc">oxml doc to change</param>
        public static void ChangeNotesPageSize(PresentationDocument pDoc)
        {
            if (pDoc == null)
            {
                throw new ArgumentNullException("pDoc = null");
            }

            // Get the presentation part of document
            PresentationPart presentationPart = pDoc.PresentationPart;

            if (presentationPart != null)
            {
                Presentation p = presentationPart.Presentation;

                // Step 1 : Resize the presentation notesz prop
                // if the notes size is already the default, no need to make any changes
                if (p.NotesSize.Cx != 6858000 || p.NotesSize.Cy != 9144000)
                {
                    // setup default size
                    NotesSize defaultNotesSize = new NotesSize()
                    {
                        Cx = 6858000L, Cy = 9144000L
                    };

                    // first reset the notes size values
                    p.NotesSize = defaultNotesSize;

                    // now save up the part
                    p.Save();
                }

                // Step 2 : loop the shapes in the notes master and reset their sizes
                // need to find a way to flag a file if the notes master and/or notes slides become corrupt
                // hiding behind a setting checkbox for now
                if (Properties.Settings.Default.ResetNotesMaster == true)
                {
                    // we need to reset sizes in the notes master for each shape
                    ShapeTree mSt = presentationPart.NotesMasterPart.NotesMaster.CommonSlideData.ShapeTree;

                    foreach (var mShp in mSt)
                    {
                        if (mShp.ToString() == StringResources.dfopShape)
                        {
                            PShape ps = (PShape)mShp;
                            NonVisualDrawingProperties nvdpr = ps.NonVisualShapeProperties.NonVisualDrawingProperties;
                            Transform2D t2d = ps.ShapeProperties.Transform2D;

                            // use default values
                            if (nvdpr.Name == StringResources.pptHeaderPlaceholder1)
                            {
                                t2d.Offset.X   = 0L;
                                t2d.Offset.Y   = 0L;
                                t2d.Extents.Cx = 2971800L;
                                t2d.Extents.Cy = 458788L;
                            }

                            if (nvdpr.Name == StringResources.pptDatePlaceholder2)
                            {
                                t2d.Offset.X   = 3884613L;
                                t2d.Offset.Y   = 0L;
                                t2d.Extents.Cx = 2971800L;
                                t2d.Extents.Cy = 458788L;
                            }

                            if (nvdpr.Name == StringResources.pptSlideImagePlaceholder3)
                            {
                                t2d.Offset.X   = 685800L;
                                t2d.Offset.Y   = 1143000L;
                                t2d.Extents.Cx = 5486400L;
                                t2d.Extents.Cy = 3086100L;
                            }

                            if (nvdpr.Name == StringResources.pptNotesPlaceholder4)
                            {
                                t2d.Offset.X   = 685800L;
                                t2d.Offset.Y   = 4400550L;
                                t2d.Extents.Cx = 5486400L;
                                t2d.Extents.Cy = 3600450L;
                            }

                            if (nvdpr.Name == StringResources.pptFooterPlaceholder5)
                            {
                                t2d.Offset.X   = 0L;
                                t2d.Offset.Y   = 8685213L;
                                t2d.Extents.Cx = 2971800L;
                                t2d.Extents.Cy = 458787L;
                            }

                            if (nvdpr.Name == StringResources.pptSlideNumberPlaceholder6)
                            {
                                t2d.Offset.X   = 3884613L;
                                t2d.Offset.Y   = 8685213L;
                                t2d.Extents.Cx = 2971800L;
                                t2d.Extents.Cy = 458787L;
                            }
                        }
                    }

                    // Step 3 : we need to delete the size values for placeholders on each notes slide
                    foreach (var slideId in p.SlideIdList.Elements <SlideId>())
                    {
                        SlidePart            slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
                        ShapeTree            st        = slidePart.NotesSlidePart.NotesSlide.CommonSlideData.ShapeTree;
                        List <RunProperties> rpList    = slidePart.NotesSlidePart.NotesSlide.Descendants <RunProperties>().ToList();

                        foreach (var s in st)
                        {
                            // we only want to make changes to the shapes
                            if (s.ToString() == StringResources.dfopShape)
                            {
                                PShape      ps  = (PShape)s;
                                Transform2D t2d = ps.ShapeProperties.Transform2D;
                                TextBody    tb  = ps.TextBody;

                                // if the transform exists, delete it for each shape
                                if (t2d != null)
                                {
                                    t2d.Remove();
                                }

                                // if there are drawing paragraph props, reset the margin and indent to 0
                                if (ps.TextBody != null)
                                {
                                    foreach (var x in tb.ChildElements)
                                    {
                                        if (x.ToString() == "DocumentFormat.OpenXml.Drawing.Paragraph")
                                        {
                                            Paragraph para = (Paragraph)x;
                                            if (para.ParagraphProperties != null)
                                            {
                                                if (para.ParagraphProperties.LeftMargin != null)
                                                {
                                                    para.ParagraphProperties.LeftMargin = 0;
                                                }

                                                if (para.ParagraphProperties.Indent != null)
                                                {
                                                    para.ParagraphProperties.Indent = 0;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (s.ToString() == StringResources.dfopPresentationPicture)
                            {
                                DocumentFormat.OpenXml.Presentation.Picture pic = (DocumentFormat.OpenXml.Presentation.Picture)s;
                                Transform2D t2d = pic.ShapeProperties.Transform2D;

                                // there are times when pictures get moved with the rest of the slide objects, need to reset those back
                                if (t2d != null)
                                {
                                    t2d.Offset.X   = 217831L;
                                    t2d.Offset.Y   = 4470109L;
                                    t2d.Extents.Cx = 3249763L;
                                    t2d.Extents.Cy = 2795946L;
                                }
                            }
                        }

                        foreach (RunProperties r in rpList)
                        {
                            r.FontSize = 1200;
                        }
                    }
                }
            }
        }
        // Insert the specified slide into the presentation at the specified position.
        public static void InsertNewSlide(PresentationDocument presentationDocument, int position, string slideTitle, List <string> HeaderData, List <string> CsvRow)
        {
            if (presentationDocument == null)
            {
                throw new ArgumentNullException("presentationDocument");
            }

            if (slideTitle == null)
            {
                throw new ArgumentNullException("slideTitle");
            }

            PresentationPart presentationPart = presentationDocument.PresentationPart;

            // Verify that the presentation is not empty.
            if (presentationPart == null)
            {
                throw new InvalidOperationException("The presentation document is empty.");
            }

            // Declare and instantiate a new slide.
            Slide slide           = new Slide(new CommonSlideData(new ShapeTree()));
            uint  drawingObjectId = 1;

            // Construct the slide content.
            // Specify the non-visual properties of the new slide.
            P.NonVisualGroupShapeProperties nonVisualProperties = slide.CommonSlideData.ShapeTree.AppendChild(new P.NonVisualGroupShapeProperties());
            nonVisualProperties.NonVisualDrawingProperties = new P.NonVisualDrawingProperties()
            {
                Id = 1, Name = ""
            };
            nonVisualProperties.NonVisualGroupShapeDrawingProperties  = new P.NonVisualGroupShapeDrawingProperties();
            nonVisualProperties.ApplicationNonVisualDrawingProperties = new ApplicationNonVisualDrawingProperties();

            // Specify the group shape properties of the new slide.
            slide.CommonSlideData.ShapeTree.AppendChild(new GroupShapeProperties());

            // Declare and instantiate the title shape of the new slide.
            P.Shape titleShape = slide.CommonSlideData.ShapeTree.AppendChild(new P.Shape());

            drawingObjectId++;

            // Specify the required shape properties for the title shape.
            titleShape.NonVisualShapeProperties = new P.NonVisualShapeProperties
                                                      (new P.NonVisualDrawingProperties()
            {
                Id = drawingObjectId, Name = "Title"
            },
                                                      new P.NonVisualShapeDrawingProperties(new D.ShapeLocks()
            {
                NoGrouping = true
            }),
                                                      new ApplicationNonVisualDrawingProperties(new PlaceholderShape()
            {
                Type = PlaceholderValues.Title
            }));
            titleShape.ShapeProperties = new P.ShapeProperties();

            // Specify the text of the title shape.
            titleShape.TextBody = new P.TextBody(new D.BodyProperties(),
                                                 new D.ListStyle(),
                                                 new D.Paragraph(new D.Run(new D.Text()
            {
                Text = slideTitle
            })));

            // Declare and instantiate the body shape of the new slide.
            P.Shape bodyShape = slide.CommonSlideData.ShapeTree.AppendChild(new P.Shape());
            drawingObjectId++;

            // Specify the required shape properties for the body shape.
            bodyShape.NonVisualShapeProperties = new P.NonVisualShapeProperties(new P.NonVisualDrawingProperties()
            {
                Id = drawingObjectId, Name = "Content Placeholder",
            },
                                                                                new P.NonVisualShapeDrawingProperties(new D.ShapeLocks()
            {
                NoGrouping = true
            }),
                                                                                new ApplicationNonVisualDrawingProperties(new PlaceholderShape()
            {
                Index = 1
            }));
            bodyShape.ShapeProperties             = new P.ShapeProperties();
            bodyShape.ShapeProperties.Transform2D = new DocumentFormat.OpenXml.Drawing.Transform2D();
            bodyShape.ShapeProperties.Transform2D.Append(new DocumentFormat.OpenXml.Drawing.Offset
            {
                X = 2286000,
                Y = 1720840,
            });
            bodyShape.ShapeProperties.Transform2D.Append(new DocumentFormat.OpenXml.Drawing.Extents
            {
                Cx = 4572000,
                Cy = 3416320,
            });
            // Specify the text of the body shape.
            bodyShape.TextBody = new P.TextBody(new D.BodyProperties(),
                                                new D.ListStyle());
            for (int i = 0; i < HeaderData.Count; i++)
            {
                bodyShape.TextBody.AppendChild(new D.Paragraph(new D.Run(new D.Text()
                {
                    Text = $"{HeaderData[i]} : {CsvRow[i]}"
                })));
            }

            // Create the slide part for the new slide.
            SlidePart slidePart = presentationPart.AddNewPart <SlidePart>();

            // Save the new slide part.
            slide.Save(slidePart);

            // Modify the slide ID list in the presentation part.
            // The slide ID list should not be null.
            SlideIdList slideIdList = presentationPart.Presentation.SlideIdList;

            // Find the highest slide ID in the current list.
            uint    maxSlideId  = 1;
            SlideId prevSlideId = null;

            foreach (SlideId slideId in slideIdList.ChildElements)
            {
                if (slideId.Id > maxSlideId)
                {
                    maxSlideId = slideId.Id;
                }

                position--;
                if (position == 0)
                {
                    prevSlideId = slideId;
                }
            }

            maxSlideId++;

            // Get the ID of the previous slide.
            SlidePart lastSlidePart;

            if (prevSlideId != null)
            {
                lastSlidePart = (SlidePart)presentationPart.GetPartById(prevSlideId.RelationshipId);
            }
            else
            {
                lastSlidePart = (SlidePart)presentationPart.GetPartById(((SlideId)(slideIdList.ChildElements[0])).RelationshipId);
            }

            // Use the same slide layout as that of the previous slide.
            if (null != lastSlidePart.SlideLayoutPart)
            {
                slidePart.AddPart(lastSlidePart.SlideLayoutPart);
            }

            // Insert the new slide into the slide list after the previous slide.
            SlideId newSlideId = slideIdList.InsertAfter(new SlideId(), prevSlideId);

            newSlideId.Id             = maxSlideId;
            newSlideId.RelationshipId = presentationPart.GetIdOfPart(slidePart);

            // Save the modified presentation.
            presentationPart.Presentation.Save();
        }
Example #22
0
        public static NoteSlideHelper GetNotesPageSizesFromFile()
        {
            NoteSlideHelper nsh = new NoteSlideHelper();

            OpenFileDialog fDialog = new OpenFileDialog
            {
                Title            = "Select PowerPoint File.",
                Filter           = "PowerPoint | *.pptx",
                RestoreDirectory = true,
                InitialDirectory = @"%userprofile%"
            };

            if (fDialog.ShowDialog() == DialogResult.OK)
            {
                using (PresentationDocument document = PresentationDocument.Open(fDialog.FileName, false))
                {
                    nsh.pNotesSz.Cx = document.PresentationPart.Presentation.NotesSize.Cx;
                    nsh.pNotesSz.Cy = document.PresentationPart.Presentation.NotesSize.Cy;

                    ShapeTree mSt = document.PresentationPart.NotesMasterPart.NotesMaster.CommonSlideData.ShapeTree;

                    foreach (var mShp in mSt)
                    {
                        if (mShp.ToString() == StringResources.dfopShape)
                        {
                            PShape ps = (PShape)mShp;
                            NonVisualDrawingProperties nvdpr = ps.NonVisualShapeProperties.NonVisualDrawingProperties;
                            Transform2D t2d = ps.ShapeProperties.Transform2D;

                            if (nvdpr.Name == StringResources.pptHeaderPlaceholder1)
                            {
                                nsh.t2dHeader.OffsetX   = t2d.Offset.X;
                                nsh.t2dHeader.OffsetY   = t2d.Offset.Y;
                                nsh.t2dHeader.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dHeader.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptDatePlaceholder2)
                            {
                                nsh.t2dDate.OffsetX   = t2d.Offset.X;
                                nsh.t2dDate.OffsetY   = t2d.Offset.Y;
                                nsh.t2dDate.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dDate.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptSlideImagePlaceholder3)
                            {
                                nsh.t2dSlideImage.OffsetX   = t2d.Offset.X;
                                nsh.t2dSlideImage.OffsetY   = t2d.Offset.Y;
                                nsh.t2dSlideImage.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dSlideImage.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptNotesPlaceholder4)
                            {
                                nsh.t2dNotes.OffsetX   = t2d.Offset.X;
                                nsh.t2dNotes.OffsetY   = t2d.Offset.Y;
                                nsh.t2dNotes.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dNotes.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptFooterPlaceholder5)
                            {
                                nsh.t2dFooter.OffsetX   = t2d.Offset.X;
                                nsh.t2dFooter.OffsetY   = t2d.Offset.Y;
                                nsh.t2dFooter.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dFooter.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptSlideNumberPlaceholder6)
                            {
                                nsh.t2dSlideNumber.OffsetX   = t2d.Offset.X;
                                nsh.t2dSlideNumber.OffsetY   = t2d.Offset.Y;
                                nsh.t2dSlideNumber.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dSlideNumber.ExtentsCy = t2d.Extents.Cy;
                            }

                            if (nvdpr.Name == StringResources.pptPicture)
                            {
                                nsh.t2dPicture.OffsetX   = t2d.Offset.X;
                                nsh.t2dPicture.OffsetY   = t2d.Offset.Y;
                                nsh.t2dPicture.ExtentsCx = t2d.Extents.Cx;
                                nsh.t2dPicture.ExtentsCy = t2d.Extents.Cy;
                            }
                        }
                    }
                }
            }

            return(nsh);
        }
		/// <summary>
		/// Gets if this shape is for body or not
		/// </summary>
		/// <param name="shape">Shape of interest</param>
		/// <returns>True if it is body shape, false otherwise</returns>
		private bool IsBodyShape(Shape shape)
		{
			if (shape == null
				|| shape.NonVisualShapeProperties == null
				|| shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties == null)
			{
				return false;
			}

			PlaceholderShape phShape = shape.NonVisualShapeProperties.ApplicationNonVisualDrawingProperties.GetFirstChild<PlaceholderShape>();

			return phShape != null
				&& phShape.Type != null
				&& phShape.Type.HasValue
				&& phShape.Type.Value == PlaceholderValues.Body;
		}
Example #24
0
        /// <summary>
        /// 添加文本
        /// </summary>
        private Shape AddText(ShapeTree tree, string text, PPTTextStyle textStyle, D.Transform2D transform)
        {
            //Picture
            Shape textShape = tree.AppendChild(new Shape());
            uint  maxid     = AnalysisHelper.GetMaxId(tree);

            textShape.NonVisualShapeProperties = new P.NonVisualShapeProperties
                                                 (
                new P.NonVisualDrawingProperties()
            {
                Id   = maxid + 1,
                Name = $"TEXT{maxid + 1}"
            },
                new P.NonVisualShapeDrawingProperties
                (
                    new D.ShapeLocks()
            {
                NoGrouping = true
            }
                ),
                new ApplicationNonVisualDrawingProperties
                (
                    new PlaceholderShape()
            {
                Type = PlaceholderValues.Body
            }
                )
                                                 );
            //位置
            textShape.ShapeProperties = new ShapeProperties()
            {
                Transform2D = transform
            };

            textShape.TextBody = new TextBody(
                new D.BodyProperties(),
                new D.ListStyle(),
                new D.Paragraph(new D.Run()
            {
                Text = new D.Text()
                {
                    Text = text
                },
                RunProperties = new D.RunProperties
                                (
                    new D.SolidFill()
                {
                    RgbColorModelHex = new D.RgbColorModelHex()
                    {
                        Val = HexBinaryValue.FromString(textStyle.Color.Replace("#", ""))
                    }
                }
                                )
                {
                    FontSize            = (int)(textStyle.FontSize * 100), //20*100 字号20
                    Underline           = textStyle.IsUnderline ? D.TextUnderlineValues.Single : D.TextUnderlineValues.None,
                    Italic              = textStyle.IsItalic,
                    Bold                = textStyle.IsBold,
                    AlternativeLanguage = "zh-CN",
                    Language            = "en-US",
                    Kumimoji            = true,
                    Dirty               = false,
                    SpellingError       = false
                },
            },
                                new D.EndParagraphRunProperties(
                                    new D.SolidFill()
            {
                RgbColorModelHex = new D.RgbColorModelHex()
                {
                    Val = HexBinaryValue.FromString(textStyle.Color.Replace("#", ""))
                }
            }
                                    )
            {
                FontSize            = (int)(textStyle.FontSize * 100), //20*100 字号20
                Underline           = textStyle.IsUnderline ? D.TextUnderlineValues.Single : D.TextUnderlineValues.None,
                Italic              = textStyle.IsItalic,
                Bold                = textStyle.IsBold,
                AlternativeLanguage = "zh-CN",
                Language            = "en-US",
                Kumimoji            = true,
                Dirty               = false,
                SpellingError       = false
            }
                                ));

            return(textShape);
        }
Example #25
0
        private void insertLink(Slide slide, PageUrl pageUrl, int objId)
        {
            slide.SlidePart.AddHyperlinkRelationship(new System.Uri(pageUrl.url, System.UriKind.Absolute), true, "rId" + objId);

            P.Shape shape = new P.Shape();
            P.NonVisualShapeProperties nonVisualShapeProperties1 = new P.NonVisualShapeProperties()
            {
                NonVisualDrawingProperties = new P.NonVisualDrawingProperties()
                {
                    Id = (UInt32Value)2U, Name = "矩形 1", HyperlinkOnClick = new A.HyperlinkOnClick()
                    {
                        Id = "rId" + objId
                    }
                },
                NonVisualShapeDrawingProperties       = new P.NonVisualShapeDrawingProperties(),
                ApplicationNonVisualDrawingProperties = new P.ApplicationNonVisualDrawingProperties()
            };

            P.ShapeProperties shapeProperties = new P.ShapeProperties()
            {
                Transform2D = new A.Transform2D()
                {
                    Offset = new A.Offset()
                    {
                        X = pageUrl.origin.Width * ImageInfoUtils.RATE, Y = pageUrl.origin.Height * ImageInfoUtils.RATE
                    },
                    Extents = new A.Extents()
                    {
                        Cx = pageUrl.size.Width * ImageInfoUtils.RATE, Cy = pageUrl.size.Height * ImageInfoUtils.RATE
                    }
                }
            };

            A.PresetGeometry presetGeometry = new A.PresetGeometry()
            {
                Preset = A.ShapeTypeValues.Rectangle, AdjustValueList = new A.AdjustValueList()
            };
            A.NoFill  noFill  = new A.NoFill();
            A.Outline outline = new A.Outline();
            A.NoFill  noFill2 = new A.NoFill();
            outline.Append(noFill2);

            shapeProperties.Append(presetGeometry);
            shapeProperties.Append(noFill);
            shapeProperties.Append(outline);

            P.ShapeStyle shapeStyle1 = new P.ShapeStyle();

            A.LineReference lineReference = new A.LineReference()
            {
                Index = (UInt32Value)2U
            };
            A.SchemeColor schemeColor = new A.SchemeColor()
            {
                Val = A.SchemeColorValues.Accent1
            };
            A.Shade shade1 = new A.Shade()
            {
                Val = 50000
            };
            schemeColor.Append(shade1);
            lineReference.Append(schemeColor);

            A.FillReference fillReference = new A.FillReference()
            {
                Index = (UInt32Value)1U
            };
            A.SchemeColor schemeColor2 = new A.SchemeColor()
            {
                Val = A.SchemeColorValues.Accent1
            };
            fillReference.Append(schemeColor2);

            A.EffectReference effectReference = new A.EffectReference()
            {
                Index = (UInt32Value)0U
            };
            A.SchemeColor schemeColor3 = new A.SchemeColor()
            {
                Val = A.SchemeColorValues.Accent1
            };
            effectReference.Append(schemeColor3);

            A.FontReference fontReference = new A.FontReference()
            {
                Index = A.FontCollectionIndexValues.Minor
            };
            A.SchemeColor schemeColor4 = new A.SchemeColor()
            {
                Val = A.SchemeColorValues.Light1
            };
            fontReference.Append(schemeColor4);

            shapeStyle1.Append(lineReference);
            shapeStyle1.Append(fillReference);
            shapeStyle1.Append(effectReference);
            shapeStyle1.Append(fontReference);

            P.TextBody       textBody       = new P.TextBody();
            A.BodyProperties bodyProperties = new A.BodyProperties()
            {
                RightToLeftColumns = false, Anchor = A.TextAnchoringTypeValues.Center
            };
            A.ListStyle listStyle = new A.ListStyle();

            A.Paragraph           paragraph           = new A.Paragraph();
            A.ParagraphProperties paragraphProperties = new A.ParagraphProperties()
            {
                Alignment = A.TextAlignmentTypeValues.Center
            };
            A.EndParagraphRunProperties endParagraphRunProperties = new A.EndParagraphRunProperties()
            {
                Language = "zh-CN", AlternativeLanguage = "en-US"
            };

            paragraph.Append(paragraphProperties);
            paragraph.Append(endParagraphRunProperties);

            textBody.Append(bodyProperties);
            textBody.Append(listStyle);
            textBody.Append(paragraph);

            shape.Append(nonVisualShapeProperties1);
            shape.Append(shapeProperties);
            shape.Append(shapeStyle1);
            shape.Append(textBody);

            slide.CommonSlideData.ShapeTree.AppendChild(shape);
        }
Example #26
0
        /// <summary>
        /// Use custom placeholder values from another file
        /// </summary>
        /// <param name="pDoc">oxml doc to change</param>
        public static void UseCustomNotesPageSize(string filename)
        {
            using (PresentationDocument document = PresentationDocument.Open(filename, true))
            {
                NoteSlideHelper nsh = GetNotesPageSizesFromFile();

                if (nsh.pNotesSz.Cx == 0)
                {
                    return;
                }

                // Get the presentation part of document
                PresentationPart presentationPart = document.PresentationPart;

                if (presentationPart != null)
                {
                    Presentation p = presentationPart.Presentation;

                    // Step 1 : Resize the presentation notesz prop
                    NotesSize defaultNotesSize = new NotesSize()
                    {
                        Cx = nsh.pNotesSz.Cx, Cy = nsh.pNotesSz.Cy
                    };

                    // first reset the notes size values
                    p.NotesSize = defaultNotesSize;

                    // now save up the part
                    p.Save();

                    // Step 2 : loop the shapes in the notes master and reset their sizes
                    if (Properties.Settings.Default.ResetNotesMaster == true)
                    {
                        // we need to reset sizes in the notes master for each shape
                        ShapeTree mSt = presentationPart.NotesMasterPart.NotesMaster.CommonSlideData.ShapeTree;

                        foreach (var mShp in mSt)
                        {
                            if (mShp.ToString() == StringResources.dfopShape)
                            {
                                PShape ps = (PShape)mShp;
                                NonVisualDrawingProperties nvdpr = ps.NonVisualShapeProperties.NonVisualDrawingProperties;
                                Transform2D t2d = ps.ShapeProperties.Transform2D;

                                if (nvdpr.Name.ToString().Contains(StringResources.pptHeaderPlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dHeader.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dHeader.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dHeader.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dHeader.ExtentsCy;
                                }

                                if (nvdpr.Name.ToString().Contains(StringResources.pptDatePlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dDate.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dDate.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dDate.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dDate.ExtentsCy;
                                }

                                if (nvdpr.Name.ToString().Contains(StringResources.pptSlideImagePlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dSlideImage.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dSlideImage.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dSlideImage.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dSlideImage.ExtentsCy;
                                }

                                if (nvdpr.Name.ToString().Contains(StringResources.pptNotesPlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dNotes.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dNotes.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dNotes.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dNotes.ExtentsCy;
                                }

                                if (nvdpr.Name.ToString().Contains(StringResources.pptFooterPlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dFooter.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dFooter.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dFooter.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dFooter.ExtentsCy;
                                }

                                if (nvdpr.Name.ToString().Contains(StringResources.pptSlideNumberPlaceholder))
                                {
                                    t2d.Offset.X   = nsh.t2dSlideNumber.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dSlideNumber.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dSlideNumber.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dSlideNumber.ExtentsCy;
                                }

                                if (nvdpr.Name == StringResources.pptPicture)
                                {
                                    t2d.Offset.X   = nsh.t2dPicture.OffsetX;
                                    t2d.Offset.Y   = nsh.t2dPicture.OffsetY;
                                    t2d.Extents.Cx = nsh.t2dPicture.ExtentsCx;
                                    t2d.Extents.Cy = nsh.t2dPicture.ExtentsCy;
                                }
                            }
                        }

                        // Step 3 : we need to delete the size values for placeholders on each notes slide
                        foreach (var slideId in p.SlideIdList.Elements <SlideId>())
                        {
                            SlidePart            slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
                            ShapeTree            st        = slidePart.NotesSlidePart.NotesSlide.CommonSlideData.ShapeTree;
                            List <RunProperties> rpList    = slidePart.NotesSlidePart.NotesSlide.Descendants <RunProperties>().ToList();

                            foreach (var s in st)
                            {
                                // we only want to make changes to the shapes
                                if (s.ToString() == StringResources.dfopShape)
                                {
                                    PShape ps = (PShape)s;
                                    NonVisualDrawingProperties nvdpr = ps.NonVisualShapeProperties.NonVisualDrawingProperties;
                                    Transform2D t2d = ps.ShapeProperties.Transform2D;

                                    if (t2d == null)
                                    {
                                        A.Transform2D t2dn    = new Transform2D();
                                        A.Offset      offset1 = new A.Offset()
                                        {
                                            X = 0L, Y = 0L
                                        };
                                        A.Extents extents1 = new A.Extents()
                                        {
                                            Cx = 0L, Cy = 0L
                                        };
                                        t2d         = t2dn;
                                        t2d.Offset  = offset1;
                                        t2d.Extents = extents1;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptHeaderPlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dHeader.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dHeader.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dHeader.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dHeader.ExtentsCy;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptDatePlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dDate.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dDate.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dDate.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dDate.ExtentsCy;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptSlideImagePlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dSlideImage.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dSlideImage.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dSlideImage.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dSlideImage.ExtentsCy;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptNotesPlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dNotes.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dNotes.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dNotes.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dNotes.ExtentsCy;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptFooterPlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dFooter.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dFooter.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dFooter.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dFooter.ExtentsCy;
                                    }

                                    if (nvdpr.Name.ToString().Contains(StringResources.pptSlideNumberPlaceholder))
                                    {
                                        t2d.Offset.X   = nsh.t2dSlideNumber.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dSlideNumber.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dSlideNumber.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dSlideNumber.ExtentsCy;
                                    }
                                }
                                else if (s.ToString() == StringResources.dfopPresentationPicture)
                                {
                                    DocumentFormat.OpenXml.Presentation.Picture pic = (DocumentFormat.OpenXml.Presentation.Picture)s;
                                    Transform2D t2d = pic.ShapeProperties.Transform2D;

                                    // there are times when pictures get moved with the rest of the slide objects, need to reset those back
                                    if (t2d == null)
                                    {
                                        t2d.Offset.X   = nsh.t2dPicture.OffsetX;
                                        t2d.Offset.Y   = nsh.t2dPicture.OffsetY;
                                        t2d.Extents.Cx = nsh.t2dPicture.ExtentsCx;
                                        t2d.Extents.Cy = nsh.t2dPicture.ExtentsCy;
                                    }
                                    else
                                    {
                                        t2d.Offset.X   = 217831L;
                                        t2d.Offset.Y   = 4470109L;
                                        t2d.Extents.Cx = 3249763L;
                                        t2d.Extents.Cy = 2795946L;
                                    }
                                }
                            }

                            foreach (RunProperties r in rpList)
                            {
                                r.FontSize = 1200;
                            }
                        }
                    }

                    p.Save();
                }
            }
        }