PdfContentElementCollection Class
Represents a collection of PdfContentElements.
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.ObjectPdfContentElementCollection
Implements
Remarks
Collection is implemented as doubly linked list.
Properties
Count
Gets the number of PdfContentElements contained in the PdfContentElementCollection.
Property Value
- System.Int32
The number of PdfContentElements contained in the PdfContentElementCollection.
First
Gets the first PdfContentElement of the PdfContentElementCollection.
Property Value
The first PdfContentElement of the PdfContentElementCollection.
Last
Gets the last PdfContentElement of the PdfContentElementCollection.
Property Value
The last PdfContentElement of the PdfContentElementCollection.
Methods
AddAfter(PdfContentElement, PdfContentElement)
Adds the specified PdfContentElement after the specified existing PdfContentElement in the PdfContentElementCollection.
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.
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.
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
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.
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.
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.
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
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
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.
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
The PdfContentGroup added to the PdfContentElementCollection.
Exceptions
- System.ArgumentException
The nextElement
is not contained in the current PdfContentElementCollection.
See Also
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.
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
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
AddLast(PdfContentElement)
Adds the specified PdfContentElement at the end of the PdfContentElementCollection.
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.
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
The PdfContentMark added to the PdfContentElementCollection.
Exceptions
- System.ArgumentException
The nextElement
is not contained in the current PdfContentElementCollection.
See Also
AddMarkPoint(PdfContentMarkTag, PdfContentElement)
Adds the PdfContentMark that represents single marked-content point.
Use GetEditableProperties() of the returned PdfContentMark to set the marked content properties.
public PdfContentMark AddMarkPoint(PdfContentMarkTag tag, PdfContentElement nextElement = null)
Public Function AddMarkPoint(tag As PdfContentMarkTag, nextElement As PdfContentElement = Nothing) As PdfContentMark
Parameters
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
The PdfContentMark added to the PdfContentElementCollection.
Exceptions
- System.ArgumentException
The nextElement
is not contained in the current PdfContentElementCollection.
See Also
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.
public PdfContentMark AddMarkStart(PdfContentMarkTag tag, PdfContentElement nextElement = null)
Public Function AddMarkStart(tag As PdfContentMarkTag, nextElement As PdfContentElement = Nothing) As PdfContentMark
Parameters
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
The PdfContentMark added to the PdfContentElementCollection.
Exceptions
- System.ArgumentException
The nextElement
is not contained in the current PdfContentElementCollection.
See Also
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.
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
The PdfPathContent added to the PdfContentElementCollection.
Exceptions
- System.ArgumentException
The nextElement
is not contained in the current PdfContentElementCollection.
See Also
AddShading(PdfShading, PdfContentElement)
Adds the PdfShadingContent that represents a PDF content that is a smooth transition between colors.
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
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
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.
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
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
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.
public PdfContentElementCollection.AllEnumerable All()
Public Function All As PdfContentElementCollection.AllEnumerable
Returns
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.
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
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.
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
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.
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
All PdfContentElements underneath this PdfContentElementCollection.
Clear()
Removes all PdfContentElements from the PdfContentElementCollection.
Contains(PdfContentElement)
Determines whether a PdfContentElement is in the PdfContentElementCollection.
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.
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.
public PdfContentElementCollection.Enumerator GetEnumerator()
Public Function GetEnumerator As PdfContentElementCollection.Enumerator
Returns
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.
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.
The element of this PdfContentElementCollection that represents the last element of a newly added PdfContentGroup.
Returns
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
Remove(PdfContentElement)
Removes the PdfContentElement from the PdfContentElementCollection.
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.
Exceptions
- System.InvalidOperationException
The PdfContentElementCollection is empty.
RemoveLast()
Removes the PdfContentElement at the end of the PdfContentElementCollection.
Exceptions
- System.InvalidOperationException
The PdfContentElementCollection is empty.