public class SlideUtil
extends java.lang.Object
Offer methods which help to search shapes and text in a presentation.
| Constructor and Description |
|---|
SlideUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
alignShapes(int alignmentType,
boolean alignToSlide,
IBaseSlide slide)
Changes the placement of all shapes on the slide.
|
static void |
alignShapes(int alignmentType,
boolean alignToSlide,
IBaseSlide slide,
int[] shapeIndexes)
Changes the placement of selected shapes on the slide.
|
static void |
alignShapes(int alignmentType,
boolean alignToSlide,
IGroupShape groupShape)
Changes the placement of all shapes within group shape.
|
static void |
alignShapes(int alignmentType,
boolean alignToSlide,
IGroupShape groupShape,
int[] shapeIndexes)
Changes the placement of selected shapes within group shape.
|
static void |
findAndReplaceText(IPresentation presentation,
boolean withMasters,
java.lang.String find,
java.lang.String replace)
Finds and replaces text in presentation with given format
|
static void |
findAndReplaceText(IPresentation presentation,
boolean withMasters,
java.lang.String find,
java.lang.String replace,
PortionFormat format)
Finds and replaces text in presentation with given format
|
static IShape |
findShape(IBaseSlide slide,
java.lang.String altText)
Find shape by alternative text on a slide in a PPTX presentation.
|
static IShape |
findShape(IPresentation pres,
java.lang.String altText)
Find shape by alternative text in a PPTX presentation.
|
static IShape[] |
findShapesByPlaceholderType(IBaseSlide slide,
byte placeholderType)
Searches for all shapes on the specified slide that match the given placeholder type.
|
static ITextFrame[] |
getAllTextBoxes(IBaseSlide slide)
Returns all text frames on a slide in a PPTX presentation.
|
static ITextFrame[] |
getAllTextFrames(IPresentation pres,
boolean withMasters)
Returns all text frames in a PPTX presentation.
|
static ITextFrame[] |
getTextBoxesContainsText(IBaseSlide slide,
java.lang.String text,
boolean checkPlaceholderText)
Returns all text frames on the specified slide that contain the given text.
|
public static IShape findShape(IPresentation pres, java.lang.String altText)
Find shape by alternative text in a PPTX presentation.
pres - Scanned presentation.altText - Alternative text of a shape.public static IShape findShape(IBaseSlide slide, java.lang.String altText)
Find shape by alternative text on a slide in a PPTX presentation.
slide - Scanned slide.altText - Alternative text of a shape.public static IShape[] findShapesByPlaceholderType(IBaseSlide slide, byte placeholderType)
Searches for all shapes on the specified slide that match the given placeholder type.
slide - The slide to search for shapes.placeholderType - The type of placeholder to filter shapes by.IShape objects that match the specified placeholder type.public static void alignShapes(int alignmentType,
boolean alignToSlide,
IBaseSlide slide)
Changes the placement of all shapes on the slide. Aligns shapes to the margins or the edge of the slide or align them relative to each other.
Example:Presentation pres = new Presentation("pres.pptx"); try { SlideUtil.alignShapes(ShapesAlignmentType.AlignBottom, true, pres.getSlides().get_Item(0)); } finally { if (pres != null) pres.dispose(); }
alignmentType - Determines which type of alignment will be applied.alignToSlide - If true, shapes will be aligned relative to the slide edges.slide - Parent slide.public static void alignShapes(int alignmentType,
boolean alignToSlide,
IBaseSlide slide,
int[] shapeIndexes)
Changes the placement of selected shapes on the slide. Aligns shapes to the margins or the edge of the slide or align them relative to each other.
Example:Presentation pres = new Presentation("pres.pptx"); try { ISlide slide = pres.getSlides().get_Item(0); IShape shape1 = slide.getShapes().get_Item(0); IShape shape2 = slide.getShapes().get_Item(1); SlideUtil.alignShapes(ShapesAlignmentType.AlignBottom, false, pres.getSlides().get_Item(0), new int[] { slide.getShapes().indexOf(shape1), slide.getShapes().indexOf(shape2) }); } finally { if (pres != null) pres.dispose(); }
alignmentType - Determines which type of alignment will be applied.alignToSlide - If true, shapes will be aligned relative to the slide edges.slide - Parent slide.shapeIndexes - Indexes of shapes to be aligned.public static void alignShapes(int alignmentType,
boolean alignToSlide,
IGroupShape groupShape)
Changes the placement of all shapes within group shape. Aligns shapes to the margins or the edge of the slide or align them relative to each other.
Example:Presentation pres = new Presentation("pres.pptx"); try { ISlide slide = pres.getSlides().get_Item(0); SlideUtil.alignShapes(ShapesAlignmentType.AlignLeft, false, (GroupShape) slide.getShapes().get_Item(0)); } finally { if (pres != null) pres.dispose(); }
alignmentType - Determines which type of alignment will be applied.alignToSlide - If true, shapes will be aligned relative to the slide edges.groupShape - Parent group shape.public static void alignShapes(int alignmentType,
boolean alignToSlide,
IGroupShape groupShape,
int[] shapeIndexes)
Changes the placement of selected shapes within group shape. Aligns shapes to the margins or the edge of the slide or align them relative to each other.
Example:Presentation pres = new Presentation("pres.pptx"); try { ISlide slide = pres.getSlides().get_Item(0); SlideUtil.alignShapes(ShapesAlignmentType.AlignLeft, false, (GroupShape)slide.getShapes().get_Item(0), new int[] { 0, 2 }); } finally { if (pres != null) pres.dispose(); }
alignmentType - Determines which type of alignment will be applied.alignToSlide - If true, shapes will be aligned relative to the slide edges.groupShape - Parent group shape.shapeIndexes - Indexes of shapes to be aligned.public static void findAndReplaceText(IPresentation presentation, boolean withMasters, java.lang.String find, java.lang.String replace)
Finds and replaces text in presentation with given format
Presentation pres = new Presentation("pres.pptx"); try { PortionFormat format = new PortionFormat(); format.setFontHeight(24f); format.setFontItalic(NullableBool.True); format.getFillFormat().setFillType(FillType.Solid); format.getFillFormat().getSolidFillColor().setColor(Color.RED); SlideUtil.findAndReplaceText(pres, true, "[this block] ", "my text ", format); pres.save("replaced.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
presentation - Scanned presentation.withMasters - Determines whether master slides should be scanned.find - String value to find.replace - String value to replace.
character of the found stringpublic static void findAndReplaceText(IPresentation presentation, boolean withMasters, java.lang.String find, java.lang.String replace, PortionFormat format)
Finds and replaces text in presentation with given format
Presentation pres = new Presentation("pres.pptx"); try { PortionFormat format = new PortionFormat(); format.setFontHeight(24f); format.setFontItalic(NullableBool.True); format.getFillFormat().setFillType(FillType.Solid); format.getFillFormat().getSolidFillColor().setColor(Color.RED); SlideUtil.findAndReplaceText(pres, true, "[this block] ", "my text ", format); pres.save("replaced.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
presentation - Scanned presentation.withMasters - Determines whether master slides should be scanned.find - String value to find.replace - String value to replace.format - Format for replacing text portion. If null then will be used format of the first
character of the found stringpublic static ITextFrame[] getAllTextBoxes(IBaseSlide slide)
Returns all text frames on a slide in a PPTX presentation.
slide - Scanned slide.TextFrame objects.public static ITextFrame[] getTextBoxesContainsText(IBaseSlide slide, java.lang.String text, boolean checkPlaceholderText)
Returns all text frames on the specified slide that contain the given text.
slide - The slide to search.text - The text to search for within text frames.checkPlaceholderText - Indicates whether to include text frames that are empty, but whose placeholder text contains the search text.ITextFrame objects that contain the specified text.public static ITextFrame[] getAllTextFrames(IPresentation pres, boolean withMasters)
Returns all text frames in a PPTX presentation.
pres - Scanned presentation.withMasters - Determines whether master slides should be scanned.TextFrame objects.Copyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.