Class DrawingDocument
Represents an ODF drawing document. 表示 ODF 繪圖文件(Drawing Document)的類別。
public class DrawingDocument : OdfDocument, IDisposable, IAsyncDisposable
- Inheritance
-
DrawingDocument
- Implements
- Derived
- Inherited Members
Constructors
DrawingDocument()
Initializes a new instance of the DrawingDocument class. 初始化 DrawingDocument 類別的新執行個體。
public DrawingDocument()
DrawingDocument(OdfPackage)
Initializes a new instance of the DrawingDocument class. 初始化 DrawingDocument 類別的新執行個體。
public DrawingDocument(OdfPackage package)
Parameters
packageOdfPackageThe ODF package instance. / Odf 套件執行個體。
Properties
Pages
Gets the collection of drawing pages. 取得繪圖頁面的集合。
public OdfDrawPageCollection Pages { get; }
Property Value
Methods
AddConnector(string, string)
Short overload of AddConnector that accepts startShapeId and endShapeId; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 startShapeId 與 endShapeId;其餘可選參數使用預設值並轉呼叫最長 AddConnector 多載。
public OdfShape AddConnector(string startShapeId, string endShapeId)
Parameters
Returns
AddConnector(string, string, OdfConnectorType)
Creates a connector linking a start shape and an end shape on the drawing document (applied to the default first page). 在繪圖文件上建立起點與終點相連的連接線(套用至預設第一頁)。
public OdfShape AddConnector(string startShapeId, string endShapeId, OdfConnectorType connectorType)
Parameters
startShapeIdstringThe start shape identifier. / 起點圖形識別碼。
endShapeIdstringThe end shape identifier. / 終點圖形識別碼。
connectorTypeOdfConnectorTypeThe connector geometry type. / 連接線幾何類型。
Returns
- OdfShape
The newly added connector shape instance. / 新增的連接線圖形執行個體。
AddCustomShape(string, OdfLength, OdfLength, OdfLength, OdfLength)
Adds a custom shape to the drawing document (applied to the default first page). 在繪圖文件上新增自定義幾何圖形(套用至預設第一頁)。
public OdfShape AddCustomShape(string shapeType, OdfLength x, OdfLength y, OdfLength width, OdfLength height)
Parameters
shapeTypestringThe custom shape type name. / 自定義形狀的類型名稱。
xOdfLengthThe X-axis position. / X 軸座標位置。
yOdfLengthThe Y-axis position. / Y 軸座標位置。
widthOdfLengthThe width. / 寬度。
heightOdfLengthThe height. / 高度。
Returns
- OdfShape
The newly added custom shape instance. / 新增的自定義幾何圖形執行個體。
AddPage()
Short overload of AddPage that uses default values for all optional parameters and forwards to the full overload. 便利多載:AddPage 的所有可選參數使用預設值並轉呼叫最長多載。
public OdfDrawPage AddPage()
Returns
AddPage(string?)
Adds a drawing page. 新增一個繪圖頁面。
public OdfDrawPage AddPage(string? name)
Parameters
namestringThe page name. / 頁面名稱。
Returns
- OdfDrawPage
The newly added drawing page instance. / 新增的繪圖頁面執行個體。
AddPath(string, OdfLength, OdfLength, OdfLength, OdfLength)
Adds a path shape to the drawing document (applied to the default first page). 在繪圖文件上新增路徑圖形(套用至預設第一頁)。
public OdfShape AddPath(string svgPathData, OdfLength x, OdfLength y, OdfLength width, OdfLength height)
Parameters
svgPathDatastringThe SVG path data description string. / SVG path data 路徑描述字串。
xOdfLengthThe X-axis position. / X 軸座標位置。
yOdfLengthThe Y-axis position. / Y 軸座標位置。
widthOdfLengthThe width. / 寬度。
heightOdfLengthThe height. / 高度。
Returns
- OdfShape
The newly added path shape instance. / 新增的路徑圖形執行個體。
AddPolygon(IEnumerable<(OdfLength X, OdfLength Y)>)
Adds a polygon shape to the drawing document (applied to the default first page). 在繪圖文件上新增多邊形圖形(套用至預設第一頁)。
public OdfShape AddPolygon(IEnumerable<(OdfLength X, OdfLength Y)> points)
Parameters
pointsIEnumerable<(OdfLength X, OdfLength Y)>The length-based coordinate collection of polygon vertices. / 多邊形頂點的長度座標集合。
Returns
- OdfShape
The newly added polygon shape instance. / 新增的多邊形圖形執行個體。
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 ODG drawing document fluent builder. 建立新的 ODG 繪圖文件 Fluent builder。
public static DrawingDocumentBuilder Builder()
Returns
- DrawingDocumentBuilder
A new DrawingDocumentBuilder instance. / 新的 DrawingDocumentBuilder 執行個體。
ClearTemplateUserContent()
Clears template user content. 清除 Template User Content。
protected override void ClearTemplateUserContent()
Remarks
基底實作不做任何事;各文件種類(文字、試算表、簡報、繪圖)於對應的部分類別中覆寫, 依各自的內容模型清除使用者資料。
Create()
Creates a new ODG drawing document. 建立新的 ODG 繪圖文件。
public static DrawingDocument Create()
Returns
- DrawingDocument
A new DrawingDocument instance. / 新的 DrawingDocument 執行個體。
CreateFromFlatDocument(FlatGraphicsDocument)
Creates an equivalent ODG (ZIP package) drawing document from a FODG flat XML drawing document, with identical content. 從 FODG 扁平 XML 繪圖文件建立等價的 ODG(ZIP 封裝)繪圖文件,內容完全相同。
public static DrawingDocument CreateFromFlatDocument(FlatGraphicsDocument document)
Parameters
documentFlatGraphicsDocumentThe source FODG flat XML drawing document. / 來源 FODG 扁平 XML 繪圖文件。
Returns
- DrawingDocument
The created DrawingDocument instance. / 建立完成的 DrawingDocument 執行個體。
CreateFromTemplate(GraphicsTemplateDocument)
Short overload of CreateFromTemplate that accepts template; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 template;其餘可選參數使用預設值並轉呼叫最長 CreateFromTemplate 多載。
public static DrawingDocument CreateFromTemplate(GraphicsTemplateDocument template)
Parameters
templateGraphicsTemplateDocument
Returns
CreateFromTemplate(GraphicsTemplateDocument, bool)
Creates a new drawing document from the specified graphics template document. 從指定的繪圖範本文件建立新的繪圖文件。
public static DrawingDocument CreateFromTemplate(GraphicsTemplateDocument template, bool clearUserContent)
Parameters
templateGraphicsTemplateDocumentThe graphics template document. / 繪圖範本文件。
clearUserContentboolWhether to clear the text content of each page in the template while keeping layout and shape structure. / 是否清除範本中各頁面的文字內容,但保留版面配置與形狀結構。
Returns
- DrawingDocument
The created DrawingDocument instance. / 建立完成的 DrawingDocument 執行個體。
FindChildElement(OdfNode, string, string)
Finds a child element. 尋找子元素。
public OdfNode? FindChildElement(OdfNode parent, string localName, string nsUri)
Parameters
parentOdfNodeThe parent node. / 父節點。
localNamestringThe local name of the element. / 元素的區域名稱。
nsUristringThe namespace URI. / 命名空間 URI。
Returns
- OdfNode
The found child element node, or
nullif none is found. / 找到的子元素節點,若無則為null。
GetConnectors()
Gets a summary list of connectors from all drawing pages in the document. 取得文件中所有繪圖頁面的連接線摘要清單。
public IReadOnlyList<OdfConnectorInfo> GetConnectors()
Returns
GetCustomShapes()
Gets a summary list of custom shapes from all drawing pages in the document. 取得文件中所有繪圖頁面的自定義幾何圖形摘要清單。
public IReadOnlyList<OdfCustomShapeInfo> GetCustomShapes()
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 字串。
GetDrawingNode()
Gets the drawing node. 取得繪圖節點。
public OdfNode GetDrawingNode()
Returns
- OdfNode
The drawing's OdfKit.DOM.OdfNode node. / 繪圖的 OdfKit.DOM.OdfNode 節點。
GetGroups()
Gets a summary list of group shapes from all drawing pages in the document. 取得文件中所有繪圖頁面的群組圖形摘要清單。
public IReadOnlyList<OdfGroupInfo> GetGroups()
Returns
GetLayers()
Gets a summary list of layers from all drawing pages in the document. 取得文件中所有繪圖頁面的圖層摘要清單。
public IReadOnlyList<OdfLayerInfo> GetLayers()
Returns
GetPaths()
Gets a summary list of path shapes from all drawing pages in the document. 取得文件中所有繪圖頁面的路徑圖形摘要清單。
public IReadOnlyList<OdfPathInfo> GetPaths()
Returns
GetPictures()
Gets a summary list of pictures from all drawing pages in the document. 取得文件中所有繪圖頁面的圖片摘要清單。
public IReadOnlyList<OdfDrawPictureInfo> GetPictures()
Returns
GetPolygons()
Gets a summary list of polygon shapes from all drawing pages in the document. 取得文件中所有繪圖頁面的多邊形圖形摘要清單。
public IReadOnlyList<OdfPolygonInfo> GetPolygons()
Returns
GetShapeLayerAssignments()
Gets a summary list of shape-to-layer assignments from all drawing pages in the document. 取得文件中所有繪圖頁面的圖形圖層指派摘要清單。
public IReadOnlyList<OdfDrawShapeLayerInfo> GetShapeLayerAssignments()
Returns
GetTextBoxes()
Gets a summary list of text boxes from all drawing pages in the document. 取得文件中所有繪圖頁面的文字方塊摘要清單。
public IReadOnlyList<OdfDrawTextBoxInfo> GetTextBoxes()
Returns
Load(Stream)
Loads an ODG drawing document from the specified stream. 從指定資料流載入 ODG 繪圖文件。
public static DrawingDocument Load(Stream stream)
Parameters
streamStream
Returns
- DrawingDocument
The loaded DrawingDocument instance. / 載入完成的 DrawingDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODG drawing. / 當指定文件不是 ODG 繪圖時擲出。
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 DrawingDocument Load(Stream stream, string? fileName)
Parameters
Returns
Load(string)
Loads an ODG drawing document from the specified path. 從指定路徑載入 ODG 繪圖文件。
public static DrawingDocument Load(string path)
Parameters
pathstringThe ODG document path. / ODG 文件路徑。
Returns
- DrawingDocument
The loaded DrawingDocument instance. / 載入完成的 DrawingDocument 執行個體。
Exceptions
- InvalidOperationException
When the specified document is not an ODG drawing. / 當指定文件不是 ODG 繪圖時擲出。
LoadAsync(Stream)
Asynchronously loads an ODG drawing document from the specified stream. 非同步從指定資料流載入 ODG 繪圖文件。
public static Task<DrawingDocument> LoadAsync(Stream stream)
Parameters
streamStream
Returns
- Task<DrawingDocument>
A task representing the asynchronous load operation, whose result is the loaded DrawingDocument. / 代表非同步載入作業的工作,其結果為載入完成的 DrawingDocument。
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<DrawingDocument> 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<DrawingDocument> 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<DrawingDocument> LoadAsync(Stream stream, CancellationToken cancellationToken)
Parameters
streamStreamThe document stream. / 文件資料流。
cancellationTokenCancellationTokenThe cancellation token. / 取消語彙基元。
Returns
- Task<DrawingDocument>
A task whose result is the loaded document. / 代表非同步載入作業的工作,其結果為載入完成的文件。
LoadAsync(string)
Asynchronously loads an ODG drawing document from the specified path. 非同步從指定路徑載入 ODG 繪圖文件。
public static Task<DrawingDocument> LoadAsync(string path)
Parameters
pathstring
Returns
- Task<DrawingDocument>
A task representing the asynchronous load operation, whose result is the loaded DrawingDocument. / 代表非同步載入作業的工作,其結果為載入完成的 DrawingDocument。
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<DrawingDocument> LoadAsync(string path, CancellationToken cancellationToken)
Parameters
pathstringcancellationTokenCancellationToken
Returns
MergeContentNodes(OdfDocument, OdfMergeOptions, Dictionary<string, string>)
Merges the content nodes of a 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 dictionary mapping renamed style names. / 樣式名稱變更的對照字典。
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
ReplaceText(string, string)
Replaces text in all drawing text boxes. 取代所有繪圖文字方塊中的文字。
public override void ReplaceText(string search, string replacement)
Parameters
ReplaceTextInTextBoxes(string, string)
Replaces text in all drawing 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
UpdatePictures(IEnumerable<OdfPictureUpdateRequest>)
Updates drawing 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 drawing shapes by id or name. 依識別碼或名稱更新繪圖圖形。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<OdfShapeUpdateRequest> requests)
Parameters
requestsIEnumerable<OdfShapeUpdateRequest>The shape update requests. / 圖形更新要求。
Returns
- OdfBatchUpdateResult
The batch update result. / 批次更新結果。
UpdateShapes(IEnumerable<string>)
Short overload of UpdateShapes that accepts names; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 names;其餘可選參數使用預設值並轉呼叫最長 UpdateShapes 多載。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names)
Parameters
namesIEnumerable<string>
Returns
UpdateShapes(IEnumerable<string>, OdfLength?)
Short overload of UpdateShapes that accepts names and x; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 names 與 x;其餘可選參數使用預設值並轉呼叫最長 UpdateShapes 多載。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names, OdfLength? x)
Parameters
namesIEnumerable<string>xOdfLength?
Returns
UpdateShapes(IEnumerable<string>, OdfLength?, OdfLength?)
Short overload of UpdateShapes that accepts names, x, and y; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 names、x 與 y;其餘可選參數使用預設值並轉呼叫最長 UpdateShapes 多載。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names, OdfLength? x, OdfLength? y)
Parameters
namesIEnumerable<string>xOdfLength?yOdfLength?
Returns
UpdateShapes(IEnumerable<string>, OdfLength?, OdfLength?, OdfLength?)
Short overload of UpdateShapes that accepts names, x, y, and width; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 names、x、y 與 width;其餘可選參數使用預設值並轉呼叫最長 UpdateShapes 多載。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names, OdfLength? x, OdfLength? y, OdfLength? width)
Parameters
namesIEnumerable<string>xOdfLength?yOdfLength?widthOdfLength?
Returns
UpdateShapes(IEnumerable<string>, OdfLength?, OdfLength?, OdfLength?, OdfLength?)
Short overload of UpdateShapes that accepts names, x, y, width, and height; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 names、x、y、width 與 height;其餘可選參數使用預設值並轉呼叫最長 UpdateShapes 多載。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names, OdfLength? x, OdfLength? y, OdfLength? width, OdfLength? height)
Parameters
Returns
UpdateShapes(IEnumerable<string>, OdfLength?, OdfLength?, OdfLength?, OdfLength?, string?)
Updates drawing shapes by id or name. 依識別碼或名稱更新繪圖圖形。
public OdfBatchUpdateResult UpdateShapes(IEnumerable<string> names, OdfLength? x, OdfLength? y, OdfLength? width, OdfLength? height, string? layerName)
Parameters
namesIEnumerable<string>The shape ids or names. / 圖形識別碼或名稱。
xOdfLength?The optional X-axis position. / 選用的 X 軸位置。
yOdfLength?The optional Y-axis position. / 選用的 Y 軸位置。
widthOdfLength?The optional width. / 選用的寬度。
heightOdfLength?The optional height. / 選用的高度。
layerNamestringThe optional layer name. / 選用的圖層名稱。
Returns
- OdfBatchUpdateResult
The batch update result. / 批次更新結果。