Presentation

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IPresentation, com.aspose.slides.IDOMObject

public final class Presentation implements IPresentation, IDOMObject

Represents a Microsoft PowerPoint presentation.


The following example shows how to create PowerPoint Presentation.
  
 // Instantiate a Presentation object that represents a presentation file
 Presentation pres = new Presentation();
 try {
     // Get the first slide
     ISlide slide = pres.getSlides().get_Item(0);
     // Add an autoshape of type line
     slide.getShapes().addAutoShape(ShapeType.Line, 50, 150, 300, 0);
     // Save the presentation file.
     pres.save("NewPresentation_out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }
  
  The following example shows how to open and save Presentation.
  
 // Load any supported file in Presentation e.g. ppt, pptx, odp etc.
 Presentation pres = new Presentation("Sample.odp");
 try {
     // Save the presentation file.
     pres.save("OutputPresenation.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Constructors

ConstructorDescription
Presentation()This constructor creates new presentation from scratch.
Presentation(LoadOptions loadOptions)This constructor creates new presentation from scratch.
Presentation(InputStream stream)This constructor is the primary mechanism for reading an existing Presentation.
Presentation(InputStream stream, LoadOptions loadOptions)This constructor is the primary mechanism for reading an existing Presentation.
Presentation(String file)This constructor gets a source file path from which the contents of the Presentation are read.
Presentation(String file, LoadOptions loadOptions)This constructor gets a source file path from which the contents of the Presentation are read.

Methods

MethodDescription
getCurrentDateTime()Returns or sets date and time which will substitute content of datetime fields.
setCurrentDateTime(Date value)Returns or sets date and time which will substitute content of datetime fields.
getParent_Immediate()
getHeaderFooterManager()Returns actual HeaderFooter manager.
getProtectionManager()Gets manager of the permissions for this presentation.
getSlides()Returns a list of all slides that are defined in the presentation.
getSections()Returns a list of all slides sections that are defined in the presentation.
getSlideSize()Returns slide size object.
getNotesSize()Returns notes slide size object.
getLayoutSlides()Returns a list of all layout slides that are defined in the presentation.
getMasters()Returns a list of all master slides that are defined in the presentation.
getMasterNotesSlideManager()Returns notes master manager.
getMasterHandoutSlideManager()Returns handout master manager.
getFontsManager()Returns fonts manager.
getDefaultTextStyle()Returns default text style for shapes.
getCommentAuthors()Returns the collection of comments autors.
getDocumentProperties()Returns DocumentProperties object which contains standard and custom document properties.
getImages()Returns the collection of all images in the presentation.
getAudios()Returns the collection of all embedded audio files in the presentation.
getVideos()Returns the collection of all embedded video files in the presentation.
getSlideShowSettings()Returns the slide show settings for the presentation.
getDigitalSignatures()Returns the collection of signatures used to sign the presentation.
getCustomData()Returns the presentation’s custom data.
getAllCustomXmlParts()Returns all custom data parts in the presentaion.
getVbaProject()Gets or sets VBA project with presentation macros.
setVbaProject(IVbaProject value)Gets or sets VBA project with presentation macros.
getHyperlinkQueries()Provides easy access to all hyperlinks contained in all presentation slides (not in master, layout, notes slides).
getViewProperties()Gets presentation wide view properties.
getFirstSlideNumber()Represents the first slide number in the presentation
setFirstSlideNumber(int value)Represents the first slide number in the presentation
getSlideById(long id)Returns a Slide, MasterSlide or LayoutSlide by Id.
getSourceFormat()Returns information about from which format presentation was loaded.
getMasterTheme()Returns master theme.
save(String fname, int format)Saves all slides of a presentation to a file with the specified format.
save(OutputStream stream, int format)Saves all slides of a presentation to a stream in the specified format.
save(String fname, int format, ISaveOptions options)Saves all slides of a presentation to a file with the specified format and with additional options.
save(OutputStream stream, int format, ISaveOptions options)Saves all slides of a presentation to a stream in the specified format and with additional options.
save(IXamlOptions options)Saves all slides of a presentation to a set of files representing XAML markup.
getThumbnails(IRenderingOptions options)Returns a Thumbnail BufferedImage objects for all slides of a presentation.
getImages(IRenderingOptions options)Returns a Image objects for all slides of a presentation.
getThumbnails(IRenderingOptions options, int[] slides)Returns a Thumbnail BufferedImage objects for specified slides of a presentation.
getImages(IRenderingOptions options, int[] slides)Returns a Thumbnail Image objects for specified slides of a presentation.
getThumbnails(IRenderingOptions options, float scaleX, float scaleY)Returns a Thumbnail BufferedImage objects for all slides of a presentation with custom scaling.
getImages(IRenderingOptions options, float scaleX, float scaleY)Returns a Thumbnail Image objects for all slides of a presentation with custom scaling.
getThumbnails(IRenderingOptions options, int[] slides, float scaleX, float scaleY)Returns a Thumbnail BufferedImage objects for specified slides of a presentation with custom scaling.
getImages(IRenderingOptions options, int[] slides, float scaleX, float scaleY)Returns a Thumbnail Image objects for specified slides of a presentation with custom scaling.
getThumbnails(IRenderingOptions options, Dimension imageSize)Returns a Thumbnail BufferedImage objects for all slides of a presentation with specified size.
getImages(IRenderingOptions options, Dimension imageSize)Returns a Thumbnail Image objects for all slides of a presentation with specified size.
getThumbnails(IRenderingOptions options, int[] slides, Dimension imageSize)Returns a Thumbnail BufferedImage objects for specified slides of a presentation with specified size.
getImages(IRenderingOptions options, int[] slides, Dimension imageSize)Returns a Thumbnail Image objects for specified slides of a presentation with specified size.
save(String fname, int[] slides, int format)Saves specified slides of a presentation to a file with the specified format with page number keeping.
save(String fname, int[] slides, int format, ISaveOptions options)Saves specified slides of a presentation to a file with the specified format with page number keeping.
save(OutputStream stream, int[] slides, int format)Saves specified slides of a presentation to a stream in the specified format with page number keeping.
save(OutputStream stream, int[] slides, int format, ISaveOptions options)Saves specified slides of a presentation to a stream in the specified format with page number keeping.
joinPortionsWithSameFormatting()Joins runs with same formatting in all paragraphs in all acceptable shapes in all slides.
dispose()Releases all resources used by this Presentation object.
getPresentation()Returns the parent presentation of a text.
highlightText(String text, Color highlightColor)Highlights all matches of the sample text with the specified color.
highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback)Highlights all matches of the sample text with the specified color.
highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback)Highlights all matches of the regular expression with the specified color.
replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)Replaces all occurrences of the specified text with another specified text.
replaceRegex(Pattern regex, String newText, IFindResultCallback callback)Replaces all matches of the regular expression with the specified string.

Presentation()

public Presentation()

This constructor creates new presentation from scratch. Created presentation has one empty slide.

Presentation(LoadOptions loadOptions)

public Presentation(LoadOptions loadOptions)

This constructor creates new presentation from scratch. Created presentation has one empty slide.

Parameters:

ParameterTypeDescription
loadOptionsLoadOptionsAdditional load options.

Presentation(InputStream stream)

public Presentation(InputStream stream)

This constructor is the primary mechanism for reading an existing Presentation.


FileInputStream fis = new FileInputStream("demo.pptx");
 Presentation pres = new Presentation(fis);
 fis.close();

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamInput stream.

Presentation(InputStream stream, LoadOptions loadOptions)

public Presentation(InputStream stream, LoadOptions loadOptions)

This constructor is the primary mechanism for reading an existing Presentation.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamInput stream.
loadOptionsLoadOptionsAdditional load options.

Presentation(String file)

public Presentation(String file)

This constructor gets a source file path from which the contents of the Presentation are read.


Presentation pres = new Presentation("demo.pptx");

Parameters:

ParameterTypeDescription
filejava.lang.StringInput file.

Presentation(String file, LoadOptions loadOptions)

public Presentation(String file, LoadOptions loadOptions)

This constructor gets a source file path from which the contents of the Presentation are read.

Parameters:

ParameterTypeDescription
filejava.lang.StringInput file.
loadOptionsLoadOptionsAdditional load options.

getCurrentDateTime()

public final Date getCurrentDateTime()

Returns or sets date and time which will substitute content of datetime fields. Time of this Presentation object creation by default. Read/write java.util.Date.

Returns: java.util.Date

setCurrentDateTime(Date value)

public final void setCurrentDateTime(Date value)

Returns or sets date and time which will substitute content of datetime fields. Time of this Presentation object creation by default. Read/write java.util.Date.

Parameters:

ParameterTypeDescription
valuejava.util.Date

getParent_Immediate()

public final IDOMObject getParent_Immediate()

Returns Parent_Immediate object. Read-only IDOMObject.

Returns: com.aspose.slides.IDOMObject

getHeaderFooterManager()

public final IPresentationHeaderFooterManager getHeaderFooterManager()

Returns actual HeaderFooter manager. Read-only IPresentationHeaderFooterManager.


The following example shows how to set footer visibility inside Slide of PowerPoint Presentation.
 
 Presentation pres = new Presentation("presentation.ppt");
 try
 {
     IBaseSlideHeaderFooterManager headerFooterManager = pres.getSlides().get_Item(0).getHeaderFooterManager();
     if (!headerFooterManager.isFooterVisible()) // Property IsFooterVisible is used for indicating that a slide footer placeholder is not present.
     {
         headerFooterManager.setFooterVisibility(true); // Method SetFooterVisibility is used for making a slide footer placeholder visible.
     }
     if (!headerFooterManager.isSlideNumberVisible()) // Property IsSlideNumberVisible is used for indicating that a slide page number placeholder is not present.
     {
         headerFooterManager.setSlideNumberVisibility(true); // Method SetSlideNumberVisibility is used for making a slide page number placeholder visible.
     }
     if (!headerFooterManager.isDateTimeVisible()) // Property IsDateTimeVisible is used for indicating that a slide date-time placeholder is not present.
     {
         headerFooterManager.setDateTimeVisibility(true); // Method SetFooterVisibility is used for making a slide date-time placeholder visible.
     }
     headerFooterManager.setFooterText("Footer text"); // Method SetFooterText is used for setting text to slide footer placeholder.
     headerFooterManager.setDateTimeText("Date and time text"); // Method SetDateTimeText is used for setting text to slide date-time placeholder.
     pres.save("Presentation.ppt", SaveFormat.Ppt);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to set child footer visibility inside Slide.
 
 Presentation pres = new Presentation("presentation.ppt");
 try
 {
     IMasterSlideHeaderFooterManager headerFooterManager = pres.getMasters().get_Item(0).getHeaderFooterManager();
     headerFooterManager.setFooterAndChildFootersVisibility(true); // Method SetFooterAndChildFootersVisibility is used for making a master slide and all child footer placeholders visible.
     headerFooterManager.setSlideNumberAndChildSlideNumbersVisibility(true); // Method SetSlideNumberAndChildSlideNumbersVisibility is used for making a master slide and all child page number placeholders visible.
     headerFooterManager.setDateTimeAndChildDateTimesVisibility(true); // Method SetDateTimeAndChildDateTimesVisibility is used for making a master slide and all child date-time placeholders visible.

     headerFooterManager.setFooterAndChildFootersText("Footer text"); // Method SetFooterAndChildFootersText is used for setting text to master slide and all child footer placeholders.
     headerFooterManager.setDateTimeAndChildDateTimesText("Date and time text"); // Method SetDateTimeAndChildDateTimesText is used for setting text to master slide and all child date-time placeholders.
 }
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: IPresentationHeaderFooterManager

getProtectionManager()

public final IProtectionManager getProtectionManager()

Gets manager of the permissions for this presentation. Read-only IProtectionManager.

Returns: IProtectionManager

getSlides()

public final ISlideCollection getSlides()

Returns a list of all slides that are defined in the presentation. Read-only ISlideCollection.


The following example shows how to set slides' background color of PowerPoint Presentation.
 
 // Instantiate the Presentation class that represents the presentation file
 Presentation pres = new Presentation();
 try
 {
     // Set the background color of the first ISlide to Blue
     pres.getSlides().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
     pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Solid);
     pres.getSlides().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Color.BLUE);
     pres.save("ContentBG_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to set slides' background image of PowerPoint Presentation.
 
 // Instantiate the Presentation class that represents the presentation file
 Presentation pres = new Presentation("SetImageAsBackground.pptx");
 try {
     // Set the background with Image
     pres.getSlides().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
     pres.getSlides().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Picture);
     pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch);
     // Set the picture
     BufferedImage img = ImageIO.read(new File("Tulips.jpg"));
     // Add image to presentation's images collection
     IPPImage imgx = pres.getImages().addImage(img);
     pres.getSlides().get_Item(0).getBackground().getFillFormat().getPictureFillFormat().getPicture().setImage(imgx);
     // Write the presentation to disk
     pres.save("ContentBG_Img_out.pptx", SaveFormat.Pptx);
 } catch (IOException e) { }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to add slide transition Presentation.
 
 // Instantiate Presentation class to load the source presentation file
 Presentation pres = new Presentation("AccessSlides.pptx");
 try
 {
     // Apply circle type transition on slide 1
     pres.getSlides().get_Item(0).getSlideShowTransition().setType(TransitionType.Circle);
     // Apply comb type transition on slide 2
     pres.getSlides().get_Item(1).getSlideShowTransition().setType(TransitionType.Comb);
     // Write the presentation to disk
     pres.save("SampleTransition_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to add advanced slide Transition.
 
 // Instantiate Presentation class that represents a presentation file
 Presentation pres = new Presentation("BetterSlideTransitions.pptx");
 try
 {
     // Apply circle type transition on slide 1
     pres.getSlides().get_Item(0).getSlideShowTransition().setType(TransitionType.Circle);
     // Set the transition time of 3 seconds
     pres.getSlides().get_Item(0).getSlideShowTransition().setAdvanceOnClick(true);
     pres.getSlides().get_Item(0).getSlideShowTransition().setAdvanceAfterTime(3000);
     // Apply comb type transition on slide 2
     pres.getSlides().get_Item(1).getSlideShowTransition().setType(TransitionType.Comb);
     // Set the transition time of 5 seconds
     pres.getSlides().get_Item(1).getSlideShowTransition().setAdvanceOnClick(true);
     pres.getSlides().get_Item(1).getSlideShowTransition().setAdvanceAfterTime(5000);
     // Apply zoom type transition on slide 3
     pres.getSlides().get_Item(2).getSlideShowTransition().setType(TransitionType.Zoom);
     // Set the transition time of 7 seconds
     pres.getSlides().get_Item(2).getSlideShowTransition().setAdvanceOnClick(true);
     pres.getSlides().get_Item(2).getSlideShowTransition().setAdvanceAfterTime(7000);
     // Write the presentation to disk
     pres.save("SampleTransition_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: ISlideCollection

getSections()

public final ISectionCollection getSections()

Returns a list of all slides sections that are defined in the presentation. Read-only ISectionCollection.


The following examples shows how to create Sections in a PowerPoint Presentation.
 
 Presentation pres = new Presentation();
 try {
     ISlide defaultSlide = pres.getSlides().get_Item(0);
     ISlide newSlide1 = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
     ISlide newSlide2 = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
     ISlide newSlide3 = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
     ISlide newSlide4 = pres.getSlides().addEmptySlide(pres.getLayoutSlides().get_Item(0));
     ISection section1 = pres.getSections().addSection("Section 1", newSlide1);
     // section1 will be ended at newSlide2 and after it section2 will start
     ISection section2 = pres.getSections().addSection("Section 2", newSlide3);
     pres.save("pres-sections.pptx", SaveFormat.Pptx);
     pres.getSections().reorderSectionWithSlides(section2, 0);
     pres.save("pres-sections-moved.pptx", SaveFormat.Pptx);
     pres.getSections().removeSectionWithSlides(section2);
     pres.getSections().appendEmptySection("Last empty section");
     pres.save("pres-section-with-empty.pptx",SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to changing the names of Sections.
 
 Presentation pres = new Presentation("pres.pptx");
 try {
     ISection section = pres.getSections().get_Item(0);
     section.setName("My section");
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: ISectionCollection

getSlideSize()

public final ISlideSize getSlideSize()

Returns slide size object. Read-only ISlideSize.


The following example shows how to change the slide size in a PowerPoint Presentation.
 
 Presentation pres = new Presentation("pres-4x3-aspect-ratio.pptx");
 try {
     pres.getSlideSize().setSize(SlideSizeType.OnScreen16x9, SlideSizeScaleType.DoNotScale);
     pres.save("pres-4x3-aspect-ratio.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to set slide size with respect to content scaling for a PowerPoint Presentation.
 
 // Instantiate a Presentation object that represents a presentation file
 Presentation presentation = new Presentation("AccessSlides.pptx");
 try {
     Presentation auxPresentation = new Presentation();
     try {
         ISlide slide = presentation.getSlides().get_Item(0);
         // Set the slide size of generated presentations to that of source
         presentation.getSlideSize().setSize(540, 720, SlideSizeScaleType.EnsureFit); // Method SetSize is used for set slide size with scale content to ensure fit
         presentation.getSlideSize().setSize(SlideSizeType.A4Paper, SlideSizeScaleType.Maximize); // Method SetSize is used for set slide size with maximize size of content
         // Save Presentation to disk
         auxPresentation.save("Set_Size&Type_out.pptx", SaveFormat.Pptx);
     } finally {
         if (auxPresentation != null) auxPresentation.dispose();
     }
 } finally {
     if (presentation != null) presentation.dispose();
 }
 
 The following example shows how to specifying custom slide sizes in a PowerPoint Presentation.
 
 Presentation pres = new Presentation("pres.pptx");
 try {
     pres.getSlideSize().setSize(780, 540, SlideSizeScaleType.DoNotScale); // A4 paper size
     pres.save("pres-a4-slide-size.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: ISlideSize

getNotesSize()

public final INotesSize getNotesSize()

Returns notes slide size object. Read-only INotesSize.

Returns: INotesSize

getLayoutSlides()

public final IGlobalLayoutSlideCollection getLayoutSlides()

Returns a list of all layout slides that are defined in the presentation. Read-only IGlobalLayoutSlideCollection.


You can access to alternative API for adding/inserting/removing/cloning layout slides by using IMasterSlide.LayoutSlides property.

Returns: IGlobalLayoutSlideCollection

getMasters()

public final IMasterSlideCollection getMasters()

Returns a list of all master slides that are defined in the presentation. Read-only IMasterSlideCollection.


The following examples shows how to adding Images to Master Slides of PowerPoint Presentation.
 
 Presentation pres = new Presentation();
 try {
     ISlide slide = pres.getSlides().get_Item(0);
     IMasterSlide masterSlide = slide.getLayoutSlide().getMasterSlide();
     IPPImage image = pres.getImages().addImage(Files.readAllBytes(Paths.get("image.png")));
     masterSlide.getShapes().addPictureFrame(ShapeType.Rectangle, 10, 10, 100, 100, image);
     pres.save("pres.pptx", SaveFormat.Pptx);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to change the background color of the master slide of PowerPoint Presentation.
 
 // Instantiate the Presentation class that represents the presentation file
 Presentation pres = new Presentation();
 try
 {
     // Set the background color of the Master ISlide to Forest Green
     pres.getMasters().get_Item(0).getBackground().setType(BackgroundType.OwnBackground);
     pres.getMasters().get_Item(0).getBackground().getFillFormat().setFillType(FillType.Solid);
     pres.getMasters().get_Item(0).getBackground().getFillFormat().getSolidFillColor().setColor(Color.GREEN);
     // Write the presentation to disk
     pres.save("SetSlideBackgroundMaster_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to add slide layout to PowerPoint Presentation.
 
 // Instantiate Presentation class that represents the presentation file
 Presentation presentation = new Presentation("AccessSlides.pptx");
 try
 {
     // Try to search by layout slide type
     IMasterLayoutSlideCollection layoutSlides = presentation.getMasters().get_Item(0).getLayoutSlides();
     ILayoutSlide layoutSlide = null;
     if (layoutSlides.getByType(SlideLayoutType.TitleAndObject) != null)
         layoutSlide = layoutSlides.getByType(SlideLayoutType.TitleAndObject);
     else
         layoutSlide = layoutSlides.getByType(SlideLayoutType.Title);

     if (layoutSlide == null)
     {
         // The situation when a presentation doesn't contain some type of layouts.
         // presentation File only contains Blank and Custom layout types.
         // But layout slides with Custom types has different slide names,
         // like "Title", "Title and Content", etc. And it is possible to use these
         // names for layout slide selection.
         // Also it is possible to use the set of placeholder shape types. For example,
         // Title slide should have only Title pleceholder type, etc.
         for (ILayoutSlide titleAndObjectLayoutSlide : (Iterable) layoutSlides)
         {
             if ("Title and Object".equals(titleAndObjectLayoutSlide.getName()))
             {
                 layoutSlide = titleAndObjectLayoutSlide;
                 break;
             }
         }
         if (layoutSlide == null)
         {
             for (ILayoutSlide titleLayoutSlide : (Iterable) layoutSlides)
             {
                 if ("Title".equals(titleLayoutSlide.getName()))
                 {
                     layoutSlide = titleLayoutSlide;
                     break;
                 }
             }
             if (layoutSlide == null)
             {
                 layoutSlide = layoutSlides.getByType(SlideLayoutType.Blank);
                 if (layoutSlide == null)
                 {
                     layoutSlide = layoutSlides.add(SlideLayoutType.TitleAndObject, "Title and Object");
                 }
             }
         }
     }
     // Adding empty slide with added layout slide
     presentation.getSlides().insertEmptySlide(0, layoutSlide);
     // Save presentation
     presentation.save("AddLayoutSlides_out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (presentation != null) presentation.dispose();
 }

Returns: IMasterSlideCollection

getMasterNotesSlideManager()

public final IMasterNotesSlideManager getMasterNotesSlideManager()

Returns notes master manager. Read-only IMasterNotesSlideManager.

Returns: IMasterNotesSlideManager

getMasterHandoutSlideManager()

public final IMasterHandoutSlideManager getMasterHandoutSlideManager()

Returns handout master manager. Read-only IMasterHandoutSlideManager.

Returns: IMasterHandoutSlideManager

getFontsManager()

public final IFontsManager getFontsManager()

Returns fonts manager. Read-only IFontsManager.


The following example shows how to add embedded fonts to PowerPoint Presentation.
 
 // Load presentation
 Presentation pres = new Presentation("Fonts.pptx");
 try {
     // Load source font to be replaced
     IFontData sourceFont = new FontData("Arial");
     IFontData[] allFonts = pres.getFontsManager().getFonts();
     for (IFontData font : allFonts)
     {
         boolean fontAlreadyEmbedded = false;
         IFontData[] embeddedFonts = pres.getFontsManager().getEmbeddedFonts();
         for (int i = 0; i < embeddedFonts.length; i++)
         {
             if (embeddedFonts[i].equals(font))
             {
                 fontAlreadyEmbedded = true;
                 break;
             }
         }
         if (!fontAlreadyEmbedded) {
             pres.getFontsManager().addEmbeddedFont(font, EmbedFontCharacters.All);
         }
     }
     // Save the presentation
     pres.save("AddEmbeddedFont_out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: IFontsManager

getDefaultTextStyle()

public final ITextStyle getDefaultTextStyle()

Returns default text style for shapes. Read-only ITextStyle.

Returns: ITextStyle

getCommentAuthors()

public final ICommentAuthorCollection getCommentAuthors()

Returns the collection of comments autors. Read-only ICommentAuthorCollection.

Returns: ICommentAuthorCollection

getDocumentProperties()

public final IDocumentProperties getDocumentProperties()

Returns DocumentProperties object which contains standard and custom document properties. Read-only IDocumentProperties.

Returns: IDocumentProperties

getImages()

public final IImageCollection getImages()

Returns the collection of all images in the presentation. Read-only IImageCollection.


The following examples shows how to add image as BLOB in PowerPoint Presentation.
 
 // creates a new presentation to which the image will be added.
 Presentation pres = new Presentation();
 try
 {
     // supposed we have the large image file we want to include into the presentation
     FileInputStream fip = new FileInputStream("large_image.jpg");
     try
     {
         // Let's add the image to the presentation - we choose KeepLocked behavior because we do
         // NOT intend to access the "largeImage.png" file.
         IPPImage img = pres.getImages().addImage(fip, LoadingStreamBehavior.KeepLocked);
         pres.getSlides().get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 300, 200, img);
         // Saves the presentation. While a large presentation gets outputted, the memory consumption
         // stays low through the pres object's lifecycle
         pres.save("presentationWithLargeImage.pptx", SaveFormat.Pptx);
     }
     finally
     {
         fip.close();
     }
 }
 catch (java.io.IOException e) { }
 finally
 {
     pres.dispose();
 }
 
 The following examples add a hyperlink to an image in a PowerPoint Presentation.
 
 Presentation pres = new Presentation();
 try {
     // Adds image to presentation
     IPPImage image = pres.getImages().addImage(Files.readAllBytes(Paths.get("image.png")));
     // Creates picture frame on slide 1 based on previously added image
     IPictureFrame pictureFrame = pres.getSlides().get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 10, 10, 100, 100, image);
     pictureFrame.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
     pictureFrame.getHyperlinkClick().setTooltip("More than 70% Fortune 100 companies trust Aspose APIs");
     pres.save("pres-out.pptx", SaveFormat.Pptx);
 } catch (IOException e){ }
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: IImageCollection

getAudios()

public final IAudioCollection getAudios()

Returns the collection of all embedded audio files in the presentation. Read-only IAudioCollection.


The following examples shows how to add a hyperlink to an audio file.
 
 Presentation pres = new Presentation();
 try {
     IAudio audio = pres.getAudios().addAudio(Files.readAllBytes(Paths.get("audio.mp3")));
     IAudioFrame audioFrame = pres.getSlides().get_Item(0).getShapes().addAudioFrameEmbedded(10, 10, 100, 100, audio);
     audioFrame.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
     audioFrame.getHyperlinkClick().setTooltip("More than 70% Fortune 100 companies trust Aspose APIs");
     pres.save("pres-out.pptx", SaveFormat.Pptx);
 }
 catch (IOException e) {}
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: IAudioCollection

getVideos()

public final IVideoCollection getVideos()

Returns the collection of all embedded video files in the presentation. Read-only IVideoCollection.


The following examples shows how to create embedded Video Frame in a PowerPoint Presentation.
 
 // Instantiate Presentation class that represents the PPTX
 Presentation pres = new Presentation();
 try {
     // Get the first slide
     ISlide sld = pres.getSlides().get_Item(0);
     // Embedd vide inside presentation
     IVideo vid = pres.getVideos().addVideo(new FileInputStream("Wildlife.mp4"));
     // Add Video Frame
     IVideoFrame vf = sld.getShapes().addVideoFrame(50, 150, 300, 350, vid);
     // Set video to Video Frame
     vf.setEmbeddedVideo(vid);
     // Set Play Mode and Volume of the Video
     vf.setPlayMode(VideoPlayModePreset.Auto);
     vf.setVolume(AudioVolumeMode.Loud);
     // Write the PPTX file to disk
     pres.save("VideoFrame_out.pptx", SaveFormat.Pptx);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to add a video passing path to the video file directly into AddVideoFrame method for PowerPoint Presentation.
 
 Presentation pres = new Presentation();
 try {
     ISlide sld = pres.getSlides().get_Item(0);
     IVideoFrame vf = sld.getShapes().addVideoFrame(50, 150, 300, 150, "video1.avi");
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to add large file through BLOB to a Presentation.
 
 // Creates a new presentation to which the video will be added
 Presentation pres = new Presentation();
 try {
     FileInputStream fileStream = new FileInputStream("veryLargeVideo.avi");
     try {
         // Let's add the video to the presentation - we chose the KeepLocked behavior because we do
         //not intend to access the "veryLargeVideo.avi" file.
         IVideo video = pres.getVideos().addVideo(fileStream, LoadingStreamBehavior.KeepLocked);
         pres.getSlides().get_Item(0).getShapes().addVideoFrame(0, 0, 480, 270, video);
         // Saves the presentation. While a large presentation gets outputted, the memory consumption
         // stays low through the pres object's lifecycle
         pres.save("presentationWithLargeVideo.pptx", SaveFormat.Pptx);
     } finally {
         if (fileStream != null) fileStream.close();
     }
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to export large file through BLOB from PowerPoint Presentation.
 
 LoadOptions loadOptions = new LoadOptions();
 // Locks the source file and does NOT load it into memory
 loadOptions.getBlobManagementOptions().setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
 // Creates a Presentation's instance, locks the "hugePresentationWithAudiosAndVideos.pptx" file.
 Presentation pres = new Presentation("Large  Video File Test1.pptx", loadOptions);
 try {
     // Let's save each video to a file. To prevent high memory usage, we need a buffer that will be used
     // to transfer the data from the presentation's video stream to a stream for a newly created video file.
     byte[] buffer = new byte[81024];
     // Iterates through the videos
     for (int index = 0; index < pres.getVideos().size(); index++) {
         IVideo video = pres.getVideos().get_Item(index);
         // Opens the presentation video stream. Please, note that we intentionally avoided accessing properties
         // like video.BinaryData - because this property returns a byte array containing a full video, which then
         // causes bytes to be loaded into memory. We use video.GetStream, which will return Stream - and does NOT
         //  require us to load the whole video into the memory.
         InputStream presVideoStream = video.getStream();
         try {
             FileOutputStream outputFileStream = new FileOutputStream("video{index}.avi");
             try {
                 int bytesRead;
                 while ((bytesRead = presVideoStream.read(buffer, 0, buffer.length)) > 0) {
                     outputFileStream.write(buffer, 0, bytesRead);
                 }
             } finally {
                 if (outputFileStream != null) outputFileStream.close();
             }
         } finally {
             if (presVideoStream != null) presVideoStream.close();
         }
         // Memory consumption will remain low regardless of the size of the video or presentation,
     }
     // If necessary, you can apply the same steps for audio files.
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to add a hyperlink to a video in a PowerPoint Presentation.
 
 Presentation pres = new Presentation();
 try {
     IVideo video = pres.getVideos().addVideo(Files.readAllBytes(Paths.get("video.avi")));
     IVideoFrame videoFrame = pres.getSlides().get_Item(0).getShapes().addVideoFrame(10, 10, 100, 100, video);
     videoFrame.setHyperlinkClick(new Hyperlink("https://www.aspose.com/"));
     videoFrame.getHyperlinkClick().setTooltip("More than 70% Fortune 100 companies trust Aspose APIs");
     pres.save("pres-out.pptx", SaveFormat.Pptx);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following examples shows how to create Video Frame with Video from Web Source in a PowerPoint Presentation.
 
 public static void run()
 {
     Presentation pres = new Presentation();
     try {
         addVideoFromYouTube(pres, "Tj75Arhq5ho");
         pres.save("AddVideoFrameFromWebSource_out.pptx", SaveFormat.Pptx);
     } catch(IOException e) {
     } finally {
         if (pres != null) pres.dispose();
     }
 }
 private static void addVideoFromYouTube(Presentation pres, String videoId) throws IOException
 {
     //add videoFrame
     IVideoFrame videoFrame = pres.getSlides().get_Item(0).getShapes().addVideoFrame(10, 10, 427, 240, "https://www.youtube.com/embed/" + videoId);
     videoFrame.setPlayMode(VideoPlayModePreset.Auto);

     //load thumbnail
     String thumbnailUri = "http://img.youtube.com/vi/" + videoId + "/hqdefault.jpg";
     URL url = new URL(thumbnailUri);
     URLConnection connection = url.openConnection();
     connection.setConnectTimeout(5000);
     connection.setReadTimeout(10000);
     InputStream input = connection.getInputStream();
     ByteArrayOutputStream output = new ByteArrayOutputStream();
     try
     {
         byte[] buffer = new byte[8192];
         for (int count; (count = input.read(buffer)) > 0; )
         {
             output.write(buffer, 0, count);
         }
         videoFrame.getPictureFormat().getPicture().setImage(pres.getImages().addImage(output.toByteArray()));
     } finally {
         if (input != null) input.close();
         if (output != null) output.close();
     }
 }
 
 The following examples shows how to extract Video from slide of PowerPoint Presentation.
 
 // Instantiate a Presentation object that represents a presentation file
 Presentation presentation = new Presentation("Video.pptx");
 try {
     for (ISlide slide : presentation.getSlides())
     {
         for (IShape shape : presentation.getSlides().get_Item(0).getShapes())
         {
             if (shape instanceof VideoFrame)
             {
                 IVideoFrame vf = (IVideoFrame) shape;
                 String type = vf.getEmbeddedVideo().getContentType();
                 int ss = type.lastIndexOf('/');
                 type = type.substring(ss + 1);
                 byte[] buffer = vf.getEmbeddedVideo().getBinaryData();
                 FileOutputStream fop = new FileOutputStream("NewVideo_out." + type);
                 try
                 {
                     fop.write(buffer);
                     fop.flush();
                     fop.close();
                 }
                 finally
                 {
                     if (presentation != null) presentation.dispose();
                 }
             }
         }
     }
 } catch(IOException e) {
 } finally {
     if (presentation != null) presentation.dispose();
 }

Returns: IVideoCollection

getSlideShowSettings()

public final SlideShowSettings getSlideShowSettings()

Returns the slide show settings for the presentation.

Returns: SlideShowSettings

getDigitalSignatures()

public final IDigitalSignatureCollection getDigitalSignatures()

Returns the collection of signatures used to sign the presentation. Read-only IDigitalSignatureCollection.


Presentation pres = new Presentation("SomePresentationSigned.pptx");
 try
 {
     if (pres.getDigitalSignatures().size() > 0)
     {
         boolean allSignaturesAreValid = true;
         System.out.println("Signatures used to sign the presentation: ");
         for (IDigitalSignature signature : pres.getDigitalSignatures())
         {
            System.out.println(signature.getCertificate().hashCode() + ", "
                  + signature.getSignTime().toString() + " -- " + (signature.isValid() ? "VALID" : "INVALID"));
            allSignaturesAreValid &= signature.isValid();
         }
         if (allSignaturesAreValid)
            System.out.println("Presentation is genuine, all signatures are valid.");
         else
            System.out.println("Presentation has been modified since signing.");
     }
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: IDigitalSignatureCollection

getCustomData()

public final ICustomData getCustomData()

Returns the presentation’s custom data. Read-only ICustomData.

Returns: ICustomData

getAllCustomXmlParts()

public final ICustomXmlPart[] getAllCustomXmlParts()

Returns all custom data parts in the presentaion. Read-only ICustomXmlPart[].


The following examples show how to clear all custom xml parts from PowerPoint Presentation.
 
 Presentation pres = new Presentation("PresentationWithCustomXml.pptx");
 try {
     // Iterate all custom XML Parts
     for (ICustomXmlPart item : pres.getAllCustomXmlParts())
     {
         item.remove();
     }
     pres.save("out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: com.aspose.slides.ICustomXmlPart[]

getVbaProject()

public final IVbaProject getVbaProject()

Gets or sets VBA project with presentation macros. Read/write IVbaProject.

Returns: IVbaProject

setVbaProject(IVbaProject value)

public final void setVbaProject(IVbaProject value)

Gets or sets VBA project with presentation macros. Read/write IVbaProject.

Parameters:

ParameterTypeDescription
valueIVbaProject

getHyperlinkQueries()

public final IHyperlinkQueries getHyperlinkQueries()

Provides easy access to all hyperlinks contained in all presentation slides (not in master, layout, notes slides). Read-only IHyperlinkQueries.

Returns: IHyperlinkQueries

getViewProperties()

public final IViewProperties getViewProperties()

Gets presentation wide view properties. Read-only IViewProperties.

Returns: IViewProperties

getFirstSlideNumber()

public final int getFirstSlideNumber()

Represents the first slide number in the presentation

Returns: int

setFirstSlideNumber(int value)

public final void setFirstSlideNumber(int value)

Represents the first slide number in the presentation

Parameters:

ParameterTypeDescription
valueint

getSlideById(long id)

public final IBaseSlide getSlideById(long id)

Returns a Slide, MasterSlide or LayoutSlide by Id.

Parameters:

ParameterTypeDescription
idlongId of a slide.

Returns: IBaseSlide - IBaseSlide object.

getSourceFormat()

public final int getSourceFormat()

Returns information about from which format presentation was loaded. Read-only SourceFormat.

Returns: int

getMasterTheme()

public final IMasterTheme getMasterTheme()

Returns master theme. Read-only IMasterTheme.


The following examples shows how to change a theme effect by altering parts of elements of PowerPoint Presentation.
 
 //Instantiate a presentation object that represents a presentation file
 Presentation pres = new Presentation("Subtle_Moderate_Intense.pptx");
 try {
     pres.getMasterTheme().getFormatScheme().getLineStyles().get_Item(0).getFillFormat().getSolidFillColor().setColor(Color.RED);
     ((FillFormat)pres.getMasterTheme().getFormatScheme().getLineStyles().get_Item(2)).setFillType(FillType.Solid);
     ((FillFormat)pres.getMasterTheme().getFormatScheme().getLineStyles().get_Item(2)).getSolidFillColor().setColor(Color.GREEN);
     ((EffectStyle)pres.getMasterTheme().getFormatScheme().getLineStyles().get_Item(2)).getEffectFormat().getOuterShadowEffect().setDistance(10f);
     pres.save("Design_04_Subtle_Moderate_Intense-out.pptx", SaveFormat.Pptx);
 }
 finally
 {
     if (pres != null) pres.dispose();
 }

Returns: IMasterTheme

save(String fname, int format)

public final void save(String fname, int format)

Saves all slides of a presentation to a file with the specified format.

Parameters:

ParameterTypeDescription
fnamejava.lang.StringPath to the created file.
formatintFormat of the exported data.

save(OutputStream stream, int format)

public final void save(OutputStream stream, int format)

Saves all slides of a presentation to a stream in the specified format.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamOutput stream.
formatintFormat of the exported data.

save(String fname, int format, ISaveOptions options)

public final void save(String fname, int format, ISaveOptions options)

Saves all slides of a presentation to a file with the specified format and with additional options.

Parameters:

ParameterTypeDescription
fnamejava.lang.StringPath to the created file.
formatintFormat of the exported data.
optionsISaveOptionsAdditional format options.

save(OutputStream stream, int format, ISaveOptions options)

public final void save(OutputStream stream, int format, ISaveOptions options)

Saves all slides of a presentation to a stream in the specified format and with additional options.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamOutput stream.
formatintFormat of the exported data.
optionsISaveOptionsAdditional format options.

save(IXamlOptions options)

public final void save(IXamlOptions options)

Saves all slides of a presentation to a set of files representing XAML markup.


Presentation pres = new Presentation("pres.pptx");
 try {
     XamlOptions xamlOptions = new XamlOptions();
     xamlOptions.setExportHiddenSlides(true);

     pres.save(xamlOptions);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
optionsIXamlOptionsThe XAML format options.

getThumbnails(IRenderingOptions options)

public final BufferedImage[] getThumbnails(IRenderingOptions options)

Returns a Thumbnail BufferedImage objects for all slides of a presentation.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options)

public final IImage[] getImages(IRenderingOptions options)

Returns a Image objects for all slides of a presentation.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.

Returns: com.aspose.slides.IImage[] - Image objects.

getThumbnails(IRenderingOptions options, int[] slides)

public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides)

Returns a Thumbnail BufferedImage objects for specified slides of a presentation.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options, int[] slides)

public final IImage[] getImages(IRenderingOptions options, int[] slides)

Returns a Thumbnail Image objects for specified slides of a presentation.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.

Returns: com.aspose.slides.IImage[] - Image objects.

getThumbnails(IRenderingOptions options, float scaleX, float scaleY)

public final BufferedImage[] getThumbnails(IRenderingOptions options, float scaleX, float scaleY)

Returns a Thumbnail BufferedImage objects for all slides of a presentation with custom scaling.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
scaleXfloatThe value by which to scale this Thumbnail in the x-axis direction.
scaleYfloatThe value by which to scale this Thumbnail in the y-axis direction.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options, float scaleX, float scaleY)

public final IImage[] getImages(IRenderingOptions options, float scaleX, float scaleY)

Returns a Thumbnail Image objects for all slides of a presentation with custom scaling.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
scaleXfloatThe value by which to scale this Thumbnail in the x-axis direction.
scaleYfloatThe value by which to scale this Thumbnail in the y-axis direction.

Returns: com.aspose.slides.IImage[] - Image objects.

getThumbnails(IRenderingOptions options, int[] slides, float scaleX, float scaleY)

public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, float scaleX, float scaleY)

Returns a Thumbnail BufferedImage objects for specified slides of a presentation with custom scaling.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.
scaleXfloatThe value by which to scale this Thumbnail in the x-axis direction.
scaleYfloatThe value by which to scale this Thumbnail in the y-axis direction.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options, int[] slides, float scaleX, float scaleY)

public final IImage[] getImages(IRenderingOptions options, int[] slides, float scaleX, float scaleY)

Returns a Thumbnail Image objects for specified slides of a presentation with custom scaling.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.
scaleXfloatThe value by which to scale this Thumbnail in the x-axis direction.
scaleYfloatThe value by which to scale this Thumbnail in the y-axis direction.

Returns: com.aspose.slides.IImage[] - Image objects.

getThumbnails(IRenderingOptions options, Dimension imageSize)

public final BufferedImage[] getThumbnails(IRenderingOptions options, Dimension imageSize)

Returns a Thumbnail BufferedImage objects for all slides of a presentation with specified size.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
imageSizejava.awt.DimensionSize of the image to create.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options, Dimension imageSize)

public final IImage[] getImages(IRenderingOptions options, Dimension imageSize)

Returns a Thumbnail Image objects for all slides of a presentation with specified size.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
imageSizejava.awt.DimensionSize of the image to create.

Returns: com.aspose.slides.IImage[] - Image objects.

getThumbnails(IRenderingOptions options, int[] slides, Dimension imageSize)

public final BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, Dimension imageSize)

Returns a Thumbnail BufferedImage objects for specified slides of a presentation with specified size.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.
imageSizejava.awt.DimensionSize of the image to create.

Returns: java.awt.image.BufferedImage[] - BufferedImage objects.

getImages(IRenderingOptions options, int[] slides, Dimension imageSize)

public final IImage[] getImages(IRenderingOptions options, int[] slides, Dimension imageSize)

Returns a Thumbnail Image objects for specified slides of a presentation with specified size.

Parameters:

ParameterTypeDescription
optionsIRenderingOptionsTiff options.
slidesint[]Array with slide positions, starting from 1.
imageSizejava.awt.DimensionSize of the image to create.

Returns: com.aspose.slides.IImage[] - Image objects.

save(String fname, int[] slides, int format)

public final void save(String fname, int[] slides, int format)

Saves specified slides of a presentation to a file with the specified format with page number keeping.

Parameters:

ParameterTypeDescription
fnamejava.lang.StringPath to the created file.
slidesint[]Array with slide positions, starting from 1.
formatintFormat of the exported data.

save(String fname, int[] slides, int format, ISaveOptions options)

public final void save(String fname, int[] slides, int format, ISaveOptions options)

Saves specified slides of a presentation to a file with the specified format with page number keeping.

Parameters:

ParameterTypeDescription
fnamejava.lang.StringPath to the created file.
slidesint[]Array with slide positions, starting from 1.
formatintFormat of the exported data.
optionsISaveOptionsAdditional format options.

save(OutputStream stream, int[] slides, int format)

public final void save(OutputStream stream, int[] slides, int format)

Saves specified slides of a presentation to a stream in the specified format with page number keeping.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamOutput stream.
slidesint[]Array with slide positions, starting from 1.
formatintFormat of the exported data.

save(OutputStream stream, int[] slides, int format, ISaveOptions options)

public final void save(OutputStream stream, int[] slides, int format, ISaveOptions options)

Saves specified slides of a presentation to a stream in the specified format with page number keeping.


The following example shows how to convert PowerPoint to PNG.
 
 Presentation pres = new Presentation("pres.pptx");
 try {
     for (int index = 0; index < pres.getSlides().size(); index++) {
         ISlide slide = pres.getSlides().get_Item(index);
         ImageIO.write(slide.getThumbnail(), "PNG", new java.io.File("slide_" + index + ".png"));
     }
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to convert PowerPoint to PNG with custom dimensions.
 
 Presentation pres = new Presentation("pres.pptx");
 try {
     float scaleX = 2f;
     float scaleY = 2f;
     for (int index = 0; index < pres.getSlides().size(); index++) {
         ISlide slide = pres.getSlides().get_Item(index);
         ImageIO.write(slide.getThumbnail(scaleX, scaleY), "PNG", new java.io.File("slide_" + index + ".png"));
     }
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }
 
 The following example shows how to convert PowerPoint to PNG with custom size.
 
 Presentation pres = new Presentation("pres.pptx");
 try {
     Dimension size = new Dimension(960, 720);
     for (int index = 0; index < pres.getSlides().size(); index++) {
         ISlide slide = pres.getSlides().get_Item(index);
         ImageIO.write(slide.getThumbnail(size), "PNG", new java.io.File("slide_" + index + ".png"));
     }
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamOutput stream.
slidesint[]Array with slide positions, starting from 1.
formatintFormat of the exported data.
optionsISaveOptionsAdditional format options.

joinPortionsWithSameFormatting()

public final void joinPortionsWithSameFormatting()

Joins runs with same formatting in all paragraphs in all acceptable shapes in all slides.

dispose()

public final void dispose()

Releases all resources used by this Presentation object.

getPresentation()

public final IPresentation getPresentation()

Returns the parent presentation of a text. Read-only IPresentation.

Returns: IPresentation

highlightText(String text, Color highlightColor)

public final void highlightText(String text, Color highlightColor)

Highlights all matches of the sample text with the specified color.


The following code sample shows how to highlight text in a PowerPoint presentation.
 
 Presentation presentation = new Presentation("SomePresentation.pptx");
 try {
     // highlighting all separate 'the' occurrences
     presentation.highlightText("the", Color.MAGENTA);
     presentation.save("SomePresentation-out2.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
textjava.lang.StringThe text to highlight.
highlightColorjava.awt.ColorThe color to highlight the text.

highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback)

public final void highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback)

Highlights all matches of the sample text with the specified color.


The following code sample shows how to highlight text in a PowerPoint presentation.
 
 Presentation presentation = new Presentation("SomePresentation.pptx");
 try {
     TextSearchOptions textSearchOptions = new TextSearchOptions();
     textSearchOptions.setWholeWordsOnly(true);
     // highlighting all separate 'the' occurrences
     presentation.highlightText("the", Color.MAGENTA, textSearchOptions, null);
     presentation.save("SomePresentation-out2.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
textjava.lang.StringThe text to highlight.
highlightColorjava.awt.ColorThe color to highlight the text.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback)

public final void highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback)

Highlights all matches of the regular expression with the specified color.


The following code sample shows how to highlight text in a PowerPoint Presentation using a regular expression.
 
 Presentation presentation = new Presentation("SomePresentation.pptx");
 try {
     Pattern regex = Pattern.compile("\\b[^\\s]{10,}\\b");
     // highlighting all words with 10 symbols or longer
     presentation.highlightRegex(regex, Color.BLUE, null);
     presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
regexjava.util.regex.PatternThe regular expression java.util.regex.Pattern to get strings to highlight.
highlightColorjava.awt.ColorThe color to highlight the text.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)

public final void replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)

Replaces all occurrences of the specified text with another specified text.


The following sample code shows how to replace one specified string with another specified string.
 
 Presentation presentation = new Presentation("SomePresentation.pptx")
 try {
     TextSearchOptions textSearchOptions = new TextSearchOptions();
     textSearchOptions.setWholeWordsOnly(true);
     // Replace all separate 'the' occurrences with '***'
     presentation.replaceText("the", "***", textSearchOptions, null);
     presentation.save("SomePresentation-out2.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
oldTextjava.lang.StringThe string to be replaced.
newTextjava.lang.StringThe string to replace all occurrences of oldText.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

replaceRegex(Pattern regex, String newText, IFindResultCallback callback)

public final void replaceRegex(Pattern regex, String newText, IFindResultCallback callback)

Replaces all matches of the regular expression with the specified string.


The following code sample shows how to replace text using regular expression with the specified string.
 Presentation presentation = new Presentation("SomePresentation.pptx");
 try {
     Pattern regex = Pattern.compile("\\b[^\\s]{10,}\\b");
     // Replace all words with 10 symbols or longer with '***'
     presentation.replaceRegex(regex, "***", null);
     presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx);
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
regexjava.util.regex.PatternThe regular expression java.util.regex.Pattern to get strings to replace.
newTextjava.lang.StringThe string to replace all occurrences of the strings to be replaced.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.