SlideUtil

Inheritance: java.lang.Object

public class SlideUtil

Offer methods which help to search shapes and text in a presentation.

Constructors

ConstructorDescription
SlideUtil()

Methods

MethodDescription
findShape(IPresentation pres, String altText)Find shape by alternative text in a PPTX presentation.
findShape(IBaseSlide slide, String altText)Find shape by alternative text on a slide in a PPTX presentation.
alignShapes(int alignmentType, boolean alignToSlide, IBaseSlide slide)Changes the placement of all shapes on the slide.
alignShapes(int alignmentType, boolean alignToSlide, IBaseSlide slide, int[] shapeIndexes)Changes the placement of selected shapes on the slide.
alignShapes(int alignmentType, boolean alignToSlide, IGroupShape groupShape)Changes the placement of all shapes within group shape.
alignShapes(int alignmentType, boolean alignToSlide, IGroupShape groupShape, int[] shapeIndexes)Changes the placement of selected shapes within group shape.
findAndReplaceText(IPresentation presentation, boolean withMasters, String find, String replace)Finds and replaces text in presentation with given format
findAndReplaceText(IPresentation presentation, boolean withMasters, String find, String replace, PortionFormat format)Finds and replaces text in presentation with given format
getAllTextBoxes(IBaseSlide slide)Returns all text frames on a slide in a PPTX presentation.
getAllTextFrames(IPresentation pres, boolean withMasters)Returns all text frames in a PPTX presentation.

SlideUtil()

public SlideUtil()

findShape(IPresentation pres, String altText)

public static IShape findShape(IPresentation pres, String altText)

Find shape by alternative text in a PPTX presentation.

Parameters:

ParameterTypeDescription
presIPresentationScanned presentation.
altTextjava.lang.StringAlternative text of a shape.

Returns: IShape - Shape or null.

findShape(IBaseSlide slide, String altText)

public static IShape findShape(IBaseSlide slide, String altText)

Find shape by alternative text on a slide in a PPTX presentation.

Parameters:

ParameterTypeDescription
slideIBaseSlideScanned slide.
altTextjava.lang.StringAlternative text of a shape.

Returns: IShape - Shape or null.

alignShapes(int alignmentType, boolean alignToSlide, IBaseSlide slide)

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

Parameters:

ParameterTypeDescription
alignmentTypeintDetermines which type of alignment will be applied.
alignToSlidebooleanIf true, shapes will be aligned relative to the slide edges.
slideIBaseSlideParent slide.

alignShapes(int alignmentType, boolean alignToSlide, IBaseSlide slide, int[] shapeIndexes)

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

Parameters:

ParameterTypeDescription
alignmentTypeintDetermines which type of alignment will be applied.
alignToSlidebooleanIf true, shapes will be aligned relative to the slide edges.
slideIBaseSlideParent slide.
shapeIndexesint[]Indexes of shapes to be aligned.

alignShapes(int alignmentType, boolean alignToSlide, IGroupShape groupShape)

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

Parameters:

ParameterTypeDescription
alignmentTypeintDetermines which type of alignment will be applied.
alignToSlidebooleanIf true, shapes will be aligned relative to the slide edges.
groupShapeIGroupShapeParent group shape.

alignShapes(int alignmentType, boolean alignToSlide, IGroupShape groupShape, int[] shapeIndexes)

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

Parameters:

ParameterTypeDescription
alignmentTypeintDetermines which type of alignment will be applied.
alignToSlidebooleanIf true, shapes will be aligned relative to the slide edges.
groupShapeIGroupShapeParent group shape.
shapeIndexesint[]Indexes of shapes to be aligned.

findAndReplaceText(IPresentation presentation, boolean withMasters, String find, String replace)

public static void findAndReplaceText(IPresentation presentation, boolean withMasters, String find, 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();
 }

Parameters:

ParameterTypeDescription
presentationIPresentationScanned presentation.
withMastersbooleanDetermines whether master slides should be scanned.
findjava.lang.StringString value to find.
replacejava.lang.StringString value to replace. character of the found string

findAndReplaceText(IPresentation presentation, boolean withMasters, String find, String replace, PortionFormat format)

public static void findAndReplaceText(IPresentation presentation, boolean withMasters, String find, 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();
 }

Parameters:

ParameterTypeDescription
presentationIPresentationScanned presentation.
withMastersbooleanDetermines whether master slides should be scanned.
findjava.lang.StringString value to find.
replacejava.lang.StringString value to replace.
formatPortionFormatFormat for replacing text portion. If null then will be used format of the first character of the found string

getAllTextBoxes(IBaseSlide slide)

public static ITextFrame[] getAllTextBoxes(IBaseSlide slide)

Returns all text frames on a slide in a PPTX presentation.

Parameters:

ParameterTypeDescription
slideIBaseSlideScanned slide.

Returns: com.aspose.slides.ITextFrame[] - Array of TextFrame objects.

getAllTextFrames(IPresentation pres, boolean withMasters)

public static ITextFrame[] getAllTextFrames(IPresentation pres, boolean withMasters)

Returns all text frames in a PPTX presentation.

Parameters:

ParameterTypeDescription
presIPresentationScanned presentation.
withMastersbooleanDetermines whether master slides should be scanned.

Returns: com.aspose.slides.ITextFrame[] - Array of TextFrame objects.