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

MethodDescription
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:

ParameterTypeDescription
indexint

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:

ParameterTypeDescription
sourceSlideISlideSlide 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:

ParameterTypeDescription
sourceSlideISlideSlide to clone.
sectionISectionSection 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.


The following example shows how to clone at another position within Presentation.
 
 // Instantiate Presentation class that represents a presentation file
 Presentation pres = new Presentation("CloneWithInSamePresentation.pptx");
 try {
     // Clone the desired slide to the end of the collection of slides in the same presentation
     ISlideCollection slds = pres.getSlides();
     // Clone the desired slide to the specified index in the same presentation
     slds.insertClone(2, pres.getSlides().get_Item(1));
     // Write the modified presentation to disk
     pres.save("Aspose_CloneWithInSamePresentation_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to clone at another position within Presentation.
 
 // Instantiate Presentation class to load the source presentation file
 Presentation srcPres = new Presentation("CloneAtEndOfAnother.pptx");
 try {
     // Instantiate Presentation class for destination PPTX (where slide is to be cloned)
     Presentation destPres = new Presentation();
     try {
         ISlideCollection slds = destPres.getSlides();
         slds.insertClone(2, srcPres.getSlides().get_Item(0));
         // Write the destination presentation to disk
         destPres.save("Aspose2_out.pptx", SaveFormat.Pptx);
     } finally {
         if (destPres != null) destPres.dispose();
     }
 } finally {
     if (srcPres != null) srcPres.dispose();
 }

Parameters:

ParameterTypeDescription
indexintIndex of new slide.
sourceSlideISlideSlide 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:

ParameterTypeDescription
layoutILayoutSlideLayout 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:

ParameterTypeDescription
indexintIndex of a new slide.
layoutILayoutSlideLayout 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:

ParameterTypeDescription
sourceSlideISlideSlide to clone.
destLayoutILayoutSlideLayout 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:

ParameterTypeDescription
indexintIndex of new slide.
sourceSlideISlideSlide to clone.
destLayoutILayoutSlideLayout 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:

ParameterTypeDescription
sourceSlideISlideSlide to clone.
destMasterIMasterSlideMaster slide for a new slide.
allowCloneMissingLayoutbooleanIf 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:

ParameterTypeDescription
indexintIndex of new slide.
sourceSlideISlideSlide to clone.
destMasterIMasterSlideMaster slide for a new slide.
allowCloneMissingLayoutbooleanIf 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:

ParameterTypeDescription
valueISlideThe 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:

ParameterTypeDescription
indexintThe 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:

ParameterTypeDescription
startIndexintAn index of a first slide to add.
countintA 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:

ParameterTypeDescription
indexintTarget index.
slideISlideSlide 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:

ParameterTypeDescription
indexintTarget index.
slidesISlide[]Slides to move.

indexOf(ISlide slide)

public final int indexOf(ISlide slide)

Returns an index of the specified slide in the collection.

Parameters:

ParameterTypeDescription
slideISlideSlide 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:

ParameterTypeDescription
pathjava.lang.StringA 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:

ParameterTypeDescription
pdfStreamjava.io.InputStreamA 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:

ParameterTypeDescription
htmlTextjava.lang.StringHtml to add.
resolverIExternalResourceResolverA callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
urijava.lang.StringAn 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:

ParameterTypeDescription
htmlTextjava.lang.StringHtml 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:

ParameterTypeDescription
htmlStreamjava.io.InputStreamA Stream object which will be used as a source of a HTML file.
resolverIExternalResourceResolverA callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
urijava.lang.StringAn 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.


// Create an instance of the Presentation class.
 Presentation pres = new Presentation();
 try {
     String html = new String(Files.readAllBytes(Paths.get("file.html")));
     // Call the AddFromHtml method and pass the HTML file.
     pres.getSlides().addFromHtml(html);
     // Use the Save method to save the file as a PowerPoint document.
     pres.save("MyPresentation.pptx", SaveFormat.Pptx);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
htmlStreamjava.io.InputStreamA 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:

ParameterTypeDescription
indexintPosition to insert.
htmlTextjava.lang.StringHtml to add.
resolverIExternalResourceResolverA callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
urijava.lang.StringAn 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:

ParameterTypeDescription
indexintPosition to insert.
htmlTextjava.lang.StringHtml 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:

ParameterTypeDescription
indexintPosition to insert.
htmlStreamjava.io.InputStreamA Stream object which will be used as a source of a HTML file.
resolverIExternalResourceResolverA callback object used to fetch external objects. If this parameter is null all external objects will be ignored.
urijava.lang.StringAn 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:

ParameterTypeDescription
indexintPosition to insert.
htmlStreamjava.io.InputStreamA 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:

ParameterTypeDescription
arraycom.aspose.ms.System.ArrayTarget array.
indexintStarting 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