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

    Show / Hide Table of Contents

    DrawingElement Class

    Namespace:
    GemBox.Document.Drawing
    Assembly:
    GemBox.Document.dll

    Represents a base class for all drawings (shapes, text-boxes, pictures, etc.).

    • C#
    • VB.NET
    public abstract class DrawingElement : Inline
    Public MustInherit Class DrawingElement
        Inherits Inline
    Inheritance:
    System.Object
    Element
    Inline
    DrawingElement
    Derived
    Chart
    Group
    PreservedDrawingElement
    Shape
    Remarks

    DrawingElement can contain metadata (non-visual properties) which is available through Metadata property.

    DrawingElement can be positioned in-line with the rest of the document content or floating within document content. For more information, see remarks for Layout property.

    Properties

    CharacterFormat

    Gets or sets the character format.

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

    The character format.

    Remarks

    This property is defined as direct formatting, since it is directly applied to the DrawingElement and supersedes any formatting from styles.

    For more information about character formatting, see character formatting example.

    Hidden

    Gets or sets a value indicating whether this DrawingElement is hidden.

    Default value is false.

    • C#
    • VB.NET
    public bool Hidden { get; set; }
    Public Property Hidden As Boolean
    Property Value
    System.Boolean

    true if DrawingElement is hidden; otherwise, false.

    Layout

    Gets or sets the DrawingElement layout (position and size).

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

    The DrawingElement layout (position and size).

    Remarks

    DrawingElement (Picture, TextBox or Shape) can be embedded / positioned (by using Layout property):

    • In line with the text (InlineLayout type) - affects the line height and layout of its line (like a character glyph of similar size).
    • Floating within the text relative to the page (FloatingLayout type) - affects the layout of its surrounding content which is either wrapped around or in-front / behind the floating element.

    Besides position, embeddable element must also have size specified. DrawingElement's position and size are contained in Layout property.

    Embedded element's layout can be specified by either instantiating appropriate Layout derived type, such as InlineLayout or FloatingLayout, or by using factory methods Inline(Double, Double, LengthUnit) or Floating(HorizontalPosition, VerticalPosition, Size).

    For more information, seeShapes and Layoutarticle.

    Exceptions
    System.ArgumentNullException

    Value is null.

    Metadata

    Gets the metadata (non-visual properties) of this DrawingElement instance.

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

    The metadata (non-visual properties) of this DrawingElement instance.

    Methods

    Clone(Boolean)

    Clones this DrawingElement instance.

    • C#
    • VB.NET
    public DrawingElement Clone(bool cloneDescendants)
    Public Function Clone(cloneDescendants As Boolean) As DrawingElement
    Parameters
    cloneDescendants
    System.Boolean

    If set to true clone all descendants recursively; otherwise clone only current DrawingElement.

    Returns
    DrawingElement

    Cloned DrawingElement.

    Remarks

    Document content element instance can exist only in a one place in the document.

    If you want to insert document content element into some other part of the same document, then clone the element and insert its clone.

    If you want to insert document content element into another document, then you should first import it into another document with Import<T>(T, Boolean, Boolean) method and then insert the imported element.

    For more information, see cloning example.

    FormatDrawing()

    Formats this DrawingElement to its default size so it can be exported to PDF, XPS, image or be printed.

    • C#
    • VB.NET
    public FormattedDrawingElement FormatDrawing()
    Public Function FormatDrawing As FormattedDrawingElement
    Returns
    FormattedDrawingElement

    FormattedDrawingElement that can be exported to PDF, XPS, image or be printed.

    Exceptions
    System.InvalidOperationException

    Drawing cannot be formatted because it doesn't belong to any document.

    FormatDrawing(PaginatorOptions)

    Formats this DrawingElement to its default size so it can be exported to PDF, XPS, image or be printed.

    • C#
    • VB.NET
    public FormattedDrawingElement FormatDrawing(PaginatorOptions options)
    Public Function FormatDrawing(options As PaginatorOptions) As FormattedDrawingElement
    Parameters
    options
    PaginatorOptions

    The options used to specify which parts of the drawing element to update while formatting it.

    Returns
    FormattedDrawingElement

    FormattedDrawingElement that can be exported to PDF, XPS, image or be printed.

    Exceptions
    System.InvalidOperationException

    Drawing cannot be formatted because it doesn't belong to any document.

    FormatDrawing(Double, Double, LengthUnit)

    Formats this DrawingElement to specified size so it can be exported to PDF, XPS, image or be printed.

    • C#
    • VB.NET
    public FormattedDrawingElement FormatDrawing(double width, double height, LengthUnit unit)
    Public Function FormatDrawing(width As Double, height As Double, unit As LengthUnit) As FormattedDrawingElement
    Parameters
    width
    System.Double

    The formatted drawing width.

    height
    System.Double

    The formatted drawing height.

    unit
    LengthUnit

    The formatted drawing width / height length unit.

    Returns
    FormattedDrawingElement

    FormattedDrawingElement that can be exported to PDF, XPS, image or be printed.

    Exceptions
    System.InvalidOperationException

    Drawing cannot be formatted because it doesn't belong to any document.

    FormatDrawing(Double, Double, LengthUnit, PaginatorOptions)

    Formats this DrawingElement to specified size so it can be exported to PDF, XPS, image or be printed.

    • C#
    • VB.NET
    public FormattedDrawingElement FormatDrawing(double width, double height, LengthUnit unit, PaginatorOptions options)
    Public Function FormatDrawing(width As Double, height As Double, unit As LengthUnit, options As PaginatorOptions) As FormattedDrawingElement
    Parameters
    width
    System.Double

    The formatted drawing width.

    height
    System.Double

    The formatted drawing height.

    unit
    LengthUnit

    The formatted drawing width / height length unit.

    options
    PaginatorOptions

    The options used to specify which parts of the drawing element to update while formatting it.

    Returns
    FormattedDrawingElement

    FormattedDrawingElement that can be exported to PDF, XPS, image or be printed.

    Exceptions
    System.InvalidOperationException

    Drawing cannot be formatted because it doesn't belong to any document.

    Inherited Properties

    Content

    Gets the content of the current Element.

    (Inherited from Element)

    Document

    Gets the owner document.

    (Inherited from Element)

    ElementType

    Gets the ElementType of this Element instance.

    (Inherited from Element)

    Parent

    Gets the parent of this Element instance.

    (Inherited from Element)

    ParentCollection

    Gets the InlineCollection that contains this Inline instance.

    (Inherited from Inline)

    Revision

    Gets or sets the revision information for the inline.

    (Inherited from Inline)

    Inherited Methods

    GetChildElements(System.Boolean)

    Gets the child elements.

    (Inherited from Element)

    GetChildElements(System.Boolean, ElementType[])

    Gets the child elements filtered by ElementType.

    (Inherited from Element)

    GetParentElements()

    Gets the parent elements.

    (Inherited from Element)

    GetParentElements(ElementType[])

    Gets the parent elements.

    (Inherited from Element)

    Examples

    Shapes example
    Text Boxes example
    Pictures example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.