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

    Show / Hide Table of Contents

    PdfContentElementCollection Class

    Namespace:
    GemBox.Pdf.Content
    Assembly:
    GemBox.Pdf.dll

    Represents a collection of PdfContentElements.

    • C#
    • VB.NET
    public sealed class PdfContentElementCollection : ICollection<PdfContentElement>, IEnumerable<PdfContentElement>, ICollection, IEnumerable
    Public NotInheritable Class PdfContentElementCollection
        Implements ICollection(Of PdfContentElement), IEnumerable(Of PdfContentElement), ICollection, IEnumerable
    Inheritance:
    System.Object
    PdfContentElementCollection
    Implements
    System.Collections.Generic.ICollection<PdfContentElement>
    System.Collections.Generic.IEnumerable<PdfContentElement>
    System.Collections.ICollection
    System.Collections.IEnumerable
    Remarks

    Collection is implemented as doubly linked list.

    Properties

    Count

    Gets the number of PdfContentElements contained in the PdfContentElementCollection.

    • C#
    • VB.NET
    public int Count { get; }
    Public ReadOnly Property Count As Integer
    Property Value
    System.Int32

    The number of PdfContentElements contained in the PdfContentElementCollection.

    First

    Gets the first PdfContentElement of the PdfContentElementCollection.

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

    The first PdfContentElement of the PdfContentElementCollection.

    Last

    Gets the last PdfContentElement of the PdfContentElementCollection.

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

    The last PdfContentElement of the PdfContentElementCollection.

    Methods

    AddAfter(PdfContentElement, PdfContentElement)

    Adds the specified PdfContentElement after the specified existing PdfContentElement in the PdfContentElementCollection.

    • C#
    • VB.NET
    public void AddAfter(PdfContentElement containedElement, PdfContentElement element)
    Public Sub AddAfter(containedElement As PdfContentElement, element As PdfContentElement)
    Parameters
    containedElement
    PdfContentElement

    The PdfContentElement after which to insert element.

    element
    PdfContentElement

    The PdfContentElement to add to the PdfContentElementCollection.

    Exceptions
    System.ArgumentNullException

    containedElement or element is null.

    System.InvalidOperationException

    containedElement does not belong to the current PdfContentElementCollection or element already belongs to a PdfContentElementCollection or to a different PdfDocument than the current PdfContentElementCollection. Use AddClone(PdfContentElement, PdfContentElement) method instead.

    AddBefore(PdfContentElement, PdfContentElement)

    Adds the specified PdfContentElement before the specified existing PdfContentElement in the PdfContentElementCollection.

    • C#
    • VB.NET
    public void AddBefore(PdfContentElement containedElement, PdfContentElement element)
    Public Sub AddBefore(containedElement As PdfContentElement, element As PdfContentElement)
    Parameters
    containedElement
    PdfContentElement

    The PdfContentElement before which to insert element.

    element
    PdfContentElement

    The PdfContentElement to add to the PdfContentElementCollection.

    Exceptions
    System.ArgumentNullException

    containedElement or element is null.

    System.InvalidOperationException

    containedElement does not belong to the current PdfContentElementCollection or element already belongs to a PdfContentElementCollection or to a different PdfDocument than the current PdfContentElementCollection. Use AddClone(PdfContentElement, PdfContentElement) method instead.

    AddClone(PdfContentElement, PdfContentElement)

    Adds a clone of the specified PdfContentElement to the PdfContentElementCollection.

    • C#
    • VB.NET
    public PdfContentElement AddClone(PdfContentElement element, PdfContentElement nextElement = null)
    Public Function AddClone(element As PdfContentElement, nextElement As PdfContentElement = Nothing) As PdfContentElement
    Parameters
    element
    PdfContentElement

    The element whose clone is added to this PdfContentElementCollection.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the clone of the element. If null, the clone of the element is added at the end of the PdfContentElementCollection.

    Returns
    PdfContentElement

    The clone of the specified PdfContentElement added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    System.ArgumentNullException

    The element is null.

    AddClone<TPdfContentElement>(TPdfContentElement, PdfContentElement)

    Adds a clone of the specified TPdfContentElement to the PdfContentElementCollection.

    • C#
    • VB.NET
    public TPdfContentElement AddClone<TPdfContentElement>(TPdfContentElement element, PdfContentElement nextElement = null)
        where TPdfContentElement : PdfContentElement
    Public Function AddClone(Of TPdfContentElement As PdfContentElement)(element As TPdfContentElement, nextElement As PdfContentElement = Nothing) As TPdfContentElement
    Parameters
    element
    TPdfContentElement

    The element whose clone is added to this PdfContentElementCollection.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the clone of the element. If null, the clone of the element is added at the end of the PdfContentElementCollection.

    Returns
    TPdfContentElement

    The clone of the specified TPdfContentElement added to the PdfContentElementCollection.

    Type Parameters
    TPdfContentElement

    The type of the PDF content element.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    System.ArgumentNullException

    The element is null.

    AddFirst(PdfContentElement)

    Adds the specified PdfContentElement at the start of the PdfContentElementCollection.

    • C#
    • VB.NET
    public void AddFirst(PdfContentElement element)
    Public Sub AddFirst(element As PdfContentElement)
    Parameters
    element
    PdfContentElement

    The PdfContentElement to add at the start of the PdfContentElementCollection.

    Exceptions
    System.ArgumentNullException

    element is null.

    System.InvalidOperationException

    element already belongs to a PdfContentElementCollection or to a different PdfDocument than the current PdfContentElementCollection. Use AddClone(PdfContentElement, PdfContentElement) method instead.

    AddForm(PdfForm, PdfContentElement)

    Adds the PdfFormContent that represents a PDF content that is a self-contained description of any sequence of PdfContentElements.

    Use Transform of the returned PdfFormContent to position or transform the PdfFormContent.

    • C#
    • VB.NET
    public PdfFormContent AddForm(PdfForm form, PdfContentElement nextElement = null)
    Public Function AddForm(form As PdfForm, nextElement As PdfContentElement = Nothing) As PdfFormContent
    Parameters
    form
    PdfForm

    The form.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfFormContent. If null, the PdfFormContent is added at the end of the PdfContentElementCollection.

    Returns
    PdfFormContent

    The PdfFormContent added to the PdfContentElementCollection.

    Remarks

    If form is associated with another PdfDocument, this method will automatically clone it and associate the clone with the current PdfDocument.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    System.ArgumentNullException

    The form is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.10 Form XObjects'

    AddGroup(PdfContentElement)

    Adds the PdfContentGroup that represents a group of PDF content elements that are independent from the rest of the surrounding elements.

    Use Transform of the returned PdfContentGroup to position or transform the PdfContentGroup.

    • C#
    • VB.NET
    public PdfContentGroup AddGroup(PdfContentElement nextElement = null)
    Public Function AddGroup(nextElement As PdfContentElement = Nothing) As PdfContentGroup
    Parameters
    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfContentGroup. If null, the PdfContentGroup is added at the end of the PdfContentElementCollection.

    Returns
    PdfContentGroup

    The PdfContentGroup added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.4.2 Graphics State Stack'

    AddImage(PdfImage, PdfContentElement)

    Adds the PdfImageContent that represents a PDF content that is a rectangular array of sample values, each representing a color.

    Use Transform of the returned PdfImageContent to position or transform the PdfImageContent.

    tip

    The preferred way to add an image is by using DrawImage(PdfImage, PdfPoint) methods.

    • C#
    • VB.NET
    public PdfImageContent AddImage(PdfImage image, PdfContentElement nextElement = null)
    Public Function AddImage(image As PdfImage, nextElement As PdfContentElement = Nothing) As PdfImageContent
    Parameters
    image
    PdfImage

    The image.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfImageContent. If null, the PdfImageContent is added at the end of the PdfContentElementCollection.

    Returns
    PdfImageContent

    The PdfImageContent added to the PdfContentElementCollection.

    Remarks

    If image is associated with another PdfDocument, this method will automatically clone it and associate the clone with the current PdfDocument.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    System.ArgumentNullException

    The image is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.9 Images'

    AddLast(PdfContentElement)

    Adds the specified PdfContentElement at the end of the PdfContentElementCollection.

    • C#
    • VB.NET
    public void AddLast(PdfContentElement element)
    Public Sub AddLast(element As PdfContentElement)
    Parameters
    element
    PdfContentElement

    The PdfContentElement to add at the end of the PdfContentElementCollection.

    Exceptions
    System.ArgumentNullException

    element is null.

    System.InvalidOperationException

    element already belongs to a PdfContentElementCollection or to a different PdfDocument than the current PdfContentElementCollection. Use AddClone(PdfContentElement, PdfContentElement) method instead.

    AddMarkEnd(PdfContentElement)

    Adds the PdfContentMark that represents the end of the marked-content sequence.

    This method should be preceded by the AddMarkStart(PdfContentMarkTag, PdfContentElement) method and PdfContentMarks that these methods return limit the added marked-content sequence.

    • C#
    • VB.NET
    public PdfContentMark AddMarkEnd(PdfContentElement nextElement = null)
    Public Function AddMarkEnd(nextElement As PdfContentElement = Nothing) As PdfContentMark
    Parameters
    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfContentMark. If null, the PdfContentMark is added at the end of the PdfContentElementCollection.

    Returns
    PdfContentMark

    The PdfContentMark added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '14.6 Marked Content'

    AddMarkPoint(PdfContentMarkTag, PdfContentElement)

    Adds the PdfContentMark that represents single marked-content point.

    Use GetEditableProperties() of the returned PdfContentMark to set the marked content properties.

    • C#
    • VB.NET
    public PdfContentMark AddMarkPoint(PdfContentMarkTag tag, PdfContentElement nextElement = null)
    Public Function AddMarkPoint(tag As PdfContentMarkTag, nextElement As PdfContentElement = Nothing) As PdfContentMark
    Parameters
    tag
    PdfContentMarkTag

    The marked content tag.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfContentMark. If null, the PdfContentMark is added at the end of the PdfContentElementCollection.

    Returns
    PdfContentMark

    The PdfContentMark added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '14.6 Marked Content'

    AddMarkStart(PdfContentMarkTag, PdfContentElement)

    Adds the PdfContentMark that represents the start of the marked-content sequence.

    Use GetEditableProperties() of the returned PdfContentMark to set the marked content properties.

    This method should be followed by the AddMarkEnd(PdfContentElement) method and PdfContentMarks that these methods return limit the added marked-content sequence.

    • C#
    • VB.NET
    public PdfContentMark AddMarkStart(PdfContentMarkTag tag, PdfContentElement nextElement = null)
    Public Function AddMarkStart(tag As PdfContentMarkTag, nextElement As PdfContentElement = Nothing) As PdfContentMark
    Parameters
    tag
    PdfContentMarkTag

    The marked content tag.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfContentMark. If null, the PdfContentMark is added at the end of the PdfContentElementCollection.

    Returns
    PdfContentMark

    The PdfContentMark added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '14.6 Marked Content'

    AddPath(PdfContentElement)

    Adds the PdfPathContent that represents a geometrical PDF content composed of lines and curves.

    Use methods BeginSubpath(PdfPoint), LineTo(PdfPoint), and BezierTo(PdfPoint, PdfPoint, PdfPoint) of the returned PdfPathContent to define the geometrical content.

    • C#
    • VB.NET
    public PdfPathContent AddPath(PdfContentElement nextElement = null)
    Public Function AddPath(nextElement As PdfContentElement = Nothing) As PdfPathContent
    Parameters
    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfPathContent. If null, the PdfPathContent is added at the end of the PdfContentElementCollection.

    Returns
    PdfPathContent

    The PdfPathContent added to the PdfContentElementCollection.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.5 Path Construction and Painting'

    AddShading(PdfShading, PdfContentElement)

    Adds the PdfShadingContent that represents a PDF content that is a smooth transition between colors.

    • C#
    • VB.NET
    public PdfShadingContent AddShading(PdfShading shading, PdfContentElement nextElement = null)
    Public Function AddShading(shading As PdfShading, nextElement As PdfContentElement = Nothing) As PdfShadingContent
    Parameters
    shading
    PdfShading

    The shading.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfShadingContent. If null, the PdfShadingContent is added at the end of the PdfContentElementCollection.

    Returns
    PdfShadingContent

    The PdfShadingContent added to the PdfContentElementCollection.

    Remarks

    If shading is associated with another PdfDocument, this method will automatically clone it and associate the clone with the current PdfDocument.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection.

    System.ArgumentNullException

    The shading is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.7.4 Shading Patterns'

    AddText(PdfEncodedContentString, PdfBasicFont, Double, PdfContentElement)

    Adds the PdfTextContent that represents a textual PDF content (a sequence of glyphs from the specified font of the specified size).

    Use TextTransform of the returned PdfTextContent to position or transform the PdfTextContent.

    warning

    Note that the font might not contain all the necessary information to correctly position, render and/or convert to Unicode all characters of the encodedText so use this method at your own risk.

    tip

    The preferred way to add a text is by using PdfFormattedText type and DrawText(PdfFormattedText, PdfPoint) methods.

    • C#
    • VB.NET
    public PdfTextContent AddText(PdfEncodedContentString encodedText, PdfBasicFont font, double size, PdfContentElement nextElement = null)
    Public Function AddText(encodedText As PdfEncodedContentString, font As PdfBasicFont, size As Double, nextElement As PdfContentElement = Nothing) As PdfTextContent
    Parameters
    encodedText
    PdfEncodedContentString

    The sequence of character codes, with optionally individually positioned glyphs, that represent a font-encoded text contained in the added PdfTextContent element.

    font
    PdfBasicFont

    The font.

    size
    System.Double

    The size.

    nextElement
    PdfContentElement

    The optional element of this PdfContentElementCollection before which to insert the PdfTextContent. If null, the PdfTextContent is added at the end of the PdfContentElementCollection.

    Returns
    PdfTextContent

    The PdfTextContent added to the PdfContentElementCollection.

    Remarks

    If the font is associated with another PdfDocument, this method will automatically clone it and associate the clone with the current PdfDocument.

    Exceptions
    System.ArgumentException

    The nextElement is not contained in the current PdfContentElementCollection or encodedText is empty or size is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    System.ArgumentNullException

    The font is null.

    See Also
    PDF Specification ISO 32000-1:2008, section '9.4 Text Objects'

    All()

    Gets all PdfContentElements underneath this PdfContentElementCollection using the Identity as the initial transformation and flattening PdfFormContent elements as specified by the FlattenForms static property.

    • C#
    • VB.NET
    public PdfContentElementCollection.AllEnumerable All()
    Public Function All As PdfContentElementCollection.AllEnumerable
    Returns
    PdfContentElementCollection.AllEnumerable

    All PdfContentElements underneath this PdfContentElementCollection.

    All(PdfMatrix)

    Gets all PdfContentElements underneath this PdfContentElementCollection using the specified transform as the initial transformation and flattening PdfFormContent elements as specified by the FlattenForms static property.

    • C#
    • VB.NET
    public PdfContentElementCollection.AllEnumerable All(PdfMatrix transform)
    Public Function All(transform As PdfMatrix) As PdfContentElementCollection.AllEnumerable
    Parameters
    transform
    PdfMatrix

    The initial transformation from the new (transformed) coordinate system to the default (untransformed) coordinate system.

    Returns
    PdfContentElementCollection.AllEnumerable

    All PdfContentElements underneath this PdfContentElementCollection.

    All(PdfMatrix, Boolean)

    Gets all PdfContentElements underneath this PdfContentElementCollection using the specified transform as the initial transformation and flattening PdfFormContent elements as specified by the flattenForms parameter.

    • C#
    • VB.NET
    public PdfContentElementCollection.AllEnumerable All(PdfMatrix transform, bool flattenForms)
    Public Function All(transform As PdfMatrix, flattenForms As Boolean) As PdfContentElementCollection.AllEnumerable
    Parameters
    transform
    PdfMatrix

    The initial transformation from the new (transformed) coordinate system to the default (untransformed) coordinate system.

    flattenForms
    System.Boolean

    If set to true, also gets all PdfContentElements underneath PdfFormContent elements, recursively.

    Returns
    PdfContentElementCollection.AllEnumerable

    All PdfContentElements underneath this PdfContentElementCollection.

    All(Boolean)

    Gets all PdfContentElements underneath this PdfContentElementCollection using the Identity as the initial transformation and flattening PdfFormContent elements as specified by the flattenForms parameter.

    • C#
    • VB.NET
    public PdfContentElementCollection.AllEnumerable All(bool flattenForms)
    Public Function All(flattenForms As Boolean) As PdfContentElementCollection.AllEnumerable
    Parameters
    flattenForms
    System.Boolean

    If set to true, also gets all PdfContentElements underneath PdfFormContent elements, recursively.

    Returns
    PdfContentElementCollection.AllEnumerable

    All PdfContentElements underneath this PdfContentElementCollection.

    Clear()

    Removes all PdfContentElements from the PdfContentElementCollection.

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

    Contains(PdfContentElement)

    Determines whether a PdfContentElement is in the PdfContentElementCollection.

    • C#
    • VB.NET
    public bool Contains(PdfContentElement element)
    Public Function Contains(element As PdfContentElement) As Boolean
    Parameters
    element
    PdfContentElement

    The PdfContentElement to locate in the PdfContentElementCollection.

    Returns
    System.Boolean

    true if element is found in the PdfContentElementCollection; otherwise, false.

    CopyTo(PdfContentElement[], Int32)

    Copies the entire PdfContentElementCollection to a compatible one-dimensional array, starting at the specified index of the target array.

    • C#
    • VB.NET
    public void CopyTo(PdfContentElement[] array, int arrayIndex)
    Public Sub CopyTo(array As PdfContentElement(), arrayIndex As Integer)
    Parameters
    array
    PdfContentElement[]

    The one-dimensional System.Array that is the destination of the PdfContentElements copied from PdfContentElementCollection. The System.Array must have zero-based indexing.

    arrayIndex
    System.Int32

    The zero-based index in array at which copying begins.

    Exceptions
    System.ArgumentNullException

    array is null.

    System.ArgumentOutOfRangeException

    arrayIndex is less than 0 or greater than array's System.Array.Length.

    System.ArgumentException

    The number of PdfContentElements in the source PdfContentElementCollection is greater than the available space from arrayIndex to the end of the destination array.

    GetEnumerator()

    Returns an enumerator that iterates through the PdfContentElementCollection.

    • C#
    • VB.NET
    public PdfContentElementCollection.Enumerator GetEnumerator()
    Public Function GetEnumerator As PdfContentElementCollection.Enumerator
    Returns
    PdfContentElementCollection.Enumerator

    A PdfContentElementCollection.Enumerator for the PdfContentElementCollection.

    Group(PdfContentElement, PdfContentElement)

    Groups the specified range of PdfContentElements into a new PdfContentGroup whose elements are independent from the rest of the surrounding elements.

    All PdfContentElements between the first and the last (inclusive) of this PdfContentElementCollection are moved a new PdfContentGroup that replaces the first in this PdfContentElementCollection.

    Use Transform of the returned PdfContentGroup to position or transform the PdfContentGroup.

    • C#
    • VB.NET
    public PdfContentGroup Group(PdfContentElement first, PdfContentElement last)
    Public Function Group(first As PdfContentElement, last As PdfContentElement) As PdfContentGroup
    Parameters
    first
    PdfContentElement

    The element of this PdfContentElementCollection that represents the first element of a newly added PdfContentGroup.

    last
    PdfContentElement

    The element of this PdfContentElementCollection that represents the last element of a newly added PdfContentGroup.

    Returns
    PdfContentGroup

    A new PdfContentGroup that replaced the first in this PdfContentElementCollection.

    Exceptions
    System.ArgumentNullException

    The first or last is null.

    System.InvalidOperationException

    The first or last is not contained in the current PdfContentElementCollection.

    See Also
    PDF Specification ISO 32000-1:2008, section '8.4.2 Graphics State Stack'

    Remove(PdfContentElement)

    Removes the PdfContentElement from the PdfContentElementCollection.

    • C#
    • VB.NET
    public bool Remove(PdfContentElement element)
    Public Function Remove(element As PdfContentElement) As Boolean
    Parameters
    element
    PdfContentElement

    The PdfContentElement to remove from the PdfContentElementCollection.

    Returns
    System.Boolean

    true if element is successfully removed; otherwise, false. This method also returns false if element was not found in the PdfContentElementCollection.

    RemoveFirst()

    Removes the PdfContentElement at the start of the PdfContentElementCollection.

    • C#
    • VB.NET
    public void RemoveFirst()
    Public Sub RemoveFirst
    Exceptions
    System.InvalidOperationException

    The PdfContentElementCollection is empty.

    RemoveLast()

    Removes the PdfContentElement at the end of the PdfContentElementCollection.

    • C#
    • VB.NET
    public void RemoveLast()
    Public Sub RemoveLast
    Exceptions
    System.InvalidOperationException

    The PdfContentElementCollection is empty.

    Implements

    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.ICollection
    System.Collections.IEnumerable

    Examples

    Form XObjects example
    Content Groups example
    Marked Content example
    Shapes (Paths) example
    Shadings example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.