/// <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); }