Slide Class
A presentation slide.
Declaration
public class Slide extends SlideElement
Remarks
To add a slide to a presentation:
- Create a
Slideobject. Specify a layout type in the constructor. - Add the slide to the presentation.
import com.devexpress.docs.presentation.*;
// Create a presentation.
Presentation presentation = new Presentation();
// Create a blank slide.
Slide slide = new Slide(SlideLayoutType.BLANK, "Slide_Name");
// Add the slide to the presentation.
presentation.getSlides().add(slide);
Refer to the following help topics for additional information and examples:
- Manage Slide
- Configure Slide Masters and Layouts
- Slide Size and Orientation
- Work with Shapes
- Slide Background
Inherited Members
Inheritance
Constructors
Slide(SlideLayout slideLayout, String name) Constructor
Initializes a new instance of the Slide class with the specified layout and name.
Declaration
public Slide(SlideLayout slideLayout, String name)
Parameters
| Name | Type | Description |
|---|---|---|
| slideLayout | SlideLayout | The slide layout. |
| name | String | The slide name. |
Slide(SlideLayout slideLayout) Constructor
Initializes a new instance of the Slide class with the specified layout.
Declaration
public Slide(SlideLayout slideLayout)
Parameters
| Name | Type | Description |
|---|---|---|
| slideLayout | SlideLayout | The slide layout. |
Remarks
The following code snippet obtains a title slide layout from the first slide master and creates a new slide based on this layout:
import com.devexpress.docs.presentation.*;
// Get the first slide master's title layout.
// Create the layout if it does not exist.
SlideLayout layout =
presentation.getSlideMasters()
.get(0)
.getLayouts()
.getOrCreate(SlideLayoutType.TITLE);
// Create a slide based on the layout.
Slide slide = new Slide(layout);
// Add the slide to the presentation.
presentation.getSlides().add(slide);
Refer to the following help topic for additional information: Configure Slide Masters and Layouts — Presentation API for Java.
Slide(SlideLayoutType slideLayoutType, String name) Constructor
Initializes a new instance of the Slide class with the specified layout type and name.
Declaration
public Slide(SlideLayoutType slideLayoutType, String name)
Parameters
| Name | Type | Description |
|---|---|---|
| slideLayoutType | SlideLayoutType | The slide layout type. |
| name | String | The slide name. |
Remarks
// Create a presentation.
try(Presentation presentation = new Presentation()) {
// Create a blank slide.
Slide slide = new Slide(SlideLayoutType.BLANK, "Slide_Name");
// Add the slide to the presentation.
presentation.getSlides().add(slide);
// Perform additional presentation processing logic.
}
Slide(SlideLayoutType slideLayoutType) Constructor
Initializes a new instance of the Slide class with the specified layout type.
Declaration
public Slide(SlideLayoutType slideLayoutType)
Parameters
| Name | Type | Description |
|---|---|---|
| slideLayoutType | SlideLayoutType | The slide layout type. |
Remarks
// Create a presentation.
try(Presentation presentation = new Presentation()) {
// Create a blank slide.
Slide slide = new Slide(SlideLayoutType.BLANK);
// Add the slide to the presentation.
presentation.getSlides().add(slide);
// Perform additional presentation processing logic.
}
Methods
deepClone() Method
Clones the current Slide instance.
Declaration
public Slide deepClone()
Returns
| Type | Description |
|---|---|
Slide |
The cloned |
findText(String text, TextSearchOptions options) Method
Finds all occurrences of the specified text in the slide using specified search options.
Declaration
public List<TextSearchInfo> findText(String text, TextSearchOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
| text | String | The text to search for. |
| options | TextSearchOptions | Search options. |
Returns
| Type | Description |
|---|---|
| java.util.List<TextSearchInfo> | A collection of search results for the specified text. |
Remarks
// Define search options.
TextSearchOptions options = new TextSearchOptions();
options.setMatchCase(false);
// Get the first slide.
Slide slide1 = presentation.getSlides().getFirst();
// Find all occurrences of the specified text on the slide.
List<TextSearchInfo> searchResults = slide.findText("PowerPoint", options);
findText(String text) Method
Searches the slide for all occurrences of the specified text.
Declaration
public List<TextSearchInfo> findText(String text)
Parameters
| Name | Type | Description |
|---|---|---|
| text | String | Text to find. |
Returns
| Type | Description |
|---|---|
| java.util.List<TextSearchInfo> | A collection of search results for the specified text. |
Remarks
// Get the first slide.
Slide slide1 = presentation.getSlides().getFirst();
// Find all occurrences of the specified text on the slide.
List<TextSearchInfo> searchResults = slide.findText("PowerPoint");
getLayout() Method
Returns the slide layout.
Declaration
public SlideLayout getLayout()
Returns
| Type | Description |
|---|---|
| SlideLayout | The slide layout. |
Remarks
Refer to the following help topic for additional information: Configure Slide Masters and Layouts — Presentation API for Java.
getNotes() Method
Returns slide notes.
Declaration
public NotesSlide getNotes()
Returns
| Type | Description |
|---|---|
| NotesSlide | Speaker notes. |
Remarks
The following code snippet updates the content and formatting of notes for the first slide:
// Get notes associated with the slide.
NotesSlide notes = slide.getNotes();
// Update the note content.
notes.getTextArea().setText("Updated key points and additional context for the presenter.");
// Create text formatting settings.
TextParagraphProperties paragraphProperties = new TextParagraphProperties();
paragraphProperties.getTextProperties().setBold(true);
// Apply formatting to the note content.
notes.getTextArea().setParagraphProperties(paragraphProperties);
notes.getTextArea().setLevel1ParagraphProperties(paragraphProperties);
Refer to the following help topic for additional information: Add Speaker Notes to Slides.
getVisible() Method
Returns whether the slide is visible.
Declaration
public boolean getVisible()
Returns
| Type | Description |
|---|---|
| boolean |
|
Remarks
The following code snippet traverses all slides in the presentation and makes any hidden slide visible:
for (Slide slide : presentation.getSlides()) {
if (!slide.getVisible()) {
slide.setVisible(true);
}
}
Refer to the following help topic for additional information: Manage Slide Visibility.
modifyTextProperties(List<TextSearchInfo> textSearchInfos, TextProperties properties) Method
Modifies text properties for the specified text ranges in the slide.
Declaration
public void modifyTextProperties(List<TextSearchInfo> textSearchInfos, TextProperties properties)
Parameters
| Name | Type | Description |
|---|---|---|
| textSearchInfos | java.util.List<TextSearchInfo> | A collection of text ranges whose properties are modified. |
| properties | TextProperties | Text properties to apply. |
Remarks
The following code snippet searches the specified slide for all occurrences of the specified text and highlights matching text ranges:
void highlightText(Slide slide, String searchText) {
// Create text properties to apply to the found text.
TextProperties textProperties = new TextProperties();
textProperties.setFill(new SolidFill(Color.getYellow()));
// Find all occurrences of the specified text on the slide.
// Apply text properties to all matching text ranges.
slide.modifyTextProperties(
slide.findText(searchText),
textProperties);
}
removeText(List<TextSearchInfo> textSearchInfos) Method
Removes the specified text ranges from the slide.
Declaration
public void removeText(List<TextSearchInfo> textSearchInfos)
Parameters
| Name | Type | Description |
|---|---|---|
| textSearchInfos | java.util.List<TextSearchInfo> | A collection of text ranges to remove. |
Remarks
The following code snippet finds all occurrences of the specified text on the slide and removes all matching text ranges:
public static void removeText(Slide slide, String searchText) {
slide.removeText(
slide.findText(searchText)
);
}
replaceText(List<TextSearchInfo> textSearchInfos, String newText) Method
Replaces the specified text ranges with new text.
Declaration
public void replaceText(List<TextSearchInfo> textSearchInfos, String newText)
Parameters
| Name | Type | Description |
|---|---|---|
| textSearchInfos | java.util.List<TextSearchInfo> | A collection of text ranges to replace. |
| newText | String | The replacement text. |
Remarks
The following code snippet finds all occurrences of “v25.2“ on the slide and replaces each matched text range with “v26.1“:
slide.replaceText(
slide.findText("v25.2"), "v26.1");
replaceText(String oldText, String newText, TextSearchOptions options) Method
Replaces matching text in the slide using specified search options.
Declaration
public void replaceText(String oldText, String newText, TextSearchOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
| oldText | String | The text to replace. |
| newText | String | The replacement text. |
| options | TextSearchOptions | Search options. |
Remarks
The following code snippet configures text search options and replaces all occurrences of “v25.2“ with “v26.1“ in the slide according to the specified matching rules:
// Configure search options for text replacement.
TextSearchOptions options = new TextSearchOptions();
options.setWholeWordOnly(false);
options.setMatchCase(true);
// Replace all occurrences of the specified text in the slide.
slide.replaceText("v25.2", "v26.1", options);
replaceText(String oldText, String newText) Method
Replaces matching text in the slide.
Declaration
public void replaceText(String oldText, String newText)
Parameters
| Name | Type | Description |
|---|---|---|
| oldText | String | The text to replace. |
| newText | String | The replacement text. |
Remarks
The following code snippet configures text search options and replaces all occurrences of “v25.2“ with “v26.1“ in the slide:
slide.replaceText("v25.2", "v26.1");
setLayout(SlideLayout value) Method
Sets the slide layout.
Declaration
public void setLayout(SlideLayout value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | SlideLayout | The slide layout. |
Remarks
Refer to the following help topic for additional information: Configure Slide Masters and Layouts — Presentation API for Java.
setNotes(NotesSlide value) Method
Sets the slide notes.
Declaration
public void setNotes(NotesSlide value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | NotesSlide | The slide notes. |
Remarks
The following code snippet adds a note to the first slide:
// Create a NotesSlide.
NotesSlide notes = new NotesSlide("slide1-notes");
// Specify notes content.
notes.getTextArea().setText("Key points and additional context for the presenter.");
// Get the first slide in the presentation.
Slide slide = presentation.getSlides().getFirst();
// Assign notes to the slide.
slide.setNotes(notes);
Refer to the following help topic for additional information: Add Speaker Notes to Slides.
setVisible(boolean value) Method
Sets whether the slide is visible.
Declaration
public void setVisible(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
The following code snippet traverses all slides in the presentation and makes any hidden slide visible:
for (Slide slide : presentation.getSlides()) {
if (!slide.getVisible()) {
slide.setVisible(true);
}
}
Refer to the following help topic for additional information: Manage Slide Visibility.