Table of Contents

Class PdfArray

Namespace
MiPdf.Objects
Assembly
MiPdf.dll

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

items PdfObject[]

PdfArray(IEnumerable<PdfObject>)

Creates an array containing items.

public PdfArray(IEnumerable<PdfObject> items)

Parameters

items IEnumerable<PdfObject>

Properties

Count

The number of elements.

public int Count { get; }

Property Value

int

IsReadOnly

Always false; the array is mutable.

public bool IsReadOnly { get; }

Property Value

bool

this[int]

The raw (possibly indirect) element at the 0-based index. Assigning null stores Instance.

public PdfObject this[int index] { get; set; }

Parameters

index int

Property Value

PdfObject

ObjectType

The kind of this object.

public override PdfObjectType ObjectType { get; }

Property Value

PdfObjectType

Methods

Add(PdfObject)

Appends an element; null is stored as Instance.

public void Add(PdfObject item)

Parameters

item PdfObject

AddRange(IEnumerable<PdfObject>)

Appends several elements; null elements are stored as Instance.

public void AddRange(IEnumerable<PdfObject> items)

Parameters

items IEnumerable<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

PdfObject

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

item PdfObject

Returns

bool

CopyTo(PdfObject[], int)

Copies the raw elements to array, starting at arrayIndex.

public void CopyTo(PdfObject[] array, int arrayIndex)

Parameters

array PdfObject[]
arrayIndex int

FromNumbers(params double[])

Creates an array of real numbers.

public static PdfArray FromNumbers(params double[] values)

Parameters

values double[]

Returns

PdfArray

FromNumbers(params int[])

Creates an array of integer numbers.

public static PdfArray FromNumbers(params int[] values)

Parameters

values int[]

Returns

PdfArray

FromRectangle(PdfRectangle)

Creates a rectangle array [llx lly urx ury] (left, bottom, right, top).

public static PdfArray FromRectangle(PdfRectangle r)

Parameters

r PdfRectangle

Returns

PdfArray

Get(int)

Returns the resolved element at index, or null if out of range.

public PdfObject? Get(int index)

Parameters

index int

Returns

PdfObject

GetArray(int)

Returns the resolved element at index if it is an array, otherwise null.

public PdfArray? GetArray(int index)

Parameters

index int

Returns

PdfArray

GetDictionary(int)

Returns the resolved element at index if it is a dictionary (or stream), otherwise null.

public PdfDictionary? GetDictionary(int index)

Parameters

index int

Returns

PdfDictionary

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

index int
defaultValue double

Returns

double

GetEnumerator()

Enumerates the raw (unresolved) elements.

public IEnumerator<PdfObject> GetEnumerator()

Returns

IEnumerator<PdfObject>

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

index int
defaultValue int

Returns

int

GetName(int)

Returns the resolved element at index if it is a name, otherwise null.

public PdfName? GetName(int index)

Parameters

index int

Returns

PdfName

GetStream(int)

Returns the resolved element at index if it is a stream, otherwise null.

public PdfStream? GetStream(int index)

Parameters

index int

Returns

PdfStream

GetString(int)

Returns the resolved element at index if it is a string, otherwise null.

public PdfString? GetString(int index)

Parameters

index int

Returns

PdfString

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

index int

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

item PdfObject

Returns

int

Insert(int, PdfObject)

Inserts an element at the 0-based index; null is stored as Instance.

public void Insert(int index, PdfObject item)

Parameters

index int
item PdfObject

Remove(PdfObject)

Removes the first occurrence of item; returns false if it was not found.

public bool Remove(PdfObject item)

Parameters

item PdfObject

Returns

bool

RemoveAt(int)

Removes the element at the 0-based index.

public void RemoveAt(int index)

Parameters

index int

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()

Returns

PdfRectangle?