Class PdfArray
A PDF array. Typed getters resolve indirect references.
public sealed class PdfArray : PdfObject, IList<PdfObject>, ICollection<PdfObject>, IEnumerable<PdfObject>, IEnumerable
- Inheritance
-
PdfArray
- Implements
- Inherited Members
Constructors
PdfArray()
Creates an empty array.
public PdfArray()
PdfArray(params PdfObject[])
Creates an array containing items.
public PdfArray(params PdfObject[] items)
Parameters
itemsPdfObject[]
PdfArray(IEnumerable<PdfObject>)
Creates an array containing items.
public PdfArray(IEnumerable<PdfObject> items)
Parameters
itemsIEnumerable<PdfObject>
Properties
Count
The number of elements.
public int Count { get; }
Property Value
IsReadOnly
Always false; the array is mutable.
public bool IsReadOnly { get; }
Property Value
this[int]
The raw (possibly indirect) element at the 0-based index. Assigning null stores
Instance.
public PdfObject this[int index] { get; set; }
Parameters
indexint
Property Value
ObjectType
The kind of this object.
public override PdfObjectType ObjectType { get; }
Property Value
Methods
Add(PdfObject)
Appends an element; null is stored as Instance.
public void Add(PdfObject item)
Parameters
itemPdfObject
AddRange(IEnumerable<PdfObject>)
Appends several elements; null elements are stored as Instance.
public void AddRange(IEnumerable<PdfObject> items)
Parameters
itemsIEnumerable<PdfObject>
Clear()
Removes all elements.
public void Clear()
Clone()
Creates a deep copy; references are copied as references (not followed).
public override PdfObject Clone()
Returns
Contains(PdfObject)
True if the array contains item. Numbers, names, strings, booleans, null and references are
compared by value, arrays, dictionaries and streams by reference (the same instance); references are not
resolved.
public bool Contains(PdfObject item)
Parameters
itemPdfObject
Returns
CopyTo(PdfObject[], int)
Copies the raw elements to array, starting at arrayIndex.
public void CopyTo(PdfObject[] array, int arrayIndex)
Parameters
FromNumbers(params double[])
Creates an array of real numbers.
public static PdfArray FromNumbers(params double[] values)
Parameters
valuesdouble[]
Returns
FromNumbers(params int[])
Creates an array of integer numbers.
public static PdfArray FromNumbers(params int[] values)
Parameters
valuesint[]
Returns
FromRectangle(PdfRectangle)
Creates a rectangle array [llx lly urx ury] (left, bottom, right, top).
public static PdfArray FromRectangle(PdfRectangle r)
Parameters
Returns
Get(int)
Returns the resolved element at index, or null if out of range.
public PdfObject? Get(int index)
Parameters
indexint
Returns
GetArray(int)
Returns the resolved element at index if it is an array, otherwise null.
public PdfArray? GetArray(int index)
Parameters
indexint
Returns
GetDictionary(int)
Returns the resolved element at index if it is a dictionary (or stream), otherwise null.
public PdfDictionary? GetDictionary(int index)
Parameters
indexint
Returns
GetDouble(int, double)
Returns the resolved number at index, or defaultValue if it is missing or not a number.
public double GetDouble(int index, double defaultValue = 0)
Parameters
Returns
GetEnumerator()
Enumerates the raw (unresolved) elements.
public IEnumerator<PdfObject> GetEnumerator()
Returns
GetInt(int, int)
Returns the resolved number at index as int (see IntValue), or defaultValue if it is missing or not a number.
public int GetInt(int index, int defaultValue = 0)
Parameters
Returns
GetName(int)
Returns the resolved element at index if it is a name, otherwise null.
public PdfName? GetName(int index)
Parameters
indexint
Returns
GetStream(int)
Returns the resolved element at index if it is a stream, otherwise null.
public PdfStream? GetStream(int index)
Parameters
indexint
Returns
GetString(int)
Returns the resolved element at index if it is a string, otherwise null.
public PdfString? GetString(int index)
Parameters
indexint
Returns
Get<T>(int)
Returns the resolved element at index if it is a T, otherwise null.
public T? Get<T>(int index) where T : PdfObject
Parameters
indexint
Returns
- T
Type Parameters
T
IndexOf(PdfObject)
Returns the 0-based index of item, or -1 if it is not in the array (compared like
Contains(PdfObject)).
public int IndexOf(PdfObject item)
Parameters
itemPdfObject
Returns
Insert(int, PdfObject)
Inserts an element at the 0-based index; null is stored as Instance.
public void Insert(int index, PdfObject item)
Parameters
Remove(PdfObject)
Removes the first occurrence of item; returns false if it was not found.
public bool Remove(PdfObject item)
Parameters
itemPdfObject
Returns
RemoveAt(int)
Removes the element at the 0-based index.
public void RemoveAt(int index)
Parameters
indexint
ToDoubleArray()
Returns all elements as numbers; elements that are not numbers become 0.
public double[] ToDoubleArray()
Returns
- double[]
ToRectangle()
Interprets the array as rectangle [llx lly urx ury] and normalizes it.
public PdfRectangle? ToRectangle()