Create a new ResourceElement.




ResourceElement(Atom atom, IndirectObject host)
ResourceElement(IndirectObject obj)
ResourceElement(Element relation, CreationOptions options)

[Visual Basic]
ResourceElement(atom As Atom, host As IndirectObject)
ResourceElement(obj As IndirectObject)
ResourceElement(relation As Element, options As CreationOptions)



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.




Create a new ResourceElement.

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.




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

Doc = inDoc;
CatalogElement cat = new CatalogElement(Doc.ObjectSoup.Catalog);
if (cat.EntryAcroForm == null) {
  cat.EntryAcroForm = new InteractiveFormElement(cat, CreationOptions.Indirect);
  cat.EntryAcroForm.EntryFields = new ArrayElement<FieldElement>(cat);
else { // convert indirect reference to direct one
  if (cat.EntryAcroForm.EntryFields.Ref != null)
    cat.EntryAcroForm.EntryFields = cat.EntryAcroForm.EntryFields;
// add font for text fields
IndirectObject times = Doc.ObjectSoup[Doc.AddFont("Times-Roman")];
if (cat.EntryAcroForm.EntryDR == null)
  cat.EntryAcroForm.EntryDR = new ResourceElement(cat);
if (cat.EntryAcroForm.EntryDR.EntryFont == null)
  cat.EntryAcroForm.EntryDR.EntryFont = new DictElement<FontElement>(cat);
cat.EntryAcroForm.EntryDR.EntryFont["TimesRoman"] = new FontElement(times);
FormElement = cat.EntryAcroForm;

Doc = inDoc
Dim cat As New CatalogElement(Doc.ObjectSoup.Catalog)
If cat.EntryAcroForm Is Nothing Then
  cat.EntryAcroForm = New InteractiveFormElement(cat, CreationOptions.Indirect)
  cat.EntryAcroForm.EntryFields = New ArrayElement(Of FieldElement)(cat)
Else ' convert indirect reference to direct one
  If cat.EntryAcroForm.EntryFields.Ref IsNot Nothing Then
    cat.EntryAcroForm.EntryFields = cat.EntryAcroForm.EntryFields
  End If
End If
' add font for text fields
Dim times As IndirectObject = Doc.ObjectSoup(Doc.AddFont("Times-Roman"))
If cat.EntryAcroForm.EntryDR Is Nothing Then
  cat.EntryAcroForm.EntryDR = New ResourceElement(cat)
End If
If cat.EntryAcroForm.EntryDR.EntryFont Is Nothing Then
  cat.EntryAcroForm.EntryDR.EntryFont = New DictElement(Of FontElement)(cat)
End If
cat.EntryAcroForm.EntryDR.EntryFont("TimesRoman") = New FontElement(times)
FormElement = cat.EntryAcroForm