SlideUtil
Inheritance: java.lang.Object
public class SlideUtil
Offer methods which help to search shapes and text in a presentation.
Constructors
Constructor | Description |
---|---|
SlideUtil() |
Methods
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:
Parameter | Type | Description |
---|---|---|
pres | IPresentation | Scanned presentation. |
altText | java.lang.String | Alternative 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:
Parameter | Type | Description |
---|---|---|
slide | IBaseSlide | Scanned slide. |
altText | java.lang.String | Alternative text of a shape. |
Returns: IShape - Shape or null.
alignShapes(int alignmentType, boolean alignToSlide, IShapeCollection shapes)
public static void alignShapes(int alignmentType, boolean alignToSlide, IShapeCollection shapes)
Changes the placement of all shapes in the collection. 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).getShapes()); } finally { if (pres != null) pres.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
alignmentType | int | Determines which type of alignment will be applied. |
alignToSlide | boolean | If true, shapes will be aligned relative to the slide edges |
shapes | IShapeCollection | Shapes collection to be aligned |
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:
Parameter | Type | Description |
---|---|---|
alignmentType | int | Determines which type of alignment will be applied. |
alignToSlide | boolean | If true, shapes will be aligned relative to the slide edges. |
slide | IBaseSlide | Parent 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:
Parameter | Type | Description |
---|---|---|
alignmentType | int | Determines which type of alignment will be applied. |
alignToSlide | boolean | If true, shapes will be aligned relative to the slide edges. |
slide | IBaseSlide | Parent slide. |
shapeIndexes | int[] | 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:
Parameter | Type | Description |
---|---|---|
alignmentType | int | Determines which type of alignment will be applied. |
alignToSlide | boolean | If true, shapes will be aligned relative to the slide edges. |
groupShape | IGroupShape | Parent 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:
Parameter | Type | Description |
---|---|---|
alignmentType | int | Determines which type of alignment will be applied. |
alignToSlide | boolean | If true, shapes will be aligned relative to the slide edges. |
groupShape | IGroupShape | Parent group shape. |
shapeIndexes | int[] | 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:
Parameter | Type | Description |
---|---|---|
presentation | IPresentation | Scanned presentation. |
withMasters | boolean | Determines whether master slides should be scanned. |
find | java.lang.String | String value to find. |
replace | java.lang.String | String value to replace. |
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:
Parameter | Type | Description |
---|---|---|
presentation | IPresentation | Scanned presentation. |
withMasters | boolean | Determines whether master slides should be scanned. |
find | java.lang.String | String value to find. |
replace | java.lang.String | String value to replace. |
format | PortionFormat | Format 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:
Parameter | Type | Description |
---|---|---|
slide | IBaseSlide | Scanned 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:
Parameter | Type | Description |
---|---|---|
pres | IPresentation | Scanned presentation. |
withMasters | boolean | Determines whether master slides should be scanned. |
Returns: com.aspose.slides.ITextFrame[] - Array of TextFrame objects.