public final class Presentation extends java.lang.Object implements IPresentation
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(); }
| Constructor and Description |
|---|
Presentation()
This constructor creates new presentation from scratch.
|
Presentation(java.io.InputStream stream)
This constructor is the primary mechanism for reading an existing Presentation.
|
Presentation(java.io.InputStream stream,
LoadOptions loadOptions)
This constructor is the primary mechanism for reading an existing Presentation.
|
Presentation(LoadOptions loadOptions)
This constructor creates new presentation from scratch.
|
Presentation(java.lang.String file)
This constructor gets a source file path from which
the contents of the Presentation are read.
|
Presentation(java.lang.String file,
LoadOptions loadOptions)
This constructor gets a source file path from which
the contents of the Presentation are read.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Releases all resources used by this Presentation object.
|
ICustomXmlPart[] |
getAllCustomXmlParts()
Returns all custom data parts in the presentaion.
|
IAudioCollection |
getAudios()
Returns the collection of all embedded audio files in the presentation.
|
ICommentAuthorCollection |
getCommentAuthors()
Returns the collection of comments autors.
|
java.util.Date |
getCurrentDateTime()
Returns or sets date and time which will substitute content of datetime fields.
|
ICustomData |
getCustomData()
Returns the presentation's custom data.
|
ITextStyle |
getDefaultTextStyle()
Returns default text style for shapes.
|
IDigitalSignatureCollection |
getDigitalSignatures()
Returns the collection of signatures used to sign the presentation.
|
IDocumentProperties |
getDocumentProperties()
Returns DocumentProperties object which contains standard and custom document properties.
|
int |
getFirstSlideNumber()
Represents the first slide number in the presentation
|
IFontsManager |
getFontsManager()
Returns fonts manager.
|
IPresentationHeaderFooterManager |
getHeaderFooterManager()
Returns actual HeaderFooter manager.
|
IHyperlinkQueries |
getHyperlinkQueries()
Provides easy access to all hyperlinks contained in all presentation slides (not in master, layout, notes slides).
|
IImageCollection |
getImages()
Returns the collection of all images in the presentation.
|
IImage[] |
getImages(IRenderingOptions options)
Returns a Image objects for all slides of a presentation.
|
IImage[] |
getImages(IRenderingOptions options,
java.awt.Dimension imageSize)
Returns a Thumbnail Image objects for all slides of a presentation with specified size.
|
IImage[] |
getImages(IRenderingOptions options,
float scaleX,
float scaleY)
Returns a Thumbnail Image objects for all slides of a presentation with custom scaling.
|
IImage[] |
getImages(IRenderingOptions options,
int[] slides)
Returns a Thumbnail Image objects for specified slides of a presentation.
|
IImage[] |
getImages(IRenderingOptions options,
int[] slides,
java.awt.Dimension imageSize)
Returns a Thumbnail Image objects for specified slides of a presentation with specified size.
|
IImage[] |
getImages(IRenderingOptions options,
int[] slides,
float scaleX,
float scaleY)
Returns a Thumbnail Image objects for specified slides of a presentation with custom scaling.
|
IGlobalLayoutSlideCollection |
getLayoutSlides()
Returns a list of all layout slides that are defined in the presentation.
|
IMasterHandoutSlideManager |
getMasterHandoutSlideManager()
Returns handout master manager.
|
IMasterNotesSlideManager |
getMasterNotesSlideManager()
Returns notes master manager.
|
IMasterSlideCollection |
getMasters()
Returns a list of all master slides that are defined in the presentation.
|
IMasterTheme |
getMasterTheme()
Returns master theme.
|
INotesSize |
getNotesSize()
Returns notes slide size object.
|
com.aspose.slides.IDOMObject |
getParent_Immediate()
Returns Parent_Immediate object.
|
IPresentation |
getPresentation()
Returns the parent presentation of a text.
|
IProtectionManager |
getProtectionManager()
Gets manager of the permissions for this presentation.
|
ISectionCollection |
getSections()
Returns a list of all slides sections that are defined in the presentation.
|
IBaseSlide |
getSlideById(long id)
Returns a Slide, MasterSlide or LayoutSlide by Id.
|
ISlideCollection |
getSlides()
Returns a list of all slides that are defined in the presentation.
|
SlideShowSettings |
getSlideShowSettings()
Returns the slide show settings for the presentation.
|
ISlideSize |
getSlideSize()
Returns slide size object.
|
int |
getSourceFormat()
Returns information about from which format presentation was loaded.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options)
Deprecated.
Use Presentation.GetThumbnails(IRenderingOptions) instead. The method will be removed after release of version 21.4.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options,
java.awt.Dimension imageSize)
Deprecated.
Use GetImages(IRenderingOptions options, Size imageSize) method instead. The method will be removed after release of version 24.7.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options,
float scaleX,
float scaleY)
Deprecated.
Use GetImages(IRenderingOptions options, float scaleX, float scaleY) method instead. The method will be removed after release of version 24.7.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options,
int[] slides)
Deprecated.
Use GetImages(IRenderingOptions options, int[] slides) method instead. The method will be removed after release of version 24.7.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options,
int[] slides,
java.awt.Dimension imageSize)
Deprecated.
Use GetImages(IRenderingOptions options, int[] slides, Size imageSize) method instead. The method will be removed after release of version 24.7.
|
java.awt.image.BufferedImage[] |
getThumbnails(IRenderingOptions options,
int[] slides,
float scaleX,
float scaleY)
Deprecated.
Use GetImages(IRenderingOptions options, int[] slides, float scaleX, float scaleY) method instead. The method will be removed after release of version 24.7.
|
IVbaProject |
getVbaProject()
Gets or sets VBA project with presentation macros.
|
IVideoCollection |
getVideos()
Returns the collection of all embedded video files in the presentation.
|
IViewProperties |
getViewProperties()
Gets presentation wide view properties.
|
void |
highlightRegex(java.util.regex.Pattern regex,
java.awt.Color highlightColor,
IFindResultCallback callback)
Highlights all matches of the regular expression with the specified color.
|
void |
highlightText(java.lang.String text,
java.awt.Color highlightColor)
Highlights all matches of the sample text with the specified color.
|
void |
highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextSearchOptions options,
IFindResultCallback callback)
Highlights all matches of the sample text with the specified color.
|
void |
joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs in all acceptable shapes in all slides.
|
void |
replaceRegex(java.util.regex.Pattern regex,
java.lang.String newText,
IFindResultCallback callback)
Replaces all matches of the regular expression with the specified string.
|
void |
replaceText(java.lang.String oldText,
java.lang.String newText,
ITextSearchOptions options,
IFindResultCallback callback)
Replaces all occurrences of the specified text with another specified text.
|
void |
save(IXamlOptions options)
Saves all slides of a presentation to a set of files representing XAML markup.
|
void |
save(java.io.OutputStream stream,
int format)
Saves all slides of a presentation to a stream in the specified format.
|
void |
save(java.io.OutputStream stream,
int[] slides,
int format)
Saves specified slides of a presentation to a stream in the specified format with page number keeping.
|
void |
save(java.io.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.
|
void |
save(java.io.OutputStream stream,
int format,
ISaveOptions options)
Saves all slides of a presentation to a stream in the specified format and with additional options.
|
void |
save(java.lang.String fname,
int format)
Saves all slides of a presentation to a file with the specified format.
|
void |
save(java.lang.String fname,
int[] slides,
int format)
Saves specified slides of a presentation to a file with the specified format with page number keeping.
|
void |
save(java.lang.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.
|
void |
save(java.lang.String fname,
int format,
ISaveOptions options)
Saves all slides of a presentation to a file with the specified format and with additional options.
|
void |
setCurrentDateTime(java.util.Date value)
Returns or sets date and time which will substitute content of datetime fields.
|
void |
setFirstSlideNumber(int value)
Represents the first slide number in the presentation
|
void |
setVbaProject(IVbaProject value)
Gets or sets VBA project with presentation macros.
|
public Presentation()
This constructor creates new presentation from scratch. Created presentation has one empty slide.
public Presentation(LoadOptions loadOptions)
This constructor creates new presentation from scratch. Created presentation has one empty slide.
loadOptions - Additional load options.public Presentation(java.io.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();
stream - Input stream.public Presentation(java.io.InputStream stream,
LoadOptions loadOptions)
This constructor is the primary mechanism for reading an existing Presentation.
stream - Input stream.loadOptions - Additional load options.public Presentation(java.lang.String file)
This constructor gets a source file path from which the contents of the Presentation are read.
Presentation pres = new Presentation("demo.pptx");
file - Input file.com.aspose.ms.System.ArgumentException - Thrown when input file has zero lengthpublic Presentation(java.lang.String file,
LoadOptions loadOptions)
This constructor gets a source file path from which the contents of the Presentation are read.
file - Input file.loadOptions - Additional load options.com.aspose.ms.System.ArgumentException - Thrown when input file has zero lengthpublic final java.util.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 Date.
getCurrentDateTime in interface IPresentationpublic final void setCurrentDateTime(java.util.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 Date.
setCurrentDateTime in interface IPresentationpublic final com.aspose.slides.IDOMObject getParent_Immediate()
Returns Parent_Immediate object.
Read-only IDOMObject.
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(); }
getHeaderFooterManager in interface IPresentationpublic final IProtectionManager getProtectionManager()
Gets manager of the permissions for this presentation.
Read-only IProtectionManager.
getProtectionManager in interface IPresentationpublic 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(); }
getSlides in interface IPresentationpublic 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(); }
getSections in interface IPresentationpublic 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(); }
getSlideSize in interface IPresentationpublic final INotesSize getNotesSize()
Returns notes slide size object.
Read-only INotesSize.
getNotesSize in interface IPresentationpublic final IGlobalLayoutSlideCollection getLayoutSlides()
Returns a list of all layout slides that are defined in the presentation.
Read-only IGlobalLayoutSlideCollection.
getLayoutSlides in interface IPresentationpublic 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(); }
getMasters in interface IPresentationpublic final IMasterNotesSlideManager getMasterNotesSlideManager()
Returns notes master manager.
Read-only IMasterNotesSlideManager.
getMasterNotesSlideManager in interface IPresentationpublic final IMasterHandoutSlideManager getMasterHandoutSlideManager()
Returns handout master manager.
Read-only IMasterHandoutSlideManager.
getMasterHandoutSlideManager in interface IPresentationpublic 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(); }
getFontsManager in interface IPresentationpublic final ITextStyle getDefaultTextStyle()
Returns default text style for shapes.
Read-only ITextStyle.
getDefaultTextStyle in interface IPresentationpublic final ICommentAuthorCollection getCommentAuthors()
Returns the collection of comments autors.
Read-only ICommentAuthorCollection.
getCommentAuthors in interface IPresentationpublic final IDocumentProperties getDocumentProperties()
Returns DocumentProperties object which contains standard and custom document properties.
Read-only IDocumentProperties.
getDocumentProperties in interface IPresentationpublic 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(); }
getImages in interface IPresentationpublic 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(); }
getAudios in interface IPresentationpublic 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(); }
getVideos in interface IPresentationpublic final SlideShowSettings getSlideShowSettings()
Returns the slide show settings for the presentation.
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(); }
getDigitalSignatures in interface IPresentationpublic final ICustomData getCustomData()
Returns the presentation's custom data.
Read-only ICustomData.
getCustomData in interface IPresentationpublic 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(); }
getAllCustomXmlParts in interface IPresentationpublic final IVbaProject getVbaProject()
Gets or sets VBA project with presentation macros.
Read/write IVbaProject.
getVbaProject in interface IPresentationpublic final void setVbaProject(IVbaProject value)
Gets or sets VBA project with presentation macros.
Read/write IVbaProject.
setVbaProject in interface IPresentationpublic final IHyperlinkQueries getHyperlinkQueries()
Provides easy access to all hyperlinks contained in all presentation slides (not in master, layout, notes slides).
Read-only IHyperlinkQueries.
getHyperlinkQueries in interface IPresentationpublic final IViewProperties getViewProperties()
Gets presentation wide view properties.
Read-only IViewProperties.
getViewProperties in interface IPresentationpublic final int getFirstSlideNumber()
Represents the first slide number in the presentation
getFirstSlideNumber in interface IPresentationpublic final void setFirstSlideNumber(int value)
Represents the first slide number in the presentation
setFirstSlideNumber in interface IPresentationpublic final IBaseSlide getSlideById(long id)
Returns a Slide, MasterSlide or LayoutSlide by Id.
getSlideById in interface IPresentationid - Id of a slide.public final int getSourceFormat()
Returns information about from which format presentation was loaded.
Read-only SourceFormat.
getSourceFormat in interface IPresentationpublic 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(); }
getMasterTheme in interface IPresentationpublic final void save(java.lang.String fname,
int format)
Saves all slides of a presentation to a file with the specified format.
save in interface IPresentationfname - Path to the created file.format - Format of the exported data.public final void save(java.io.OutputStream stream,
int format)
Saves all slides of a presentation to a stream in the specified format.
save in interface IPresentationstream - Output stream.format - Format of the exported data.public final void save(java.lang.String fname,
int format,
ISaveOptions options)
Saves all slides of a presentation to a file with the specified format and with additional options.
save in interface IPresentationfname - Path to the created file.format - Format of the exported data.options - Additional format options.public final void save(java.io.OutputStream stream,
int format,
ISaveOptions options)
Saves all slides of a presentation to a stream in the specified format and with additional options.
save in interface IPresentationstream - Output stream.format - Format of the exported data.options - Additional format options.com.aspose.ms.System.NotSupportedException - If you try to save encrypted file in
none Office 2007-2010 formatpublic 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(); }
save in interface IPresentationoptions - The XAML format options.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options)
Returns a Thumbnail BufferedImage objects for all slides of a presentation.
getThumbnails in interface IPresentationoptions - Tiff options.public final IImage[] getImages(IRenderingOptions options)
Returns a Image objects for all slides of a presentation.
getImages in interface IPresentationoptions - Tiff options.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides)
Returns a Thumbnail BufferedImage objects for specified slides of a presentation.
getThumbnails in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.public final IImage[] getImages(IRenderingOptions options, int[] slides)
Returns a Thumbnail Image objects for specified slides of a presentation.
getImages in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options, float scaleX, float scaleY)
Returns a Thumbnail BufferedImage objects for all slides of a presentation with custom scaling.
getThumbnails in interface IPresentationoptions - Tiff options.scaleX - The value by which to scale this Thumbnail in the x-axis direction.scaleY - The value by which to scale this Thumbnail in the y-axis direction.public final IImage[] getImages(IRenderingOptions options, float scaleX, float scaleY)
Returns a Thumbnail Image objects for all slides of a presentation with custom scaling.
getImages in interface IPresentationoptions - Tiff options.scaleX - The value by which to scale this Thumbnail in the x-axis direction.scaleY - The value by which to scale this Thumbnail in the y-axis direction.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, float scaleX, float scaleY)
Returns a Thumbnail BufferedImage objects for specified slides of a presentation with custom scaling.
getThumbnails in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.scaleX - The value by which to scale this Thumbnail in the x-axis direction.scaleY - The value by which to scale this Thumbnail in the y-axis direction.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.
getImages in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.scaleX - The value by which to scale this Thumbnail in the x-axis direction.scaleY - The value by which to scale this Thumbnail in the y-axis direction.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options, java.awt.Dimension imageSize)
Returns a Thumbnail BufferedImage objects for all slides of a presentation with specified size.
getThumbnails in interface IPresentationoptions - Tiff options.imageSize - Size of the image to create.public final IImage[] getImages(IRenderingOptions options, java.awt.Dimension imageSize)
Returns a Thumbnail Image objects for all slides of a presentation with specified size.
getImages in interface IPresentationoptions - Tiff options.imageSize - Size of the image to create.@Deprecated public final java.awt.image.BufferedImage[] getThumbnails(IRenderingOptions options, int[] slides, java.awt.Dimension imageSize)
Returns a Thumbnail BufferedImage objects for specified slides of a presentation with specified size.
getThumbnails in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.imageSize - Size of the image to create.public final IImage[] getImages(IRenderingOptions options, int[] slides, java.awt.Dimension imageSize)
Returns a Thumbnail Image objects for specified slides of a presentation with specified size.
getImages in interface IPresentationoptions - Tiff options.slides - Array with slide positions, starting from 1.imageSize - Size of the image to create.public final void save(java.lang.String fname,
int[] slides,
int format)
Saves specified slides of a presentation to a file with the specified format with page number keeping.
save in interface IPresentationfname - Path to the created file.slides - Array with slide positions, starting from 1.format - Format of the exported data.com.aspose.ms.System.ArgumentNullException - When stream or slides parameter is null.com.aspose.ms.System.ArgumentOutOfRangeException - When slides parameter contains wrong page numbers.com.aspose.ms.System.InvalidOperationException - When an unsupported SaveFormat is used, e.g. PPTX, PPTM, PPSX, PPSM, POTX, POTM, PPT, ODP.public final void save(java.lang.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 in interface IPresentationfname - Path to the created file.slides - Array with slide positions, starting from 1.format - Format of the exported data.options - Additional format options.public final void save(java.io.OutputStream stream,
int[] slides,
int format)
Saves specified slides of a presentation to a stream in the specified format with page number keeping.
save in interface IPresentationstream - Output stream.slides - Array with slide positions, starting from 1.format - Format of the exported data.public final void save(java.io.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(); }
save in interface IPresentationstream - Output stream.slides - Array with slide positions, starting from 1.format - Format of the exported data.options - Additional format options.com.aspose.ms.System.ArgumentNullException - When stream or slides parameter is null.com.aspose.ms.System.ArgumentOutOfRangeException - When slides parameter contains wrong page numbers.com.aspose.ms.System.InvalidOperationException - When an unsupported SaveFormat is used, e.g. PPTX, PPTM, PPSX, PPSM, POTX, POTM, PPT, ODP.public final void joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs in all acceptable shapes in all slides.
joinPortionsWithSameFormatting in interface IPresentationpublic final void dispose()
Releases all resources used by this Presentation object.
dispose in interface com.aspose.ms.System.IDisposablepublic final IPresentation getPresentation()
Returns the parent presentation of a text.
Read-only IPresentation.
getPresentation in interface IPresentationComponentpublic final void highlightText(java.lang.String text,
java.awt.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(); }
highlightText in interface IPresentationtext - The text to highlight.highlightColor - The color to highlight the text.public final void highlightText(java.lang.String text,
java.awt.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(); }
highlightText in interface IPresentationtext - The text to highlight.highlightColor - The color to highlight the text.options - Text search options ITextSearchOptions.callback - The callback object for receiving search results IFindResultCallback.public final void highlightRegex(java.util.regex.Pattern regex,
java.awt.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(); }
highlightRegex in interface IPresentationregex - The regular expression Pattern to get strings to highlight.highlightColor - The color to highlight the text.callback - The callback object for receiving search results IFindResultCallback.public final void replaceText(java.lang.String oldText,
java.lang.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(); }
replaceText in interface IPresentationoldText - The string to be replaced.newText - The string to replace all occurrences of oldText.options - Text search options ITextSearchOptions.callback - The callback object for receiving search results IFindResultCallback.public final void replaceRegex(java.util.regex.Pattern regex,
java.lang.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();
}
replaceRegex in interface IPresentationregex - The regular expression Pattern to get strings to replace.newText - The string to replace all occurrences of the strings to be replaced.callback - The callback object for receiving search results IFindResultCallback.Copyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.