GemBox.Presentation
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PresentationDocument Class

    Namespace:
    GemBox.Presentation
    Assembly:
    GemBox.Presentation.dll

    Represents a presentation.

    This is the root object in the GemBox.Presentation object model.

    • C#
    • VB.NET
    public sealed class PresentationDocument
    Public NotInheritable Class PresentationDocument
    Inheritance:
    System.Object
    PresentationDocument

    Constructors

    PresentationDocument()

    Initializes a new instance of the PresentationDocument class.

    • C#
    • VB.NET
    public PresentationDocument()
    Public Sub New

    Properties

    CustomXmlParts

    Gets the custom XML parts contained in this document.

    • C#
    • VB.NET
    public CustomXmlPartCollection CustomXmlParts { get; }
    Public ReadOnly Property CustomXmlParts As CustomXmlPartCollection
    Property Value
    CustomXmlPartCollection

    The custom XML parts contained in this document.

    DocumentProperties

    Gets the document properties.

    • C#
    • VB.NET
    public DocumentProperties DocumentProperties { get; }
    Public ReadOnly Property DocumentProperties As DocumentProperties
    Property Value
    DocumentProperties

    The document properties.

    MasterNotes

    Gets or sets the master notes slide that is used as a template for all notes slides.

    This value is automatically instantiated when the first notes slide is created with the AddNotes() method.

    This value can be set only to null. Setting this value to null will remove the master notes and all the notes from the presentation.

    • C#
    • VB.NET
    public MasterNotesSlide MasterNotes { get; set; }
    Public Property MasterNotes As MasterNotesSlide
    Property Value
    MasterNotesSlide

    The master notes slide that is used as a template for all notes slides.

    Exceptions
    System.ArgumentException

    Argument is not null.

    MasterSlides

    Gets the master slides.

    • C#
    • VB.NET
    public MasterSlideCollection MasterSlides { get; }
    Public ReadOnly Property MasterSlides As MasterSlideCollection
    Property Value
    MasterSlideCollection

    The master slides.

    ModifyProtection

    Gets the modification protection settings.

    • C#
    • VB.NET
    public ModifyProtection ModifyProtection { get; }
    Public ReadOnly Property ModifyProtection As ModifyProtection
    Property Value
    ModifyProtection

    The modification protection settings.

    Sections

    Gets the sections.

    • C#
    • VB.NET
    public SectionCollection Sections { get; }
    Public ReadOnly Property Sections As SectionCollection
    Property Value
    SectionCollection

    The sections.

    Slides

    Gets the slides.

    • C#
    • VB.NET
    public SlideCollection Slides { get; }
    Public ReadOnly Property Slides As SlideCollection
    Property Value
    SlideCollection

    The slides.

    SlideShow

    Gets the slide show settings.

    • C#
    • VB.NET
    public SlideShowSettings SlideShow { get; }
    Public ReadOnly Property SlideShow As SlideShowSettings
    Property Value
    SlideShowSettings

    The slide show settings.

    SlideSize

    Gets the slide size settings.

    • C#
    • VB.NET
    public SlideSize SlideSize { get; }
    Public ReadOnly Property SlideSize As SlideSize
    Property Value
    SlideSize

    The slide size settings.

    TableStyles

    Gets the table styles.

    • C#
    • VB.NET
    public TableStyleCollection TableStyles { get; }
    Public ReadOnly Property TableStyles As TableStyleCollection
    Property Value
    TableStyleCollection

    The table styles.

    TextContent

    Gets the content range of the current PresentationDocument.

    • C#
    • VB.NET
    public TextRange TextContent { get; }
    Public ReadOnly Property TextContent As TextRange
    Property Value
    TextRange

    The content range of the current PresentationDocument.

    Remarks

    For more information, see Find and Replace example.

    Thumbnail

    Gets or sets the image used to help end-users identify the presentation document.

    • C#
    • VB.NET
    public PictureContent Thumbnail { get; set; }
    Public Property Thumbnail As PictureContent
    Property Value
    PictureContent

    The image used to help end-users identify the presentation document.

    VbaProject

    Represents the VbaProject contained in the PresentationDocument.

    If the PresentationDocument does not have VbaProject contained, it will be created on accessing this property.

    • C#
    • VB.NET
    public VbaProject VbaProject { get; }
    Public ReadOnly Property VbaProject As VbaProject
    Property Value
    VbaProject

    ViewProperties

    Gets the presentation-wide view properties.

    • C#
    • VB.NET
    public ViewProperties ViewProperties { get; }
    Public ReadOnly Property ViewProperties As ViewProperties
    Property Value
    ViewProperties

    The presentation-wide view properties.

    Methods

    Clone()

    Makes a deep clone of this PresentationDocument instance.

    • C#
    • VB.NET
    public PresentationDocument Clone()
    Public Function Clone As PresentationDocument
    Returns
    PresentationDocument

    A deep clone of this PresentationDocument instance.

    Remarks

    Cloning is a process when one or more objects from a presentation are duplicated. Objects can be duplicated to the same or another presentation and to the same or another location (for example, to another slide).

    Cloning methods are available on collection types, such as SlideCollection, DrawingCollection, TextParagraphCollection or TextElementCollection. Exception is the PresentationDocument type that has a Clone() method used to make a deep clone of the entire presentation. Cloning methods available on the collection types have two forms: AddClone(Slide) and InsertClone(Int32, Slide) to append the duplicate to the collection or insert it into a specific location in the collection.

    Objects contained in the presentation can contain references to other objects. For example, Slide contains a reference to its ParentTemplate, Connector can contain a reference to drawings that it connects (BeginConnection and EndConnection), Action can contain a Target to Slide or CustomSlideShow that should be shown when the action is triggered.

    When cloning multiple objects, the desired behavior is to maintain these references in the duplicated objects so that, for example, when Connector is cloned, and later when drawings that it connects are cloned, the duplicated Connector also connects duplicates of the original drawings that are connected.

    This reference mapping between an original object and its duplicate is maintained by the instance of the CloneContext type. CloneContext instance is created with Create(PresentationDocument, PresentationDocument) static method. Each object can be cloned exactly once using the same CloneContext instance. If you want to clone the same object multiple times, each time a new CloneContext instance must be used. CloneContext is the most useful when cloning multiple objects one after another or when you want to change a behavior of the cloning operation.

    Behavior of the cloning operation can be changed by using Set<T>(T, T) method. With this method you can make an explicit mapping between objects and cloning process will respect that mapping. For example, if you are cloning a Slide instance to another PresentationDocument default behavior would be that its parent template LayoutSlide and MasterSlide would also be cloned to another PresentationDocument. This behavior can be changed by making an explicit mapping from the LayoutSlide that is the ParentTemplate of the Slide that will be cloned to some LayoutSlide in the another PresentationDocument that we wish to be a ParentTemplate of the duplicated Slide. Explicit mapping with Set<T>(T, T) method can currently be made between following type (and their derivatives) instances: SlideObject, Drawing, TableStyle and CustomSlideShow.

    ConvertToImageSource(ImageSaveOptions)

    Converts single slide specified in options of this PresentationDocument instance to an System.Windows.Media.ImageSource instance.

    • C#
    • VB.NET
    public ImageSource ConvertToImageSource(ImageSaveOptions options)
    Public Function ConvertToImageSource(options As ImageSaveOptions) As ImageSource
    Parameters
    options
    ImageSaveOptions

    The options used when converting a single presentation's slide to an image.

    Returns
    System.Windows.Media.ImageSource

    A new System.Windows.Media.ImageSource instance created from a single presentation's slide specified in options.

    Remarks

    For more information, see Export PowerPoint in WPF.

    See Also
    ImageSaveOptions

    ConvertToXpsDocument(XpsSaveOptions)

    Converts this PresentationDocument instance to an System.Windows.Xps.Packaging.XpsDocument instance.

    • C#
    • VB.NET
    public XpsDocument ConvertToXpsDocument(XpsSaveOptions options)
    Public Function ConvertToXpsDocument(options As XpsSaveOptions) As XpsDocument
    Parameters
    options
    XpsSaveOptions

    The options used when converting to XML Paper Specification (XPS) document.

    Returns
    System.Windows.Xps.Packaging.XpsDocument

    A New System.Windows.Xps.Packaging.XpsDocument instance created from this PresentationDocument instance.

    See Also
    XpsSaveOptions

    GetPaginator()

    Gets the presentation paginator.

    • C#
    • VB.NET
    public PresentationDocumentPaginator GetPaginator()
    Public Function GetPaginator As PresentationDocumentPaginator
    Returns
    PresentationDocumentPaginator

    The presentation paginator.

    GetPaginator(PaginatorOptions)

    Gets the presentation paginator and updates the presentation based on the specified options.

    • C#
    • VB.NET
    public PresentationDocumentPaginator GetPaginator(PaginatorOptions options)
    Public Function GetPaginator(options As PaginatorOptions) As PresentationDocumentPaginator
    Parameters
    options
    PaginatorOptions

    The paginator options used to specify which parts of the presentation to update while paginating it.

    Returns
    PresentationDocumentPaginator

    The presentation paginator.

    Load(Stream)

    Loads a presentation from the specified stream. This method tries to dynamically determine the file format. If you know the file format, it's faster to use Load(Stream, LoadOptions) method.

    • C#
    • VB.NET
    public static PresentationDocument Load(Stream stream)
    Public Shared Function Load(stream As Stream) As PresentationDocument
    Parameters
    stream
    System.IO.Stream

    The stream from which to load a presentation.

    Returns
    PresentationDocument

    A loaded presentation.

    Load(Stream, LoadOptions)

    Loads a presentation from the specified stream.

    • C#
    • VB.NET
    public static PresentationDocument Load(Stream stream, LoadOptions options)
    Public Shared Function Load(stream As Stream, options As LoadOptions) As PresentationDocument
    Parameters
    stream
    System.IO.Stream

    The stream from which to load a presentation.

    options
    LoadOptions

    The loading options which can be used to define settings for load operation.

    Returns
    PresentationDocument

    A loaded presentation.

    Load(String)

    Loads a presentation from a file with the specified path.

    • C#
    • VB.NET
    public static PresentationDocument Load(string path)
    Public Shared Function Load(path As String) As PresentationDocument
    Parameters
    path
    System.String

    The path from which to load a presentation.

    Returns
    PresentationDocument

    A loaded presentation.

    Load(String, LoadOptions)

    Loads a presentation from a file with the specified path.

    • C#
    • VB.NET
    public static PresentationDocument Load(string path, LoadOptions options)
    Public Shared Function Load(path As String, options As LoadOptions) As PresentationDocument
    Parameters
    path
    System.String

    The path from which to load a presentation.

    options
    LoadOptions

    The loading options which can be used to define settings for load operation.

    Returns
    PresentationDocument

    A loaded presentation.

    Print()

    Prints the presentation to the default printer.

    • C#
    • VB.NET
    public void Print()
    Public Sub Print
    Remarks

    For more information, see Print example.

    Print(String)

    Prints the presentation to the specified printer.

    • C#
    • VB.NET
    public void Print(string printerName)
    Public Sub Print(printerName As String)
    Parameters
    printerName
    System.String

    Printer name.

    Remarks

    For more information, see Print example.

    Print(String, PrintOptions)

    Prints the presentation to the specified printer according to specified options.

    • C#
    • VB.NET
    public void Print(string printerName, PrintOptions options)
    Public Sub Print(printerName As String, options As PrintOptions)
    Parameters
    printerName
    System.String

    Printer name.

    options
    PrintOptions

    Print options.

    Remarks

    For more information, see Print example.

    Save(Stream, SaveOptions)

    Saves the presentation in the specified stream.

    • C#
    • VB.NET
    [ComVisible(false)]
    public void Save(Stream stream, SaveOptions options)
    <ComVisible(False)>
    Public Sub Save(stream As Stream, options As SaveOptions)
    Parameters
    stream
    System.IO.Stream

    The stream in which to save the presentation.

    options
    SaveOptions

    The saving options which can be used to define settings for save operation.

    Save(Object, String)

    Saves the presentation to a System.Web.HttpResponse or System.Web.HttpResponseBase output stream or a System.Net.Http.HttpResponseMessage and sets appropriate HTTP response headers (Content-Type and Content-Disposition).

    • C#
    • VB.NET
    [ComVisible(false)]
    public void Save(object httpResponse, string fileName)
    <ComVisible(False)>
    Public Sub Save(httpResponse As Object, fileName As String)
    Parameters
    httpResponse
    System.Object

    System.Web.HttpResponse object that can be retrieved through the Response property of the System.Web.HttpApplication, System.Web.HttpContext, System.Web.UI.Page or System.Web.UI.UserControl classes or System.Web.HttpResponseBase object or System.Net.Http.HttpResponseMessage object.

    fileName
    System.String

    File name that will be presented in client browser when downloading a file.

    Remarks
    note

    Supported only if updating the whole page with a postback and not if doing partial-page updates (when you use UpdatePanel controls to update selected regions of a page).

    This method accepts System.Object rather than HttpResponse, HttpResponseBase or HttpResponseMessage because otherwise GemBox.Document assembly would have a dependency on System.Web or System.Net.Http assemblies and could not be used in applications which target Client Profile .NET Framework.

    HttpResponse can be retrieved through the Response property of the HttpApplication, HttpContext, Page or UserControl classes.

    For supported file extensions, see remarks for Save(String) method.

    Exceptions
    System.InvalidOperationException

    If file extension is not specified or not supported. If file extension is not recognized, use Save(Object, String, SaveOptions) method overload instead.

    Save(Object, String, SaveOptions)

    Saves the presentation to a System.Web.HttpResponse or System.Web.HttpResponseBase output stream or a System.Net.Http.HttpResponseMessage and sets appropriate HTTP response headers (Content-Type and Content-Disposition).

    • C#
    • VB.NET
    [ComVisible(false)]
    public void Save(object httpResponse, string fileName, SaveOptions options)
    <ComVisible(False)>
    Public Sub Save(httpResponse As Object, fileName As String, options As SaveOptions)
    Parameters
    httpResponse
    System.Object

    System.Web.HttpResponse object that can be retrieved through the Response property of the System.Web.HttpApplication, System.Web.HttpContext, System.Web.UI.Page or System.Web.UI.UserControl classes or System.Web.HttpResponseBase object or System.Net.Http.HttpResponseMessage object.

    fileName
    System.String

    File name that will be presented in client browser when downloading a file.

    options
    SaveOptions

    The saving options which can be used to define settings for save operation.

    Remarks
    note

    Supported only if updating the whole page with a postback and not if doing partial-page updates (when you use UpdatePanel controls to update selected regions of a page).

    This method accepts System.Object rather than HttpResponse, HttpResponseBase or HttpResponseMessage because otherwise GemBox.Document assembly would have a dependency on System.Web or System.Net.Http assemblies and could not be used in applications which target Client Profile .NET Framework.

    HttpResponse can be retrieved through the Response property of the HttpApplication, HttpContext, Page or UserControl classes.

    Save(String)

    Saves the presentation to a file with the specified path. Path must include file extension.

    • C#
    • VB.NET
    [ComVisible(true)]
    public void Save(string path)
    <ComVisible(True)>
    Public Sub Save(path As String)
    Parameters
    path
    System.String

    The path to which to save the presentation.

    Remarks

    File extension that is extracted from the path is used to create the appropriate SaveOptions derived class instance that is then passed to the Save(String, SaveOptions) method.

    Following file extensions are supported:

    • Microsoft PowerPoint: .pptx, pptm, .ppsx, .ppsm, .potx, .potm
    • Portable Document Format: .pdf
    • XML Paper Specification: .xps
    • Image: .bmp, .gif, .jpg, .jpeg, .png, .tif, .tiff, .wdp
    Exceptions
    System.InvalidOperationException

    If file extension is not specified or not supported. If file extension is not recognized, use Save(String, SaveOptions) method overload instead.

    System.PlatformNotSupportedException

    File extension is not supported on the current platform.

    Save(String, SaveOptions)

    Saves the presentation to a file with the specified path.

    • C#
    • VB.NET
    [ComVisible(false)]
    public void Save(string path, SaveOptions options)
    <ComVisible(False)>
    Public Sub Save(path As String, options As SaveOptions)
    Parameters
    path
    System.String

    The path to which to save the presentation.

    options
    SaveOptions

    The saving options which can be used to define settings for save operation.

    SetThumbnail(PictureContentType, Stream)

    Sets the image used to help end-users identify the presentation document.

    • C#
    • VB.NET
    public PictureContent SetThumbnail(PictureContentType contentType, Stream stream)
    Public Function SetThumbnail(contentType As PictureContentType, stream As Stream) As PictureContent
    Parameters
    contentType
    PictureContentType

    Content-type of the image.

    stream
    System.IO.Stream

    The image stream.

    Returns
    PictureContent

    The image used to help end-users identify the presentation document.

    SetThumbnail(String, Stream)

    Sets the image used to help end-users identify the presentation document.

    • C#
    • VB.NET
    public PictureContent SetThumbnail(string contentType, Stream stream)
    Public Function SetThumbnail(contentType As String, stream As Stream) As PictureContent
    Parameters
    contentType
    System.String

    Content-type of the image.

    stream
    System.IO.Stream

    The image stream.

    Returns
    PictureContent

    The image used to help end-users identify the presentation document.

    Exceptions
    System.ArgumentException

    contentType is either System.String.Empty or null.

    Examples

    Document Properties Example
    Slides Example
    Slide Show Example
    Find and Replace example
    Cloning Example
    Export PowerPoint in WPF
    Convert PowerPoint file to PDF in C# and VB.NET
    Open and read PowerPoint file in C# and VB.NET
    Print PowerPoint file in C# and VB.NET
    Create and write PowerPoint file in C# and VB.NET
    Export PowerPoint in ASP.NET
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.