SlideCollection

Inheritance: java.lang.Object, com.aspose.slides.DomObject

All Implemented Interfaces: com.aspose.slides.ISlideCollection

public final class SlideCollection extends DomObject<Presentation> implements ISlideCollection

Represents a collection of a slides.

Methods

Method Description
size() Gets the number of elements actually contained in the collection.
get_Item(int index) Gets the element at the specified index.
addClone(ISlide sourceSlide) Adds a copy of a specified slide to the end of the collection.
addClone(ISlide sourceSlide, ISection section) Adds a copy of a specified slide to the end of the specified section.
insertClone(int index, ISlide sourceSlide) Inserts a copy of a specified slide to specified position of the collection.
addEmptySlide(ILayoutSlide layout) Adds a new empty slide to the end of the collection.
insertEmptySlide(int index, ILayoutSlide layout) Inserts a copy of a specified slide to specified position of the collection.
addClone(ISlide sourceSlide, ILayoutSlide destLayout) Adds a copy of a specified slide to the end of the collection.
insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout) Inserts a copy of a specified slide to specified position of the collection.
addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout) Adds a copy of a specified source slide to the end of the collection.
insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout) Inserts a copy of a specified source slide to specified position of the collection.
remove(ISlide value) Removes the first occurrence of a specific object from the collection.
removeAt(int index) Removes the element at the specified index of the collection.
iterator() Returns an enumerator that iterates through the collection.
iteratorJava() Returns a java iterator for the entire collection.
toArray() Creates and returns an array with all slides in it.
toArray(int startIndex, int count) Creates and returns an array with all slides from the specified range in it.
reorder(int index, ISlide slide) Moves slide from the collection to the specified position.
reorder(int index, ISlide[] slides) Moves slides from the collection to the specified position.
indexOf(ISlide slide) Returns an index of the specified slide in the collection.
addFromPdf(String path) Creates slides from the PDF document and adds them to the end of the collection.
addFromPdf(InputStream pdfStream) Creates slides from the PDF document and adds them to the end of the collection.
addFromHtml(String htmlText, IExternalResourceResolver resolver, String uri) Creates slides from HTML text and adds them to the end of the collection.
addFromHtml(String htmlText) Creates slides from HTML text and adds them to the end of the collection.
addFromHtml(InputStream htmlStream, IExternalResourceResolver resolver, String uri) Creates slides from HTML text and adds them to the end of the collection.
addFromHtml(InputStream htmlStream) Creates slides from HTML text and adds them to the end of the collection.
insertFromHtml(int index, String htmlText, IExternalResourceResolver resolver, String uri) Creates slides from HTML text and inserts them to the collection at the specified position.
insertFromHtml(int index, String htmlText) Creates slides from HTML text and inserts them to the collection at the specified position.
insertFromHtml(int index, InputStream htmlStream, IExternalResourceResolver resolver, String uri) Creates slides from HTML text and inserts them to the collection at the specified position.
insertFromHtml(int index, InputStream htmlStream) Creates slides from HTML text and inserts them to the collection at the specified position.
copyTo(System.Array array, int index) Copies all elements from the collection to the specified array.
isSynchronized() Returns a value indicating whether access to the collection is synchronized (thread-safe).
getSyncRoot() Returns a synchronization root.

size()

public final int size()

Gets the number of elements actually contained in the collection. Read-only int.

Returns: int

get_Item(int index)

public final ISlide get_Item(int index)

Gets the element at the specified index. Read-only Slide.

Parameters:

Parameter Type Description
index int

Returns: ISlide

addClone(ISlide sourceSlide)

public final ISlide addClone(ISlide sourceSlide)

Adds a copy of a specified slide to the end of the collection.

Parameters:

Parameter Type Description
sourceSlide ISlide Slide to clone.

When cloning a slide between different presentations slide’s master can be cloned too. Internal registry is used to track automatically cloned masters to prevent creation of multiple clones of the same master slide. Manual cloning of master slides will be neither prevented nor registered. If you need more control over cloning process use #addClone(ISlide,ILayoutSlide).addClone(ISlide,ILayoutSlide) or #addClone(ISlide,IMasterSlide,boolean).addClone(ISlide,IMasterSlide,boolean) for cloning slides, IGlobalLayoutSlideCollection.addClone(ILayoutSlide) or IGlobalLayoutSlideCollection.addClone(ILayoutSlide,IMasterSlide) for cloning layouts and IMasterSlideCollection.addClone(IMasterSlide) for cloning masters. |

Returns: ISlide - New slide.

addClone(ISlide sourceSlide, ISection section)

public final ISlide addClone(ISlide sourceSlide, ISection section)

Adds a copy of a specified slide to the end of the specified section.


IPresentation presentation = new Presentation();
 try
 {
     presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 50, 300, 100);
     presentation.getSections().addSection("Section 1", presentation.getSlides().get_Item(0));
     
     ISection section2 = presentation.getSections().appendEmptySection("Section 2");
     presentation.getSlides().addClone(presentation.getSlides().get_Item(0), section2);
     
     // Now the second section contains a copy of the first slide.
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

Parameter Type Description
sourceSlide ISlide Slide to clone.
section ISection Section for a new slide.

Returns: ISlide - New slide.

insertClone(int index, ISlide sourceSlide)

public final ISlide insertClone(int index, ISlide sourceSlide)

Inserts a copy of a specified slide to specified position of the collection.

Parameters:

Parameter Type Description
index int Index of new slide.
sourceSlide ISlide Slide to clone.

When cloning a slide between different presentations slide’s master can be cloned too. Internal registry is used to track automatically cloned masters to prevent creation of multiple clones of the same master slide. Manual cloning of master slides will be neither prevented nor registered. If you need more control over cloning process use #insertClone(int,ISlide,ILayoutSlide).insertClone(int,ISlide,ILayoutSlide) or #insertClone(int,ISlide,IMasterSlide,boolean).insertClone(int,ISlide,IMasterSlide,boolean) for cloning slides and IMasterSlideCollection.addClone(IMasterSlide) for cloning masters. |

Returns: ISlide - Inserted slide.

addEmptySlide(ILayoutSlide layout)

public final ISlide addEmptySlide(ILayoutSlide layout)

Adds a new empty slide to the end of the collection.

Parameters:

Parameter Type Description
layout ILayoutSlide Layout for a slide.

Returns: ISlide - Added slide.

insertEmptySlide(int index, ILayoutSlide layout)

public final ISlide insertEmptySlide(int index, ILayoutSlide layout)

Inserts a copy of a specified slide to specified position of the collection.

Parameters:

Parameter Type Description
index int Index of a new slide.
layout ILayoutSlide Layout for a slide.

Returns: ISlide - Inserted slide.

addClone(ISlide sourceSlide, ILayoutSlide destLayout)

public final ISlide addClone(ISlide sourceSlide, ILayoutSlide destLayout)

Adds a copy of a specified slide to the end of the collection.

Parameters:

Parameter Type Description
sourceSlide ISlide Slide to clone.
destLayout ILayoutSlide Layout slide for a new slide.

Returns: ISlide - New slide.

insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout)

public final ISlide insertClone(int index, ISlide sourceSlide, ILayoutSlide destLayout)

Inserts a copy of a specified slide to specified position of the collection.

Parameters:

Parameter Type Description
index int Index of new slide.
sourceSlide ISlide Slide to clone.
destLayout ILayoutSlide Layout slide for a new slide.

Returns: ISlide - Inserted slide.

addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)

public final ISlide addClone(ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)

Adds a copy of a specified source slide to the end of the collection. Appropriate layout will be selected automatically from the specified master (appropriate layout is the layout with the same Type or Name as of layout of the source slide). If there is no appropriate layout then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

Parameters:

Parameter Type Description
sourceSlide ISlide Slide to clone.
destMaster IMasterSlide Master slide for a new slide.
allowCloneMissingLayout boolean If there is no appropriate layout in specified master then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

Returns: ISlide - New slide.

insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)

public final ISlide insertClone(int index, ISlide sourceSlide, IMasterSlide destMaster, boolean allowCloneMissingLayout)

Inserts a copy of a specified source slide to specified position of the collection. Appropriate layout will be selected automatically from the specified master (appropriate layout is the layout with the same Type or Name as of layout of the source slide). If there is no appropriate layout then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

Parameters:

Parameter Type Description
index int Index of new slide.
sourceSlide ISlide Slide to clone.
destMaster IMasterSlide Master slide for a new slide.
allowCloneMissingLayout boolean If there is no appropriate layout in specified master then layout of the source slide will be cloned (if allowCloneMissingLayout is true) or PptxEditException will be thrown (if allowCloneMissingLayout is false).

Returns: ISlide - Inserted slide.

remove(ISlide value)

public final void remove(ISlide value)

Removes the first occurrence of a specific object from the collection.

Parameters:

Parameter Type Description
value ISlide The slide to remove from the collection.

removeAt(int index)

public final void removeAt(int index)

Removes the element at the specified index of the collection.

Parameters:

Parameter Type Description
index int The zero-based index of the element to remove.

iterator()

public final System.Collections.Generic.IGenericEnumerator<ISlide> iterator()

Returns an enumerator that iterates through the collection.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.slides.ISlide> - A IGenericEnumerator that can be used to iterate through the collection.

iteratorJava()

public final System.Collections.Generic.IGenericEnumerator<ISlide> iteratorJava()

Returns a java iterator for the entire collection.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.slides.ISlide> - An java.util.Iterator for the entire collection.

toArray()

public final ISlide[] toArray()

Creates and returns an array with all slides in it.

Returns: com.aspose.slides.ISlide[] - Array of Slide

toArray(int startIndex, int count)

public final ISlide[] toArray(int startIndex, int count)

Creates and returns an array with all slides from the specified range in it.

Parameters:

Parameter Type Description
startIndex int An index of a first slide to add.
count int A number of slides to add.

Returns: com.aspose.slides.ISlide[] - Array of Slide

reorder(int index, ISlide slide)

public final void reorder(int index, ISlide slide)

Moves slide from the collection to the specified position.

Parameters:

Parameter Type Description
index int Target index.
slide ISlide Slide to move.

reorder(int index, ISlide[] slides)

public final void reorder(int index, ISlide[] slides)

Moves slides from the collection to the specified position. Slides will be placed starting from index in order they appear in list.

Parameters:

Parameter Type Description
index int Target index.
slides ISlide[] Slides to move.

indexOf(ISlide slide)

public final int indexOf(ISlide slide)

Returns an index of the specified slide in the collection.

Parameters:

Parameter Type Description
slide ISlide Slide to find.

Returns: int - Index of a slide or -1 if slide not from this collection.

addFromPdf(String path)

public final ISlide[] addFromPdf(String path)

Creates slides from the PDF document and adds them to the end of the collection.


Example:
 
 Presentation pres = new Presentation();
 try {
     pres.getSlides().addFromPdf("document.pdf");
     pres.save("fromPdfDocument.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
path java.lang.String A path to the PDF document

Returns: com.aspose.slides.ISlide[] - Added slides

addFromPdf(InputStream pdfStream)

public final ISlide[] addFromPdf(InputStream pdfStream)

Creates slides from the PDF document and adds them to the end of the collection.


Example:
 
 Presentation pres = new Presentation();
 try {
     FileInputStream stream = new FileInputStream("document.pdf");
     {
         pres.getSlides().addFromPdf(stream);
     }
     pres.save("fromPdfDocument.pptx", SaveFormat.Pptx);
 } catch (IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

Parameter Type Description
pdfStream java.io.InputStream A stream which will be used as a source of the PDF document

Returns: com.aspose.slides.ISlide[] - Added slides

addFromHtml(String htmlText, IExternalResourceResolver resolver, String uri)

public final ISlide[] addFromHtml(String htmlText, IExternalResourceResolver resolver, String uri)

Creates slides from HTML text and adds them to the end of the collection.

Parameters:

Parameter Type Description
htmlText java.lang.String Html to add.
resolver IExternalResourceResolver A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
uri java.lang.String An URI of the specified HTML. Used to resolve relative links.

Returns: com.aspose.slides.ISlide[] - Added slides.

addFromHtml(String htmlText)

public final ISlide[] addFromHtml(String htmlText)

Creates slides from HTML text and adds them to the end of the collection.

Parameters:

Parameter Type Description
htmlText java.lang.String Html to add.

Returns: com.aspose.slides.ISlide[] - Added slides

addFromHtml(InputStream htmlStream, IExternalResourceResolver resolver, String uri)

public final ISlide[] addFromHtml(InputStream htmlStream, IExternalResourceResolver resolver, String uri)

Creates slides from HTML text and adds them to the end of the collection.

Parameters:

Parameter Type Description
htmlStream java.io.InputStream A Stream object which will be used as a source of a HTML file.
resolver IExternalResourceResolver A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
uri java.lang.String An URI of the specified HTML. Used to resolve relative links.

Returns: com.aspose.slides.ISlide[] - Added slides.

addFromHtml(InputStream htmlStream)

public final ISlide[] addFromHtml(InputStream htmlStream)

Creates slides from HTML text and adds them to the end of the collection.

Parameters:

Parameter Type Description
htmlStream java.io.InputStream A Stream object which will be used as a source of a HTML file.

Returns: com.aspose.slides.ISlide[] - Added slides

insertFromHtml(int index, String htmlText, IExternalResourceResolver resolver, String uri)

public final ISlide[] insertFromHtml(int index, String htmlText, IExternalResourceResolver resolver, String uri)

Creates slides from HTML text and inserts them to the collection at the specified position.

Parameters:

Parameter Type Description
index int Position to insert.
htmlText java.lang.String Html to add.
resolver IExternalResourceResolver A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
uri java.lang.String An URI of the specified HTML. Used to resolve relative links.

Returns: com.aspose.slides.ISlide[] - Added slides.

insertFromHtml(int index, String htmlText)

public final ISlide[] insertFromHtml(int index, String htmlText)

Creates slides from HTML text and inserts them to the collection at the specified position.

Parameters:

Parameter Type Description
index int Position to insert.
htmlText java.lang.String Html to add.

Returns: com.aspose.slides.ISlide[] - Added slides

insertFromHtml(int index, InputStream htmlStream, IExternalResourceResolver resolver, String uri)

public final ISlide[] insertFromHtml(int index, InputStream htmlStream, IExternalResourceResolver resolver, String uri)

Creates slides from HTML text and inserts them to the collection at the specified position.

Parameters:

Parameter Type Description
index int Position to insert.
htmlStream java.io.InputStream A Stream object which will be used as a source of a HTML file.
resolver IExternalResourceResolver A callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
uri java.lang.String An URI of the specified HTML. Used to resolve relative links.

Returns: com.aspose.slides.ISlide[] - Added slides.

insertFromHtml(int index, InputStream htmlStream)

public final ISlide[] insertFromHtml(int index, InputStream htmlStream)

Creates slides from HTML text and inserts them to the collection at the specified position.

Parameters:

Parameter Type Description
index int Position to insert.
htmlStream java.io.InputStream A Stream object which will be used as a source of a HTML file.

Returns: com.aspose.slides.ISlide[] - Added slides

copyTo(System.Array array, int index)

public final void copyTo(System.Array array, int index)

Copies all elements from the collection to the specified array.

Parameters:

Parameter Type Description
array com.aspose.ms.System.Array Target array.
index int Starting index in the target array.

isSynchronized()

public final boolean isSynchronized()

Returns a value indicating whether access to the collection is synchronized (thread-safe). Read-only boolean.

Returns: boolean

getSyncRoot()

public final Object getSyncRoot()

Returns a synchronization root. Read-only Object.

Returns: java.lang.Object