Apply Transparency to Text in PowerPoint in Java

This article demonstrates how to apply transparency to text in PowerPoint using Spire.Presentation for Java.

import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;

import java.awt.*;
import java.awt.geom.Rectangle2D;

public class ApplyTransparency {

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

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

        //Add a shape
        IAutoShape textbox = presentation .getSlides().get(0).getShapes().appendShape(ShapeType.RECTANGLE,new Rectangle2D.Float(50, 70, 300, 120));
        textbox.getShapeStyle().getLineColor().setColor(new Color(1,1,1,0));
        textbox.getFill().setFillType(FillFormatType.NONE);

        //Remove default paragraphs
        textbox.getTextFrame().getParagraphs().clear();

        //Add three paragraphs and apply colors with different alpha values to the text
        int alpha = 55;
        for (int i = 0; i < 3; i++)
        {
            textbox.getTextFrame().getParagraphs().append(new ParagraphEx());
            textbox.getTextFrame().getParagraphs().get(i).getTextRanges().append(new PortionEx("Text Transparency"));
            textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().setFillType(FillFormatType.NONE);
            textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID);
            textbox.getTextFrame().getParagraphs().get(i).getTextRanges().get(0).getFill().getSolidColor().setColor(new Color(176, 48, 96, alpha));
            alpha += 100;
        }

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

Apply Transparency to Text in PowerPoint in Java