Class PresentationDocument
- Namespace
- OdfKit.Presentation
- Assembly
- OdfKit.dll
Provides the PresentationDocument API. 提供 PresentationDocument API。
public class PresentationDocument : OdfDocument, IDisposable, IAsyncDisposable
- Inheritance
-
PresentationDocument
- Implements
- Derived
- Inherited Members
Constructors
PresentationDocument()
Initializes a new instance of the PresentationDocument class. 初始化 PresentationDocument 類別的新執行個體。
public PresentationDocument()
PresentationDocument(OdfPackage)
Initializes a new instance of the PresentationDocument class. 初始化 PresentationDocument 類別的新執行個體。
public PresentationDocument(OdfPackage package)
Parameters
packageOdfPackageThe ODF package instance. / Odf 套件執行個體。
Properties
HandoutPage
Gets the presentation handout page. 取得簡報的講義頁面(Handout Page)。
public OdfHandoutPage HandoutPage { get; }
Property Value
Slides
Gets the slide collection. 取得投影片集合。
public OdfSlideCollection Slides { get; }
Property Value
Methods
AddMasterPage(string, OdfMasterPageDefinition)
Adds a slide master page to the presentation. 在簡報中新增一個投影片母片。
public OdfMasterPage AddMasterPage(string name, OdfMasterPageDefinition def)
Parameters
namestringThe master page name. / 母片名稱。
defOdfMasterPageDefinitionThe master page definition and settings. / 母片定義與設定。
Returns
- OdfMasterPage
The added master page instance. / 新增的母片執行個體。
AddMasterPage(string, string)
Adds a master page. 新增母片(Master Page)。
public void AddMasterPage(string name, string pageLayoutName)
Parameters
Exceptions
- ArgumentException
Thrown when an argument is null or an empty string. / 引數為 null 或空字串時拋出。
AddSlide()
Short overload of AddSlide that uses default values for all optional parameters and forwards to the full overload. 便利多載:AddSlide 的所有可選參數使用預設值並轉呼叫最長多載。
public OdfSlide AddSlide()
Returns
AddSlide(string?)
Adds a slide. 新增一張投影片。
public OdfSlide AddSlide(string? name)
Parameters
namestringThe slide name. / 投影片的名稱。
Returns
- OdfSlide
The added slide instance. / 新增的投影片執行個體。
ApplyPresentationPageLayout(int, string)
Applies the named presentation page layout to a slide and instantiates placeholders from its template. 將指定名稱的投影片版面配置套用至投影片,並依範本實例化預留位置。
public void ApplyPresentationPageLayout(int slideIndex, string layoutName)
Parameters
slideIndexintThe slide index. / 投影片索引位置。
layoutNamestringThe layout name from
presentation:page-layout-name. /presentation:page-layout-name的版面配置名稱。
Exceptions
- ArgumentException
Thrown when the specified layout cannot be found. / 找不到指定版面配置時擲出。
BringToFront(string)
Moves a shape to the front of its sibling drawing order. 將圖形移到同層繪圖順序最前方。
public bool BringToFront(string name)
Parameters
namestringThe shape id or name. / 圖形識別碼或名稱。
Returns
Builder()
Creates a new ODP presentation document fluent builder. 建立新的 ODP 簡報文件 Fluent builder。
public static PresentationDocumentBuilder Builder()
Returns
- PresentationDocumentBuilder
A new PresentationDocumentBuilder instance. / 新的 PresentationDocumentBuilder 執行個體。
ClearTemplateUserContent()
Clears template user content. 清除 Template User Content。
protected override void ClearTemplateUserContent()
Remarks
基底實作不做任何事;各文件種類(文字、試算表、簡報、繪圖)於對應的部分類別中覆寫, 依各自的內容模型清除使用者資料。
CloneSlide(int)
Clones the specified slide. 複製指定的投影片。
public OdfSlide CloneSlide(int sourceSlideIndex)
Parameters
sourceSlideIndexintThe source slide index. / 來源投影片的索引位置。
Returns
- OdfSlide
The cloned slide instance. / 複製後的新投影片執行個體。
Exceptions
- ArgumentOutOfRangeException
Thrown when the index is out of range. / 索引超出範圍時拋出。
Create()
Creates a new ODP presentation document. 建立新的 ODP 簡報文件。
public static PresentationDocument Create()
Returns
- PresentationDocument
A new PresentationDocument instance. / 新的 PresentationDocument 執行個體。
CreateFromFlatDocument(FlatPresentationDocument)
Creates an equivalent ODP (ZIP package) presentation document from a FODP flat XML presentation document, with identical content. 從 FODP 扁平 XML 簡報文件建立等價的 ODP(ZIP 封裝)簡報文件,內容完全相同。
public static PresentationDocument CreateFromFlatDocument(FlatPresentationDocument document)
Parameters
documentFlatPresentationDocumentThe source FODP flat XML presentation document. / 來源 FODP 扁平 XML 簡報文件。
Returns
- PresentationDocument
The created PresentationDocument instance. / 建立完成的 PresentationDocument 執行個體。
CreateFromTemplate(PresentationTemplateDocument)
Short overload of CreateFromTemplate that accepts template; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 template;其餘可選參數使用預設值並轉呼叫最長 CreateFromTemplate 多載。
public static PresentationDocument CreateFromTemplate(PresentationTemplateDocument template)
Parameters
templatePresentationTemplateDocument
Returns
CreateFromTemplate(PresentationTemplateDocument, bool)
Creates a new presentation document from the specified presentation template. 從指定的簡報範本文件建立新的簡報文件。
public static PresentationDocument CreateFromTemplate(PresentationTemplateDocument template, bool clearUserContent)
Parameters
templatePresentationTemplateDocumentThe presentation template document. / 簡報範本文件。
clearUserContentboolWhether to clear the text content of each slide in the template while keeping layout and shape structure. / 是否清除範本中各投影片的文字內容,但保留版面配置與形狀結構。
Returns
- PresentationDocument
The created PresentationDocument instance. / 建立完成的 PresentationDocument 執行個體。
CreatePresentationPageLayout(string)
Creates a presentation page layout. 建立新的投影片版面配置(Presentation Page Layout)。
public OdfPresentationPageLayout CreatePresentationPageLayout(string name)
Parameters
namestringThe layout name. / 版面配置名稱。
Returns
- OdfPresentationPageLayout
The added presentation page layout instance. / 新增的投影片版面配置執行個體。
DeleteSlide(int)
Deletes the specified slide. 刪除指定的投影片。
public void DeleteSlide(int slideIndex)
Parameters
slideIndexintThe slide index. / 投影片的索引位置。
Exceptions
- ArgumentOutOfRangeException
Thrown when the index is out of range. / 索引超出範圍時拋出。
FindChildElement(OdfNode, string, string)
Finds a specified child element node. 尋找指定的子元素節點。
public OdfNode? FindChildElement(OdfNode parent, string localName, string nsUri)
Parameters
parentOdfNodeThe parent node to search. / 要尋找的父節點。
localNamestringThe local name. / 區域名稱。
nsUristringThe namespace URI. / 命名空間 URI。
Returns
FindPresentationPageLayout(string)
Finds the specified presentation page layout. 尋找指定的投影片版面配置。
public OdfPresentationPageLayout? FindPresentationPageLayout(string name)
Parameters
namestringThe layout name. / 版面配置名稱。
Returns
- OdfPresentationPageLayout
The presentation page layout instance, or null if it does not exist. / 投影片版面配置執行個體,若不存在則為 null。
GetAnimations()
Gets summaries of animation effects across all slides in the presentation. 取得簡報中所有投影片的動畫效果摘要清單。
public IReadOnlyList<OdfSlideAnimationInfo> GetAnimations()
Returns
GetDefaultContentXml()
Gets the default content XML string. 取得預設的內容 XML 字串。
protected override string GetDefaultContentXml()
Returns
- string
The default content XML string. / 預設的內容 XML 字串。
GetDefaultStylesXml()
Gets the default styles XML string. 取得預設的樣式 XML 字串。
protected override string GetDefaultStylesXml()
Returns
- string
The default styles XML string. / 預設的樣式 XML 字串。
GetLayout(int)
Gets the layout type of the slide at the specified index. 取得指定索引投影片的版面配置型態。
public OdfPresentationLayout GetLayout(int slideIndex)
Parameters
slideIndexintThe slide index. / 投影片索引位置。
Returns
- OdfPresentationLayout
The slide layout type. / 投影片版面配置型態。
GetLayouts()
Gets summaries of layouts across all slides in the presentation. 取得簡報中所有投影片的版面配置摘要清單。
public IReadOnlyList<OdfSlideLayoutInfo> GetLayouts()
Returns
GetMasterPage(string)
Gets an editable slide master by name. 依名稱取得可編輯的投影片母片。
public OdfMasterPage GetMasterPage(string name)
Parameters
namestringThe master page name. / 母片名稱。
Returns
- OdfMasterPage
The matching master page object. / 對應的母片物件。
Exceptions
- ArgumentException
Thrown when no master page with the specified name is found. / 找不到指定名稱的母片時擲出。
GetMasterPages()
Gets the list of all slide master pages in the presentation. 取得簡報中所有投影片母片的清單。
public IReadOnlyList<OdfMasterPage> GetMasterPages()
Returns
- IReadOnlyList<OdfMasterPage>
The master page list ordered by
style:master-pageentries inoffice:master-styles. / 依office:master-styles內style:master-page順序排列的母片清單。
GetPictures()
Gets all pictures across all slides. 取得所有投影片中的圖片。
public IReadOnlyList<OdfPicture> GetPictures()
Returns
- IReadOnlyList<OdfPicture>
The pictures in document order. / 依文件順序排列的圖片。
GetPlaceholderInfos()
Gets summaries of placeholders across all slides in the presentation. 取得簡報中所有投影片的預留位置摘要清單。
public IReadOnlyList<OdfSlidePlaceholderInfo> GetPlaceholderInfos()
Returns
GetPresentationNode()
Gets the presentation root node. 取得簡報的核心節點。
public OdfNode GetPresentationNode()
Returns
- OdfNode
The presentation OdfKit.DOM.OdfNode node. / 簡報的 OdfKit.DOM.OdfNode 節點。
GetPresentationPageLayouts()
Gets summaries for all presentation page layouts in the presentation. 取得簡報中所有投影片版面配置摘要清單。
public IReadOnlyList<OdfPresentationPageLayoutInfo> GetPresentationPageLayouts()
Returns
GetShapes()
Gets all general shapes across all slides. 取得所有投影片中的一般圖形。
public IReadOnlyList<OdfShape> GetShapes()
Returns
- IReadOnlyList<OdfShape>
The shapes in document order. / 依文件順序排列的圖形。
GetSlideSize()
Gets the slide size. 取得投影片尺寸。
public (OdfLength Width, OdfLength Height) GetSlideSize()
Returns
GetSlideTransition(int)
Gets the transition effect of the slide at the specified index. 取得指定索引投影片的切換效果。
public OdfSlideTransition GetSlideTransition(int slideIndex)
Parameters
slideIndexintThe slide index. / 投影片索引位置。
Returns
- OdfSlideTransition
The slide transition type, or None when unset. / 投影片切換效果類型;未設定時為 None。
GetSlideTransitions()
Gets summaries of slides with configured transition effects in the presentation. 取得簡報中所有已設定切換效果的投影片摘要清單。
public IReadOnlyList<OdfSlideTransitionInfo> GetSlideTransitions()
Returns
GetSpeakerNotes()
Gets summaries of speaker notes with content across all slides in the presentation. 取得簡報中所有含內容的主講人備忘錄摘要清單。
public IReadOnlyList<OdfSlideSpeakerNotesInfo> GetSpeakerNotes()
Returns
GetTextBoxes()
Gets all text boxes across all slides. 取得所有投影片中的文字方塊。
public IReadOnlyList<OdfTextBox> GetTextBoxes()
Returns
- IReadOnlyList<OdfTextBox>
The text boxes in document order. / 依文件順序排列的文字方塊。
Load(Stream)
Loads an ODP presentation document from the specified stream. 從指定資料流載入 ODP 簡報文件。
public static PresentationDocument Load(Stream stream)
Parameters
streamStream
Returns
- PresentationDocument
The loaded PresentationDocument instance. / 載入完成的 PresentationDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODP presentation. / 當指定文件不是 ODP 簡報時擲出。
Load(Stream, string?)
Short overload of Load that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 Load 多載。
public static PresentationDocument Load(Stream stream, string? fileName)
Parameters
Returns
Load(string)
Loads an ODP presentation document from the specified path. 從指定路徑載入 ODP 簡報文件。
public static PresentationDocument Load(string path)
Parameters
pathstringThe ODP document path. / ODP 文件路徑。
Returns
- PresentationDocument
The loaded PresentationDocument instance. / 載入完成的 PresentationDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODP presentation. / 當指定文件不是 ODP 簡報時擲出。
LoadAsync(Stream)
Asynchronously loads an ODP presentation document from the specified stream. 非同步從指定資料流載入 ODP 簡報文件。
public static Task<PresentationDocument> LoadAsync(Stream stream)
Parameters
streamStream
Returns
- Task<PresentationDocument>
A task representing the asynchronous load operation, whose result is the loaded PresentationDocument. / 代表非同步載入作業的工作,其結果為載入完成的 PresentationDocument。
LoadAsync(Stream, string?)
Short overload of LoadAsync that accepts stream and fileName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream 與 fileName;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<PresentationDocument> LoadAsync(Stream stream, string? fileName)
Parameters
Returns
LoadAsync(Stream, string?, CancellationToken)
Short overload of LoadAsync that accepts stream, fileName, and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 stream、fileName 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<PresentationDocument> LoadAsync(Stream stream, string? fileName, CancellationToken cancellationToken)
Parameters
streamStreamfileNamestringcancellationTokenCancellationToken
Returns
LoadAsync(Stream, CancellationToken)
Asynchronously loads the document from a stream with a cancellation token. 以取消語彙基元非同步從資料流載入文件。
public static Task<PresentationDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe document stream. / 文件資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<PresentationDocument>
A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的文件。
LoadAsync(string)
Asynchronously loads an ODP presentation document from the specified path. 非同步從指定路徑載入 ODP 簡報文件。
public static Task<PresentationDocument> LoadAsync(string path)
Parameters
pathstring
Returns
- Task<PresentationDocument>
A task representing the asynchronous load operation, whose result is the loaded PresentationDocument. / 代表非同步載入作業的工作,其結果為載入完成的 PresentationDocument。
LoadAsync(string, CancellationToken)
Short overload of LoadAsync that accepts path and cancellationToken; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 path 與 cancellationToken;其餘可選參數使用預設值並轉呼叫最長 LoadAsync 多載。
public static Task<PresentationDocument> LoadAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringcancellationTokenCancellationToken
Returns
MergeContentNodes(OdfDocument, OdfMergeOptions, Dictionary<string, string>)
Merges content nodes from the source document into this document. 合併來源文件的內容節點至本文件中。
protected override void MergeContentNodes(OdfDocument sourceDoc, OdfMergeOptions options, Dictionary<string, string> renameMap)
Parameters
sourceDocOdfDocumentThe source ODF document. / 來源 ODF 文件。
optionsOdfMergeOptionsThe merge options. / 合併設定選項。
renameMapDictionary<string, string>The style rename map. / 樣式名稱變更的對照字典。
Exceptions
- ArgumentException
Thrown when the source document is not a presentation document. / 來源文件非簡報文件時拋出。
MoveAfter(string, string)
Moves a shape after another shape in the same sibling drawing order. 將圖形移到同層繪圖順序中另一個圖形之後。
public bool MoveAfter(string name, string referenceName)
Parameters
namestringThe shape id or name to move. / 要移動的圖形識別碼或名稱。
referenceNamestringThe reference shape id or name. / 參考圖形識別碼或名稱。
Returns
MoveBefore(string, string)
Moves a shape before another shape in the same sibling drawing order. 將圖形移到同層繪圖順序中另一個圖形之前。
public bool MoveBefore(string name, string referenceName)
Parameters
namestringThe shape id or name to move. / 要移動的圖形識別碼或名稱。
referenceNamestringThe reference shape id or name. / 參考圖形識別碼或名稱。
Returns
MoveSlide(int, int)
Moves a slide to a different position. 移動投影片的順序位置。
public void MoveSlide(int fromIndex, int toIndex)
Parameters
fromIndexintThe source slide index. / 來源投影片的索引位置。
toIndexintThe destination slide index. / 目標投影片的索引位置。
Exceptions
- ArgumentOutOfRangeException
Thrown when an index is out of range. / 索引超出範圍時拋出。
ReplaceText(string, string)
Replaces text in all presentation text boxes. 取代所有簡報文字方塊中的文字。
public override void ReplaceText(string search, string replacement)
Parameters
ReplaceTextInTextBoxes(string, string)
Replaces text in all presentation text boxes and returns the changed text box count. 取代所有簡報文字方塊中的文字並傳回已變更的文字方塊數量。
public int ReplaceTextInTextBoxes(string search, string replacement)
Parameters
Returns
- int
The number of changed text boxes. / 已變更的文字方塊數量。
SendToBack(string)
Moves a shape to the back of its sibling drawing order. 將圖形移到同層繪圖順序最後方。
public bool SendToBack(string name)
Parameters
namestringThe shape id or name. / 圖形識別碼或名稱。
Returns
SetLayout(int, OdfPresentationLayout)
Sets the layout type of the slide at the specified index and automatically configures matching placeholders. 設定指定索引投影片的版面配置型態,並自動配置對應的預留位置。
public void SetLayout(int slideIndex, OdfPresentationLayout layout)
Parameters
slideIndexintThe slide index. / 投影片索引位置。
layoutOdfPresentationLayoutThe slide layout type. / 投影片版面配置型態。
SetMasterPage(int, string)
Sets the master page used by the slide at the specified index. 設定指定索引投影片所使用的母片。
public void SetMasterPage(int slideIndex, string masterPageName)
Parameters
SetSlideOrientation(OdfPageOrientation)
Sets the slide orientation. 設定投影片的方向。
public void SetSlideOrientation(OdfPageOrientation orientation)
Parameters
orientationOdfPageOrientationThe slide orientation value. / 投影片方向列舉值。
SetSlideSize(OdfLength, OdfLength)
Sets the slide size. 設定投影片的尺寸。
public void SetSlideSize(OdfLength width, OdfLength height)
Parameters
SetSlideTransition(int, OdfSlideTransition)
Sets the transition effect of the slide at the specified index. 設定指定索引投影片的切換效果。
public void SetSlideTransition(int slideIndex, OdfSlideTransition transition)
Parameters
slideIndexintThe slide index. / 投影片索引位置。
transitionOdfSlideTransitionThe slide transition type. / 投影片切換效果類型。
UpdatePictures(IEnumerable<OdfPictureUpdateRequest>)
Updates presentation pictures by id or name. 依識別碼或名稱更新簡報圖片。
public OdfBatchUpdateResult UpdatePictures(IEnumerable<OdfPictureUpdateRequest> requests)
Parameters
requestsIEnumerable<OdfPictureUpdateRequest>The picture update requests. / 圖片更新要求。
Returns
- OdfBatchUpdateResult
The batch update result. / 批次更新結果。
UpdateShapes(IEnumerable<OdfShapeUpdateRequest>)
Updates presentation shapes by id or name. 依識別碼或名稱更新簡報圖形。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<OdfShapeUpdateRequest> requests)
Parameters
requestsIEnumerable<OdfShapeUpdateRequest>The shape update requests. / 圖形更新要求。
Returns
- OdfBatchUpdateResult
The batch update result. / 批次更新結果。