Class Slide
Namespace: Aspose.Slides
Assembly: Aspose.Slides.dll (25.12.0)
Represents a slide in a presentation.
public sealed class Slide : BaseSlideInheritance
Properties
HeaderFooterManager
Returns HeaderFooter manager of the slide. Read-only Aspose.Slides.ISlideHeaderFooterManager.
public ISlideHeaderFooterManager HeaderFooterManager { get; }Property Value
Hidden
Determines whether the specified slide is hidden during a slide show. Read/write System.Boolean.
public bool Hidden { get; set; }Property Value
LayoutSlide
Returns or sets the layout slide for the current slide. Read/write Aspose.Slides.ILayoutSlide.
public ILayoutSlide LayoutSlide { get; set; }Property Value
NotesSlideManager
Allow to access notes slide, add and remove it. Read-only Aspose.Slides.INotesSlideManager.
public INotesSlideManager NotesSlideManager { get; }Property Value
ShowMasterShapes
Specifies if shapes on the master slide should be shown on slides or not. Read/write System.Boolean.
public override bool ShowMasterShapes { get; set; }Property Value
SlideNumber
Returns a number of slide. Index of slide in Aspose.Slides.Presentation.Slides collection is always equal to SlideNumber - Presentation.FirstSlideNumber. Read/write System.Int32.
public int SlideNumber { get; set; }Property Value
ThemeManager
Returns the overriding theme manager. Read-only Aspose.Slides.Theme.IOverrideThemeManager.
public IOverrideThemeManager ThemeManager { get; }Property Value
Methods
GetImage(float, float)
Returns a Thumbnail Image object with custom scaling.
public IImage GetImage(float scaleX, float scaleY)Parameters
scaleX float
The value by which to scale this Thumbnail in the x-axis direction.
scaleY float
The value by which to scale this Thumbnail in the y-axis direction.
Returns
IImage object.
Examples
The following example shows how to generate thumbnails from PowerPoint Presentation.
// Instantiate a Presentation class that represents the presentation file
using (Presentation pres = new Presentation("ThumbnailFromSlide.pptx"))
{
// Access the first slide
ISlide sld = pres.Slides[0];
// Create a full scale image
IImage bmp = sld.GetImage(1f, 1f);
// Save the image to disk in JPEG format
bmp.Save("Thumbnail_out.jpg", ImageFormat.Jpeg);
}The following example shows how to converting slides to bitmap and saving the images in PNG.
using (Presentation pres = new Presentation("Presentation.pptx"))
{
// Converts the first slide in the presentation to a Bitmap object
using (IImage bmp = pres.Slides[0].GetImage())
{
// Saves the image in the PNG format
bmp.Save("Slide_0.png", ImageFormat.Png);
}
}The following example shows how to convert PowerPoint PPT/PPTX to JPG.
using (Presentation pres = new Presentation("PowerPoint-Presentation.ppt"))
{
foreach (ISlide sld in pres.Slides)
{
// Create a full scale image
IImage bmp = sld.GetImage(1f, 1f);
// Save the image to disk in JPEG format
bmp.Save(string.Format("Slide_{0}.jpg", sld.SlideNumber), ImageFormat.Jpeg);
}
}The following example shows how to convert PowerPoint PPT/PPTX to JPG with customized dimensions.
using (Presentation pres = new Presentation("PowerPoint-Presentation.pptx"))
{
// Define dimensions
int desiredX = 1200;
int desiredY = 800;
// Get scaled values of X and Y
float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX;
float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY;
foreach (ISlide sld in pres.Slides)
{
// Create a full scale image
IImage bmp = sld.GetImage(ScaleX, ScaleY);
// Save the image to disk in JPEG format
bmp.Save(string.Format("Slide_{0}.jpg", sld.SlideNumber), ImageFormat.Jpeg);
}
}GetImage()
Returns a Thumbnail Image object (20% of real size).
public IImage GetImage()Returns
GetImage(Size)
Returns a Thumbnail Image object with specified size.
public IImage GetImage(Size imageSize)Parameters
imageSize Size
Size of the image to create.
Returns
Image object.
Examples
The following example shows how to converting slides to images with custom sizes using C#.
using (Presentation pres = new Presentation("Presentation.pptx"))
{
// Converts the first slide in the presentation to a Bitmap with the specified size
using (IImage bmp = pres.Slides[0].GetImage(new Size(1820, 1040)))
{
// Saves the image in the JPEG format
bmp.Save("Slide_0.jpg", ImageFormat.Jpeg);
}
}GetImage(ITiffOptions)
Returns a Thumbnail tiff image object with specified parameters.
public IImage GetImage(ITiffOptions options)Parameters
options ITiffOptions
Tiff options.
Returns
Image object.
Exceptions
Thrown when options.SlideLayoutOption is NotesCommentsLayoutingOptions and its property NotesPosition takes the value NotesPositions.BottomFull.
GetImage(IRenderingOptions)
Returns a Thumbnail Image object.
public IImage GetImage(IRenderingOptions options)Parameters
options IRenderingOptions
Rendering options.
Returns
Image object.
Exceptions
Thrown when notesCommentsLayouting.NotesPosition takes the value NotesPositions.BottomFull
GetImage(IRenderingOptions, float, float)
Returns a Thumbnail Image object with custom scaling.
public IImage GetImage(IRenderingOptions options, float scaleX, float scaleY)Parameters
options IRenderingOptions
Rendering options.
scaleX float
The value by which to scale this Thumbnail in the x-axis direction.
scaleY float
The value by which to scale this Thumbnail in the y-axis direction.
Returns
Bitmap objects.
Examples
The following example shows how to converting slides With notes and comments to Images using C#.
using (Presentation pres = new Presentation("PresentationNotesComments.pptx"))
{
// Create the rendering options
IRenderingOptions options = new RenderingOptions();
// Create notes and comments layouting options
NotesCommentsLayoutingOptions notesCommentsLayouting = new NotesCommentsLayoutingOptions();
// Sets the position of the notes on the page
notesCommentsLayouting.NotesPosition = NotesPositions.BottomTruncated;
// Sets the position of the comments on the page
notesCommentsLayouting.CommentsPosition = CommentsPositions.Right;
// Sets the width of the comment output area
notesCommentsLayouting.CommentsAreaWidth = 500;
// Sets the color for the comments area
notesCommentsLayouting.CommentsAreaColor = Color.AntiqueWhite;
// Set layout options for rendering
options.SlidesLayoutOptions = notesCommentsLayouting;
// Converts the first slide of the presentation to a IImage object
IImage image = pres.Slides[0].GetImage(options, 2f, 2f);
// Saves the image in the GIF format
image.Save("Slide_Notes_Comments_0.gif", ImageFormat.Gif);
}Exceptions
Thrown when notesCommentsLayouting.NotesPosition takes the value NotesPositions.BottomFull
GetImage(IRenderingOptions, Size)
Returns a Thumbnail Image object with specified size.
public IImage GetImage(IRenderingOptions options, Size imageSize)Parameters
options IRenderingOptions
Rendering options.
imageSize Size
Size of the image to create.
Returns
Image object.
Exceptions
Thrown when options.SlideLayoutOption is NotesCommentsLayoutingOptions and its property NotesPosition takes the value NotesPositions.BottomFull.
GetSlideComments(ICommentAuthor)
Returns all slide comments added by specific author.
public IComment[] GetSlideComments(ICommentAuthor author)Parameters
author ICommentAuthor
Author of comments to find or null to return all comments.
Returns
IComment []
Array of Aspose.Slides.Comment.
JoinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs in all acceptable shapes.
public override void JoinPortionsWithSameFormatting()Remove()
Removes slide from presentation.
public void Remove()Exceptions
Thrown if slide is already removed from presentation.
Reset()
Resets position, size and formatting of every shape that has a prototype on LayoutSlide.
public void Reset()WriteAsEmf(Stream)
Saves the slide content as an EMF file.
public void WriteAsEmf(Stream stream)Parameters
stream Stream
Target stream
Examples
The following code example demonstrates how to convert the first slide from a PowerPoint presentation into a metafile.
using (Presentation pres = new Presentation("pres.pptx"))
{
using (Stream fileStream = System.IO.File.Create("slide_1.emf"))
{
// Saves the first slide as a metafille
pres.Slides[0].WriteAsEmf(fileStream);
}
}Exceptions
Target stream is null
WriteAsSvg(Stream)
Saves the slide content as an SVG file.
public void WriteAsSvg(Stream stream)Parameters
stream Stream
Target stream
Examples
The following code example demonstrates how to convert the first slide from a PowerPoint presentation into an SVG file.
using (Presentation pres = new Presentation("pres.pptx"))
{
using (Stream fileStream = System.IO.File.Create("slide_1.svg"))
{
// Saves the first slide as an SVG file
pres.Slides[0].WriteAsSvg(fileStream);
}
}WriteAsSvg(Stream, ISVGOptions)
Saves the slide content as an SVG file.
public void WriteAsSvg(Stream stream, ISVGOptions svgOptions)Parameters
stream Stream
Target stream
svgOptions ISVGOptions
SVG generation options
Examples
The following code example demonstrates how to convert the first slide from a PowerPoint presentation into an SVG file with options.
using (Presentation pres = new Presentation("pres.pptx"))
{
using (Stream fileStream = System.IO.File.Create("slide_1.svg"))
{
var options = new SVGOptions() { VectorizeText = true };
// Saves the first slide as an SVG file
pres.Slides[0].WriteAsSvg(fileStream, options);
}
}