Create a new ArrayElement.

 

   

Syntax
 

[C#]
ArrayElement<T>()
ArrayElement<T>(Atom atom, IndirectObject host)
ArrayElement<T>(IndirectObject obj)
ArrayElement<T>(Element relation, CreationOptions options)

[Visual Basic]
ArrayElement<T>()
ArrayElement<T>(atom As Atom, host As IndirectObject)
ArrayElement<T>(obj As IndirectObject)
ArrayElement<T>(relation As Element, options As CreationOptions)

 

   

Params
 
Name Description
atom The Atom to be assigned to this Element.
host An IndirectObject. This can be any IndirectObject from the Soup but ideally should be one closely associated with the Atom.
obj The IndirectObject to be assigned to this Element.
relation An Element. This can be any Element in the Soup but ideally should be one closely associated with this Element.
options Options related to creation. For example this allows you to determine whether the Element should be created using an IndirectObject rather than just an Atom. If not provided a default set of options is used.

 

   

Notes
 

Create a new ArrayElement.

The different constructors allow different ways of creating an Element. Some are used for wrapping existing Atoms or IndirectObjects and others are for creating new ones.

The constructor taking a relation Element creates a new object in the document - it is typically the constructor you will want to use. Do not specify creation options unless you have very specific needs.

However for your first Element - one you can use as a relation for the others - you will need to wrap an existing IndirectObject inside an Element. For this you might use code of the following form "CatalogElement root = new CatalogElement(doc.ObjectSoup.Catalog)".

The parameterless constructor allows you to create an empty Element. By empty we mean it has no contents - no Atom within it. So before use an Atom must be Assigned or Created. In practice it is easiest to do this using one of the other constructors.

The atom and host constructor is used to wrap an existing Atom. It creates an Element and then Assigns the Atom to it. The result is a specialized Element which can be used to examine or modify the contents of the Atom.

The CreationOptions enumeration may take the following values:

  • Default - Default creation options for this particular type of Element.
  • Indirect - Create Element containing an IndirectObject.
  • Direct - Create Element containing an Atom.

 

   

Example
 

This code snippet is taken from TaggedPDF.cs line 630 in the AccessiblePDF example project.

[C#]
if (parent.EntryK == null)
  parent.EntryK = new ArrayElement<Element>(parent);
if (index > parent.EntryK.Count)
  index = parent.EntryK.Count;
parent.EntryK.Insert(index, element);

[VB]
If parent.EntryK Is Nothing Then
  parent.EntryK = New ArrayElement(Of Element)(parent)
End If
If index > parent.EntryK.Count Then
  index = parent.EntryK.Count
End If
parent.EntryK.Insert(index, element)

This code snippet is taken from Annotations.cs line 81 in the Annotations example project.

[C#]
BorderStyleElement.EntryD = new ArrayElement<Element>(Atom.FromString(value), AnnotationElement.Host);

[VB]
BorderStyleElement.EntryD = New ArrayElement(Of Element)(Atom.FromString(value), AnnotationElement.Host)

This code snippet is taken from Annotations.cs line 310 in the Annotations example project.

[C#]
string partialName, parentName;
List<string> parts = new List<string>(fieldName.Split(new char[] { '.' }));
partialName = parts[parts.Count - 1];
if (string.IsNullOrEmpty(parts[parts.Count - 1]))
  parts.RemoveAt(parts.Count - 1);
parentName = string.Join(".", parts);
FieldElement parent = new FieldElement(Form.Doc.Form[parentName]);
if (parent.EntryKids == null)
  parent.EntryKids = new ArrayElement<FieldElement>();
parent.EntryKids.Add(FieldElement);
FieldElement.EntryParent = parent;
if (!string.IsNullOrEmpty(partialName))
  FieldElement.EntryT = fieldName;

[VB]
Dim partialName, parentName As String
Dim parts As New List(Of String)(fieldName.Split(New Char() { "."c }))
partialName = parts(parts.Count - 1)
If String.IsNullOrEmpty(parts(parts.Count - 1)) Then
  parts.RemoveAt(parts.Count - 1)
End If
parentName = String.Join(".", parts)
Dim parent As New FieldElement(Form.Doc.Form(parentName))
If parent.EntryKids Is Nothing Then
  parent.EntryKids = New ArrayElement(Of FieldElement)()
End If
parent.EntryKids.Add(FieldElement)
FieldElement.EntryParent = parent
If Not String.IsNullOrEmpty(partialName) Then
  FieldElement.EntryT = fieldName
End If

This code snippet is taken from Annotations.cs line 333 in the Annotations example project.

[C#]
int fieldID = FieldElement.Object.ID;
if ((Widgets.Count == 0) || ((Widgets.Count == 1) && (Widgets[0].AnnotationElement.Object.ID == fieldID))) {
  FieldElement.EntryKids = null;
  return;
}
FieldElement.EntryKids = new ArrayElement<FieldElement>(FieldElement);
string ft = null;
Element dv = null;
foreach (WidgetAnnotation widget in Widgets) {
  FieldElement kid = new FieldElement(widget.WidgetElement.Object);
  if (kid.Object.ID != fieldID) { // not the same object
    kid.EntryParent = FieldElement;
    FieldElement.EntryKids.Add(kid);
  }
  if (ft == null)
    ft = kid.EntryFT;
  if (dv == null)
    dv = kid.EntryDV;
  kid.EntryFT = null;
  kid.EntryV = null;
  kid.EntryDV = null;
}
if (ft != null)
  FieldElement.EntryFT = ft;
if (dv != null)
  FieldElement.EntryDV = dv;

[VB]
Dim fieldID As Integer = FieldElement.Object.ID
If (Widgets.Count = 0) OrElse ((Widgets.Count = 1) AndAlso (Widgets(0).AnnotationElement.Object.ID = fieldID)) Then
  FieldElement.EntryKids = Nothing
  Return
End If
FieldElement.EntryKids = New ArrayElement(Of FieldElement)(FieldElement)
Dim ft As String = Nothing
Dim dv As Element = Nothing
For Each widget As WidgetAnnotation In Widgets
  Dim kid As New FieldElement(widget.WidgetElement.Object)
  If kid.Object.ID <> fieldID Then ' not the same object
    kid.EntryParent = FieldElement
    FieldElement.EntryKids.Add(kid)
  End If
  If ft Is Nothing Then
    ft = kid.EntryFT
  End If
  If dv Is Nothing Then
    dv = kid.EntryDV
  End If
  kid.EntryFT = Nothing
  kid.EntryV = Nothing
  kid.EntryDV = Nothing
Next widget
If ft IsNot Nothing Then
  FieldElement.EntryFT = ft
End If
If dv IsNot Nothing Then
  FieldElement.EntryDV = dv
End If