国产PPT格式控件Spire.Presentation功能演示:添加多行多列文本水印至PPT文档

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

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


C#

using Spire.Presentation;using Spire.Presentation.Drawing;using System;using System.Drawing;using System.Windows.Forms;namespace WatermarkDemo{    class Program    {        static void Main(string[] args)        {            //加载示例文档            Presentation presentation = new Presentation();            presentation.LoadFromFile("Sample.pptx");            //获取文本的大小            Font font = new Font("宋体", 20);            String watermarkText = "冰蓝科技";            SizeF size = TextRenderer.MeasureText("E-iceblue", font);            float x = 30;            float y = 80;            for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { //绘制文本,设置文本格式并将其添加到第一张幻灯片 RectangleF rect = new RectangleF(x, y, size.Width, size.Height); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(Spire.Presentation.ShapeType.Rectangle, rect); shape.Fill.FillType = FillFormatType.None; shape.ShapeStyle.LineColor.Color = Color.White; shape.Rotation = -45; shape.Locking.SelectionProtection = true; shape.Line.FillType = FillFormatType.None; shape.TextFrame.Text = watermarkText; TextRange textRange = shape.TextFrame.TextRange; textRange.Fill.FillType = FillFormatType.Solid; textRange.Fill.SolidColor.Color = Color.FromArgb(120, Color.HotPink); textRange.EastAsianFont = new TextFont(font.Name); textRange.FontHeight = font.Size; x += (100 + size.Width); } x = 30; y += (100 + size.Height); } //保存文档 presentation.SaveToFile("Watermark_result.pptx", FileFormat.Pptx2010); } } }

VB.NET

Imports Spire.PresentationImports Spire.Presentation.DrawingImports SystemImports System.DrawingImports System.Windows.FormsNamespace WatermarkDemo     Class Program        Private Shared Sub Main(ByVal args() As String)            '加载示例文档            Dim presentation As Presentation = New Presentation            presentation.LoadFromFile("Sample.pptx")            '获取文本大小            Dim font As Font = New Font("宋体", 20)            Dim watermarkText As String = "冰蓝科技"            Dim size As SizeF = TextRenderer.MeasureText("E-iceblue", font)            Dim x As Single = 30            Dim y As Single = 80            Dim i As Integer = 0            Do While (i < 3) Dim j As Integer = 0 Do While (j < 3) '绘制文本,设置文本格式并将其添加到第一张幻灯片 Dim rect As RectangleF = New RectangleF(x, y, size.Width, size.Height) Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(Spire.Presentation.ShapeType.Rectangle, rect) shape.Fill.FillType = FillFormatType.None shape.ShapeStyle.LineColor.Color = Color.White shape.Rotation = -45 shape.Locking.SelectionProtection = true shape.Line.FillType = FillFormatType.None shape.TextFrame.Text = watermarkText Dim textRange As TextRange = shape.TextFrame.TextRange textRange.Fill.FillType = FillFormatType.Solid textRange.Fill.SolidColor.Color = Color.FromArgb(120, Color.HotPink) textRange.EastAsianFont = New TextFont(font.Name) textRange.FontHeight = font.Size x = (x + (100 + size.Width)) j = (j + 1) Loop x = 30 y = (y + (100 + size.Height)) i = (i + 1) Loop '保存文档 presentation.SaveToFile("Watermark_result.pptx", FileFormat.Pptx2010) End Sub End Class End Namespace

效果图:

国产PPT格式控件Spire.Presentation功能演示:替换 PPT 中的视频、音频文件

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

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

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

相关推荐

发表回复

登录后才能评论