Java (485)
Evenly Distribute Rows and Columns in PowerPoint Table in Java
2021-06-22 03:35:14 Written by KoohjiThis article demonstrates how to evenly distribute the rows and columns of a PowerPoint table using Spire.Presentation for Java.
The input document:

import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.ITable;
import com.spire.presentation.Presentation;
public class DistributeRowsAndColumns {
public static void main(String []args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load the PowerPoint document
ppt.loadFromFile("Input.pptx");
//Get the first slide
ISlide slide = ppt.getSlides().get(0);
//Get the table in the slide
ITable table = (ITable) slide.getShapes().get(0);
//Distribute table rows
table.distributeRows(0,4);
//Distribute table columns
table.distributeColumns(0,4);
//Save the result document
ppt.saveToFile("DistributeRowsAndColumns.pptx", FileFormat.PPTX_2013);
}
The output document:

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);
}
}

PowerPoint to HTML conversion opens up opportunities for wider accessibility and enhanced interactivity. By transforming your presentations into HTML format, you can effortlessly distribute them across various platforms and devices. Whether you aim to share slides online or integrate them seamlessly within a web page, converting PowerPoint to HTML provides a flexible and versatile solution. In this article, we will explore how to convert PowerPoint files to HTML in Java using Spire.Presentation for Java.
- Convert a PowerPoint Presentation to HTML in Java
- Convert a Specific PowerPoint Slide to HTML in Java
Install Spire.Presentation for Java
First, 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>11.7.2</version>
</dependency>
</dependencies>
Convert a PowerPoint Presentation to HTML in Java
With Spire.Presentation for Java, you can convert PowerPoint files to HTML format in just three steps. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a sample PowerPoint document using Presentation.loadFromFile() method.
- Save the PowerPoint presentation as HTML using Presentation.saveToFile() method.
- Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
public class ToHtml {
public static void main(String[] args) throws Exception {
//Create a Presentation object
Presentation presentation = new Presentation();
//Load the sample document presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx");
//Save the document to HTML format presentation.saveToFile("C:\\Users\\Administrator\\Desktop\\ToHtml.html", FileFormat.HTML);
presentation.dispose();
}
}

Convert a Specific PowerPoint Slide to HTML in Java
Sometimes, it may be necessary to convert a single slide rather than the entire presentation to HTML. In such cases, Spire.Presentation for Java provides the ISlide.saveToFile() method for converting a PowerPoint slide to HTML format. The following are the detailed steps:
- Initialize an instance of the Presentation class.
- Load a sample PowerPoint document using Presentation.loadFromFile() method.
- Get the specific slide using Presentation.getSlides().get() method.
- Save the PowerPoint slide to HTML using ISlide.saveToFile() method.
- Java
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import com.spire.presentation.ISlide;
public class ConvertSpecificSlideToHtml { public static void main(String[] args) throws Exception {
// Create a Presentation object
Presentation presentation = new Presentation();
// Load the sample document presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pptx");
// Get the specific slide by index (e.g., index 0 for the second slide)
ISlide slide = presentation.getSlides().get(1);
// Save the specific slide to HTML format slide.saveToFile("C:\\Users\\Administrator\\Desktop\\SpecificSlideToHtml.html", FileFormat.HTML);
slide.dispose();
}
}

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.