国产PPT处理控件Spire.Presentation功能演示:在C#中设置 PPT 文字的对齐方式

Spire.Presentation for .NET 是专业的 PowerPoint组件,开发者可以在 .NET 平台上对 PPT文档进行生成、修改、转换和打印等操作,而无需安装 Microsoft PowerPoint。

这么优秀的国产工具怎能错过呢!想要获取更多福利的朋友咨询在线客服哦~


设置 PPT 文字的对齐方式

C#

using Spire.Presentation;using System.Drawing;using Spire.Presentation.Drawing;namespace TextAlignment{    class Program    {        static void Main(string[] args)        {            //创建Presentation对象            Presentation presentation = new Presentation();            presentation.SlideSize.Type = SlideSizeType.Screen16x9;              //添加形状            IAutoShape textShape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 200));            textShape.ShapeStyle.LineColor.Color = Color.DarkGray;            textShape.Fill.FillType = FillFormatType.None;            //删除默认段落            textShape.TextFrame.Paragraphs.Clear();            //添加段落和文字            textShape.TextFrame.Paragraphs.Append(new TextParagraph());            textShape.TextFrame.Paragraphs[0].TextRanges.Append(new TextRange("文字对齐方式"));            textShape.TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 20f;            textShape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("黑体");            textShape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;            textShape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;            //设置文字水平靠右            textShape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Right;            //设置文字垂直靠下            textShape.TextFrame.AnchoringType = TextAnchorType.Bottom;            //保存文档            presentation.SaveToFile("AlignText.pptx", FileFormat.Pptx2013);        }    }}

VB.NET

Imports Spire.PresentationImports System.DrawingImports Spire.Presentation.DrawingNamespace TextAlignment    Class Program        Shared  Sub Main(ByVal args() As String)            '创建Presentation对象            Dim presentation As Presentation =  New Presentation()            presentation.SlideSize.Type = SlideSizeType.Screen16x9             '添加形状            Dim textShape As IAutoShape =  presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle,New RectangleF(50,50,400,200))            textShape.ShapeStyle.LineColor.Color = Color.DarkGray            textShape.Fill.FillType = FillFormatType.None            '删除默认段落            textShape.TextFrame.Paragraphs.Clear()            '添加段落和文字            textShape.TextFrame.Paragraphs.Append(New TextParagraph())            textShape.TextFrame.Paragraphs(0).TextRanges.Append(New TextRange("文字对齐方式"))            textShape.TextFrame.Paragraphs(0).TextRanges(0).FontHeight = 20f            textShape.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("黑体")            textShape.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid            textShape.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black            '设置文字水平靠右            textShape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Right            '设置文字垂直靠下            textShape.TextFrame.AnchoringType = TextAnchorType.Bottom            '保存文档            presentation.SaveToFile("AlignText.pptx", FileFormat.Pptx2013)        End Sub    End ClassEnd Namespace

效果图:

国产PPT处理控件Spire.Presentation功能演示:在C#中设置 PPT 文字的对齐方式


还想要更多吗可以点击阅读【2020 · E-iceblue最新资源整合】查找需要的教程资源。是E-iceblue官方友好合作伙伴,如果您对spire.Presentation感兴趣,可以联系在线客服了解具体授权价格和使用机制。
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年6月1日
下一篇 2021年6月1日

相关推荐

发表回复

登录后才能评论