Footer is area in the bottom of each slide in a PPT document. The Spire.Presentation supports user to insert text or graphics in footer. For example, you can add slide numbers, the time and date, a company logo, the document title or the file name, or the author's name in document.
Spire.Presentation for .NET, a reliable .NET PPT component, enables you to generate, read, edit, convert even print your PPT document in a fast speed. Using Spire.Presentation for .NET, you can add footer in your PPT document with C#, VB. Please see the target PPT document with footer as below picture:
This guide will introduce the method to add footer in your PPT document with C#, VB.NET via Spire.Presentation for .NET.
The method main steps are:
Step 1: create a PPT document.
Presentation presentation = new Presentation();
Step 2: set background Image and slide.
string ImageFile = @"bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
Step 3: add and set the footer and set whether show date and page number.
presentation.SetFooterText("Demo of Spire.Presentation"); presentation.SetFooterVisible(true); presentation.SetSlideNoVisible(true); presentation.SetDateTimeVisible(true);
Step 4: save the document.
presentation.SaveToFile("HeaderAndFooter.pptx", FileFormat.Pptx2007);
Download and install Spire.Presentation for .NET and use below code to experience this method to add footer in PPT document.
The full code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using Spire.Presentation; using Spire.Presentation.Drawing; namespace AddheadersAndfooters { class Program { static void Main(string[] args) { //create PPT document Presentation presentation = new Presentation(); //set background Image string ImageFile = @"bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite; //add footer presentation.SetFooterText("Demo of Spire.Presentation"); //set the footer visible presentation.SetFooterVisible(true); //set the page number visible presentation.SetSlideNoVisible(true); //set the date visible presentation.SetDateTimeVisible(true); //append new shape IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 600, 250)); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("The sample demonstrates how to use Footer."); //append new Paragraph shape.TextFrame.Paragraphs.Append(new TextParagraph()); //add text to Paragraph shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components.")); //set the Font foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold"); para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; para.Indent = 35; } //save the document presentation.SaveToFile("HeaderAndFooter.pptx", FileFormat.Pptx2007); System.Diagnostics.Process.Start("HeaderAndFooter.pptx"); } } }
Imports System.Drawing Imports Spire.Presentation.Drawing Imports Spire.Presentation Module Module1 Sub Main() 'create PPT document Dim presentation As New Presentation() 'set background Image Dim ImageFile As String = "D:\Spire.Presentation\Demos\Data\bg.png" Dim rect As New RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height) presentation.Slides(0).Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect) presentation.Slides(0).Shapes(0).Line.FillFormat.SolidFillColor.Color = Color.FloralWhite 'add footer presentation.SetFooterText("Demo of Spire.Presentation") 'set the footer visible presentation.SetFooterVisible(True) 'set the page number visible presentation.SetSlideNoVisible(True) 'set the date visible presentation.SetDateTimeVisible(True) 'append new shape Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 70, 600, 250)) shape.ShapeStyle.LineColor.Color = Color.White shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None 'add text to shape shape.AppendTextFrame("The sample demonstrates how to use Footer.") 'append new Paragraph shape.TextFrame.Paragraphs.Append(New TextParagraph()) 'add text to Paragraph shape.TextFrame.Paragraphs(1).TextRanges.Append(New TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components.")) 'set the Font For Each para As TextParagraph In shape.TextFrame.Paragraphs para.TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold") para.TextRanges(0).Fill.FillType = FillFormatType.Solid para.TextRanges(0).Fill.SolidColor.Color = Color.Black para.Alignment = TextAlignmentType.Left para.Indent = 35 Next 'save the document presentation.SaveToFile("HeaderAndFooter.pptx", FileFormat.Pptx2007) System.Diagnostics.Process.Start("HeaderAndFooter.pptx") End Sub End Module
If you couldn't successfully use the Spire.presentation, please refer the Spire.Presentation Quick Start which can guide you quickly use the Spire.presentation.