This article shows you how to set ASCII characters (special symbols) as bullet points in Word documents using Spire.Doc for Java.

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.documents.ListStyle;
import com.spire.doc.documents.ListType;
import com.spire.doc.documents.Paragraph;

public class SetBulletPoints {

    public static void main(String[] args) {

        //Create a Document object and add a section
        Document doc = new Document();
        Section section = doc.addSection();

        //Create four list styles based on different ASCII characters
        ListStyle listStyle1 = new ListStyle(doc, ListType.Bulleted);
        listStyle1.getLevels().get(0).setBulletCharacter("\u006e");
        listStyle1.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle1.setName("liststyle1");
        doc.getListStyles().add(listStyle1);
        ListStyle listStyle2 = new ListStyle(doc, ListType.Bulleted);
        listStyle2.getLevels().get(0).setBulletCharacter("\u0075");
        listStyle2.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle2.setName("liststyle2");
        doc.getListStyles().add(listStyle2);
        ListStyle listStyle3 = new ListStyle(doc, ListType.Bulleted);
        listStyle3.getLevels().get(0).setBulletCharacter("\u00b2");
        listStyle3.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle3.setName("liststyle3");
        doc.getListStyles().add(listStyle3);
        ListStyle listStyle4 = new ListStyle(doc, ListType.Bulleted);
        listStyle4 .getLevels().get(0).setBulletCharacter("\u00d8");
        listStyle4 .getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle4.setName("liststyle4");
        doc.getListStyles().add(listStyle4);

        //Add four paragraphs and apply list style separately
        Paragraph p1 = section.getBody().addParagraph();
        p1.appendText("Spire.Doc for .NET");
        p1.getListFormat().applyStyle(listStyle1.getName());
        Paragraph p2 = section.getBody().addParagraph();
        p2.appendText("Spire.PDF for .NET");
        p2.getListFormat().applyStyle(listStyle2.getName());
        Paragraph p3 = section.getBody().addParagraph();
        p3.appendText("Spire.XLS for .NET");
        p3.getListFormat().applyStyle(listStyle3.getName());
        Paragraph p4= section.getBody().addParagraph();
        p4.appendText("Spire.Presentation for .NET");
        p4.getListFormat().applyStyle(listStyle4.getName());

        //Save to file
        doc.saveToFile("SetBulletCharacter.docx", FileFormat.Docx);
    }
}

Set ASCII Characters as Bullet Points in Word in Java

Monday, 12 April 2021 07:05

Add an Endnote to Word in Java

This article shows you how to add an endnote to Word documents using Spire.Doc for Java.

import com.spire.doc.*;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.fields.Footnote;
import com.spire.doc.fields.TextRange;

import java.awt.*;

public class AddEndnote {

    public static void main(String[] args) {

        //Create a Document object
        Document doc = new Document();

        //Load the sample Word file
        doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.docx");

        //Get the first section
        Section section = doc.getSections().get(0);

        //Get the specific paragraph to add endnote
        Paragraph paragraph = section.getParagraphs().get(2);

        //Add an endnote
        Footnote endnote = paragraph.appendFootnote(FootnoteType.Endnote);

        //Set endnote text
        TextRange textRange = endnote.getTextBody().addParagraph().appendText("This is an endnote created by Spire.Doc.");

        //Set text format of endnote
        textRange.getCharacterFormat().setFontName("Arial");
        textRange.getCharacterFormat().setFontSize(13f);
        textRange.getCharacterFormat().setTextColor(Color.RED);

        //Save to file
        doc.saveToFile("AddEndnote.docx", FileFormat.Docx_2013);
    }
}

Add an Endnote to Word in Java

This article will demonstrate how to insert and remove shapes in Excel file using Spire.XLS for Java.

Add shapes to Excel worksheet:

import com.spire.xls.*;
import com.spire.xls.core.*;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class addShapestoExcel {
    public static void main(String[] args) throws Exception {

        String output = "output/AddShapesToExcelSheet.xlsx";

        //create a workbook.
        Workbook workbook = new Workbook();

        //get the first worksheet.
        Worksheet sheet = workbook.getWorksheets().get(0);

        //add a triangle shape.
        IPrstGeomShape triangle = sheet.getPrstGeomShapes().addPrstGeomShape(2, 2, 100, 100, PrstGeomShapeType.Triangle);
        //fill the triangle with solid color.
        triangle.getFill().setForeColor( Color.YELLOW);
        triangle.getFill().setFillType( ShapeFillType.SolidColor);

        //add a heart shape.
        IPrstGeomShape heart = sheet.getPrstGeomShapes().addPrstGeomShape(2, 5, 100, 100, PrstGeomShapeType.Heart);
        //fill the heart with gradient color.
        heart.getFill().setForeColor(Color.RED);
        heart.getFill().setFillType(ShapeFillType.Gradient);

        //add an arrow shape with default color.
        IPrstGeomShape arrow = sheet.getPrstGeomShapes().addPrstGeomShape(10, 2, 100, 100, PrstGeomShapeType.CurvedRightArrow);

        //add a cloud shape.
        IPrstGeomShape cloud = sheet.getPrstGeomShapes().addPrstGeomShape(10, 5, 100, 100, PrstGeomShapeType.Cloud);
        //fill the cloud with custom picture
        BufferedImage image = ImageIO.read(new File("SpireXls.png"));
        cloud.getFill().customPicture(image, "SpireXls.png");
        cloud.getFill().setFillType( ShapeFillType.Picture);

        //save to file.
        workbook.saveToFile(output, ExcelVersion.Version2013);
        }
}

Output:

Insert and remove shapes in Excel in Java

Remove a particular shape or all shapes from Excel worksheet:

import com.spire.xls.*;

public class removeShape {
    public static void main(String[] args) throws Exception {

                 //Load the sample file
                Workbook workbook = new Workbook();
                workbook.loadFromFile("output/AddShapesToExcelSheet.xlsx");

                //get the first worksheet.
                Worksheet sheet = workbook.getWorksheets().get(0);

                //delete the second shape in the worksheet
                sheet.getPrstGeomShapes().get(1).remove();

              /* //delete all shapes in the worksheet
                for (int i = sheet.getPrstGeomShapes().getCount()-1; i >= 0; i--)
                 {
                   sheet.getPrstGeomShapes().get(i).remove();
                 }*/

                //save to file.
                workbook.saveToFile("output/RemoveParticularShape.xlsx", ExcelVersion.Version2013);
            }
        }

Effective screenshot after remove the second shape from Excel worksheet:

Insert and remove shapes in Excel in Java

We have demonstrated how to add text and image header footer to Word document by using Spire.Doc for Java. This article will show you how to create different headers/footers for odd and even pages on Word document in Java applications.

import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.*;
import java.awt.*;

public class oddAndEvenHeaderFooter {
    public static void main(String[] args) throws Exception {

        String input = "multiPages.docx";
        String output = "output/oddAndEvenHeaderFooter.docx";

        //load the document
        Document doc = new Document();
        doc.loadFromFile(input);

        //get the first section
        Section section = doc.getSections().get(0);

        //set the DifferentOddAndEvenPagesHeaderFooter property as true
        section.getPageSetup().setDifferentOddAndEvenPagesHeaderFooter(true);

        //add odd header
        Paragraph P3 = section.getHeadersFooters().getOddHeader().addParagraph();
        TextRange OH = P3.appendText("Odd Header");
        P3.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
        OH.getCharacterFormat().setFontName("Arial");
        OH.getCharacterFormat().setFontSize(14);
        OH.getCharacterFormat().setTextColor(Color.BLUE);

        //add even header
        Paragraph P4 = section.getHeadersFooters().getEvenHeader().addParagraph();
        TextRange EH = P4.appendText("Even Header from E-iceblue Using Spire.Doc");
        P4.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
        EH.getCharacterFormat().setFontName("Arial");
        EH.getCharacterFormat().setFontSize(14);
        EH.getCharacterFormat().setTextColor(Color.GREEN);

        //add odd footer
        Paragraph P2 = section.getHeadersFooters().getOddFooter().addParagraph();
        TextRange OF = P2.appendText("Odd Footer");
        P2.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
        OF.getCharacterFormat().setFontName("Arial");
        OF.getCharacterFormat().setFontSize(14);
        OF.getCharacterFormat().setTextColor(Color.BLUE);

        //add even footer
        Paragraph P1 = section.getHeadersFooters().getEvenFooter().addParagraph();
        TextRange EF = P1.appendText("Even Footer from E-iceblue Using Spire.Doc");
        EF.getCharacterFormat().setFontName("Arial");
        EF.getCharacterFormat().setFontSize(14);
        P1.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
        EF.getCharacterFormat().setTextColor(Color.GREEN);

        //save the document
        doc.saveToFile(output, FileFormat.Docx);

    }
}

Output:

Java Add different headers/footers for odd and even pages on Word

This article shows you how to create a chart in PowerPoint using the data from an existing Excel document. This solution relies on Spire.Office.jar. Please download the latest version from here and add it as a dependency in your project.

Below is a screenshot of the Excel document.

Create PowerPoint Chart from Excel Data in Java

import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import com.spire.presentation.SlideSizeType;
import com.spire.presentation.charts.ChartStyle;
import com.spire.presentation.charts.ChartType;
import com.spire.presentation.charts.IChart;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

import java.awt.geom.Rectangle2D;

public class CreateChartFromExcelData {

    public static void main(String[] args) throws Exception {

        //Create a Presentation object
        Presentation presentation = new Presentation();
        presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9);

        //Add a clustered column chart to slide
        Rectangle2D rect = new Rectangle2D.Float(200, 100, 550, 320);
        IChart chart = presentation.getSlides().get(0).getShapes().appendChart(ChartType.COLUMN_CLUSTERED,rect);

        //Clear the default dummy data
        chart.getChartData().clear(0,0,5,5 );

        //Load an existing Excel file to Workbook object
        Workbook wb = new Workbook();
        wb.loadFromFile("C:\\Users\\Administrator\\Desktop\\data.xlsx");

        //Get the first worksheet
        Worksheet sheet = wb.getWorksheets().get(0);

        //Import data from the sheet to chart table
        for (int r = 0; r < sheet.getAllocatedRange().getRowCount(); r++)
        {
            for (int c = 0; c < sheet.getAllocatedRange().getColumnCount(); c++)
            {
                chart.getChartData().get(r,c).setValue(sheet.getCellRange(r+1, c+1).getValue2());
            }
        }

        //Add chart title
        chart.getChartTitle().getTextProperties().setText("Male/Female Ratio Per Dept.");
        chart.getChartTitle().getTextProperties().isCentered(true);
        chart.getChartTitle().setHeight(25f);
        chart.hasTitle(true);

        //Set the series label
        chart.getSeries().setSeriesLabel(chart.getChartData().get("B1","C1"));

        //Set the category labels
        chart.getCategories().setCategoryLabels(chart.getChartData().get("A2","A5"));

        //Set the series values
        chart.getSeries().get(0).setValues(chart.getChartData().get("B2","B5"));
        chart.getSeries().get(1).setValues(chart.getChartData().get("C2", "C5"));

        //Apply built-in chart style
        chart.setChartStyle(ChartStyle.STYLE_11);

        //Set overlap
        chart.setOverLap(-50);

        //Set gap width
        chart.setGapWidth(200);

        //Save to file
        presentation.saveToFile("output/Chart.pptx", FileFormat.PPTX_2013);
    }
}

Create PowerPoint Chart from Excel Data in Java

Tuesday, 30 March 2021 02:37

Save PowerPoint Shapes as Images in Java

This article shows you how to export shapes in a specific slide as images using Spire.Presentation for Java. Below is a screenshot of the sample PowerPoint document.

Save PowerPoint Shapes as Images in Java

import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

public class SaveShapeAsImage {

    public static void main(String[] args) throws Exception {

        //Create a Presentation object
        Presentation presentation = new Presentation();

        //Load the sample PowerPoint file
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\chart and table.pptx");

        //Get the first slide
        ISlide slide = presentation.getSlides().get(0);

        //Declare a BufferedImage variable
        BufferedImage image;

        //Loop through the shapes in the slide
        for (int i = 0; i < slide.getShapes().getCount(); i++) {

            //Save the specific shape as image data
            image = slide.getShapes().saveAsImage(i);

            //Write data to png file
            File file = new File(String.format("ToImage-%d.png", i));
            ImageIO.write(image, "PNG", file);
        }
    }
}

Output

Save PowerPoint Shapes as Images in Java

Wednesday, 16 November 2022 08:56

Java: Add or Delete Digital Signatures in Excel

A digital signature is an electronic signature with encrypted information that helps verify the authenticity of messages, software and digital documents. They are commonly used in software distribution, financial transactions, contract management software, and other situations that require forgery or tampering detection. When generating an Excel report, you may need to add a digital signature to make it look more authentic and official. In this article, you will learn how to add or delete digital signatures in Excel in Java using Spire.XLS for Java.

Install Spire.XLS for Java

First of all, you're required to add the Spire.Xls.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls</artifactId>
        <version>14.4.1</version>
    </dependency>
</dependencies>
    

Add a Digital Signature to Excel in Java

You can add a digital signature to protect the integrity of an Excel file. Once the digital signature is added, the file becomes read-only to discourage further editing. If someone makes changes to the file, the digital signature will become invalid immediately.

Spire.XLS for Java provides the addDigitalSignature method of Workbook class to add digital signatures to an Excel file. The detailed steps are as follows:

  • Instantiate a Workbook instance.
  • Load an Excel file using Workbook.loadFromFile() method.
  • Instantiate a CertificateAndPrivateKey instance with the specified certificate (.pfx) file path and the password of the .pfx file.
  • Add a digital signature to the file using Workbook.addDigitalSignature(CertificateAndPrivateKey, String, Date) method.
  • Save the result file using Workbook.saveToFile() method.
  • Java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.digital.CertificateAndPrivateKey;

import java.util.Date;

public class AddDigitalSignature {
    public static void main(String []args) throws Exception {
        //Create a Workbook instance
        Workbook workbook=new Workbook();
        //Load an Excel file
        workbook.loadFromFile("Sample.xlsx");

        //Add a digital signature to the file
        CertificateAndPrivateKey cap = new CertificateAndPrivateKey("Test.pfx","e-iceblue");
        workbook.addDigitalSignature(cap, "e-iceblue",new Date());

        //Save the result file
        workbook.saveToFile("AddDigitalSignature.xlsx", ExcelVersion.Version2013);
    }
}

Java: Add or Delete Digital Signatures in Excel

Delete Digital Signature from Excel in Java

Spire.XLS for Java provides the removeAllDigitalSignatures method of Workbook class for developers to remove digital signatures from an Excel file. The detailed steps are as follows:

  • Initialize an instance of the Workbook class.
  • Load an Excel file using Workbook.loadFromFile() method.
  • Remove all digital signatures from the file using Workbook.removeAllDigitalSignatures() method.
  • Save the result file using Workbook.saveToFile() method.
  • Java
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;

public class DeleteDigitalSignature {
    public static void main(String []args) throws Exception {
        //Create a Workbook instance
        Workbook workbook = new Workbook();
        //Load an Excel file
        workbook.loadFromFile("AddDigitalSignature.xlsx");

        //Remove all digital signatures in the file
        workbook.removeAllDigitalSignatures();

        //Save the result file
        workbook.saveToFile("RemoveDigitalSignature.xlsx", ExcelVersion.Version2013);
    }
}

Java: Add or Delete Digital Signatures in Excel

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Tuesday, 09 March 2021 08:38

Set Table Alignment in Slides in Java

This article demonstrates how to horizontally and vertically align a table in a slide using Spire.Presentation for Java.

Below is a screenshot of the sample document.

Set Table Alignment in Slides in Java

import com.spire.presentation.FileFormat;
import com.spire.presentation.ITable;
import com.spire.presentation.Presentation;
import com.spire.presentation.ShapeAlignmentEnum;

public class AlignTable {

    public static void main(String[] args) throws Exception {

        //Create a Presentation object
        Presentation presentation = new Presentation();

        //Load the sample PowerPoint document contain
        presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx");

        //Declare a ITable variable
        ITable table = null;

        //Loop through the shapes in the first slide
        for (Object shape: presentation.getSlides().get(0).getShapes()
             ) {

            //Check if shape is an instance of ITable
            if (shape instanceof ITable)
            {
                //Convert shape to table
                table =(ITable)shape;
            }
        }

        //Horizontally align table to center
        table.setShapeAlignment(ShapeAlignmentEnum.ShapeAlignment.AlignCenter);

        //Vertically align table to middle
        table.setShapeAlignment(ShapeAlignmentEnum.ShapeAlignment.AlignMiddle);

        //Save to file
        presentation.saveToFile("AlignTable.pptx", FileFormat.PPTX_2013);
    }
}

Set Table Alignment in Slides in Java

Suppose there are two PowerPoint documents, and you want to copy a certain slide from one document to a specified location of the other. Manual copying and pasting is an option, but the quicker and more efficient way is to use Java codes for automatic operation. This article will show you how to programmatically copy slides between two different PowerPoint documents using Spire.Presentation for Java.

Install Spire.Presentation for Java

First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.presentation</artifactId>
        <version>9.4.5</version>
    </dependency>
</dependencies>
    

Copy Slides Between Two PowerPoint Documents

The following are detailed steps to copy a slide from one PowerPoint document to a specified position or the end of the other document.

  • Create a Presentation object and load one sample document using Presentation.loadFromFile() method.
  • Create another Presentation object and load the other sample document using Presentation.loadFromFile() method.
  • Get a specific slide of document one using Presentation.getSlides().get() method and insert its copy into the specified position of document two using Presentation.getSlides().insert() method.
  • Get another specific slide of document one using Presentation.getSlides().get() method and add its copy to the end of document two using Presentation.getSlides().append() method.
  • Save the document two to another file using Presentation.saveToFile() method.
  • Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;

public class CopySlidesBetweenPPT {
    public static void main(String[] args) throws Exception {
        //Create a Presentation object to load one sample document
        Presentation pptOne= new Presentation();
        pptOne.loadFromFile("C:\\Users\\Test1\\Desktop\\sample1.pptx");

        //Create another Presentation object to load the other sample document
        Presentation pptTwo = new Presentation();
        pptTwo.loadFromFile("C:\\Users\\Test1\\Desktop\\sample2.pptx");

        //Insert the specific slide from document one into the specified position of document two
        pptTwo.getSlides().insert(0,pptOne.getSlides().get(0));

        //Append the specific slide of document one to the end of document two
        pptTwo.getSlides().append(pptOne.getSlides().get(3));

        //Save the document two to another file
        pptTwo.saveToFile("output/CopySlidesBetweenPPT.pptx", FileFormat.PPTX_2013);
    }
}

Java: Copy Slides Between Two PowerPoint Documents

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Tuesday, 23 February 2021 07:30

Add multiple watermarks in presentation slides

Spire.Presentation supports to insert text watermark and image watermark to PowerPoint document. This article will show you how to use Spire.Presentation to add multiple watermarks to the presentation slides in C#/VB.NET.

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)
        {
            //Create a PPT document and load file
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("Sample.pptx");

            //Get the size of the watermark string
            Font font = new Font("Arial", 20);
            String watermarkText = "E-iceblue";
            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++)
                {
                    //Define a rectangle range
                    RectangleF rect = new RectangleF(x, y, size.Width, size.Height);

                    //Add a rectangle shape with a defined range
                    IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(Spire.Presentation.ShapeType.Rectangle, rect);

                    //Set the style of the shape
                    shape.Fill.FillType = FillFormatType.None;
                    shape.ShapeStyle.LineColor.Color = Color.White;
                    shape.Rotation = -45;
                    shape.Locking.SelectionProtection = true;
                    shape.Line.FillType = FillFormatType.None;

                    //Add text to the shape
                    shape.TextFrame.Text = watermarkText;
                    TextRange textRange = shape.TextFrame.TextRange;
                    //Set the style of the text range
                    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);
            }

            //Save the document
            presentation.SaveToFile("Watermark_result.pptx", FileFormat.Pptx2010);

        }
    }
}
VB.NET
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace WatermarkDemo
    
    Class Program
        
        Private Shared Sub Main(ByVal args() As String)
            'Create a PPT document and load file
            Dim presentation As Presentation = New Presentation
            presentation.LoadFromFile("Sample.pptx")
            'Get the size of the watermark string
            Dim font As Font = New Font("Arial", 20)
            Dim watermarkText As String = "E-iceblue"
            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)
                    'Define a rectangle range
                    Dim rect As RectangleF = New RectangleF(x, y, size.Width, size.Height)
                    'Add a rectangle shape with a defined range
                    Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(Spire.Presentation.ShapeType.Rectangle, rect)
                    'Set the style of the shape
                    shape.Fill.FillType = FillFormatType.None
                    shape.ShapeStyle.LineColor.Color = Color.White
                    shape.Rotation = -45
                    shape.Locking.SelectionProtection = true
                    shape.Line.FillType = FillFormatType.None
                    'Add text to the shape
                    shape.TextFrame.Text = watermarkText
                    Dim textRange As TextRange = shape.TextFrame.TextRange
                    'Set the style of the text range
                    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
            
            'Save the document
            presentation.SaveToFile("Watermark_result.pptx", FileFormat.Pptx2010)
        End Sub
    End Class
End Namespace

Output:

Add multiple watermarks in presentation slides