Similar Topics...
 |
OpenXml - Add Page # to PPTX Slide Assuming you have a slide with a shapetree, this method will add a page # element (has correct page # regardless of slide position, even if moved later) /// <summary> /// Adds a page # to a pptx slide /// </summary> /// <param name="shapeTree"></param> static void AddPageNumber(ShapeTree shapeTree) { Shape pageNoShape = new Shape(); ShapeProperties pageNoShapeProperties = new ShapeProperties(); NonVisualShapeProperties nonVisualShapeProperties = new NonVisualShapeProperties(); NonVisualDrawingProperties nonVisualDrawingProperties = new NonVisualDrawingProperties() { Id = (UInt32Value)5U, Name = "Slide Number Placeholder" }; NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties = new NonVisualShapeDrawingProperties(); var shapeLocks = new Drawing.ShapeLocks() { NoGrouping = true }; nonVisualShapeDrawingProperties.Append(shapeLocks); ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties132 = new ApplicationNonVisualDrawingProperties(); PlaceholderShape placeholderShape = new PlaceholderShape() { Type = PlaceholderValues.SlideNumber, Size = PlaceholderSizeValues.Quarter, Index = (UInt32Value)12U }; applicationNonVisualDrawingProperties132.Append(placeholderShape); nonVisualShapeProperties.Append(nonVisualDrawingProperties); nonVisualShapeProperties.Append(nonVisualShapeDrawingProperties); nonVisualShapeProperties.Append(applicationNonVisualDrawingProperties132); var transform2D51 = new Drawing.Transform2D(); var offset84 = new Drawing.Offset() { X = 8613648L, Y = 6305550L }; var extents84 = new Drawing.Extents() { Cx = 457200L, Cy = 476250L }; transform2D51.Append(offset84); transform2D51.Append(extents84); pageNoShapeProperties.Append(transform2D51); TextBody textBodyPageNo = new TextBody(); var bodyProperties105 = new Drawing.BodyProperties(); var listStyle105 = new Drawing.ListStyle(); var paragraph161 = new Drawing.Paragraph(); var field28 = new Drawing.Field() { Id = "{3E007167-6CA5-435B-A53A-AB0B8F1915B8}", Type = "slidenum" }; var runProperties108 = new Drawing.RunProperties() { Language = "en-US" }; //, SmartTagClean = false var paragraphProperties131 = new Drawing.ParagraphProperties(); var text111 = new Drawing.Text(); field28.Append(runProperties108); field28.Append(paragraphProperties131); field28.Append(text111); var endParagraphRunProperties100 = new Drawing.EndParagraphRunProperties() { Language = "en-US", Dirty = false }; paragraph161.Append(field28); paragraph161.Append(endParagraphRunProperties100); textBodyPageNo.Append(bodyProperties105); textBodyPageNo.Append(listStyle105); textBodyPageNo.Append(paragraph161); pageNoShape.Append(nonVisualShapeProperties); pageNoShape.Append(pageNoShapeProperties); pageNoShape.Append(textBodyPageNo); shapeTree.Append(pageNoShape); }
Created By: amos 4/24/2014 12:26:41 PM
|
|
|
|
|
|