[]
        
(Showing Draft Content)

GrapeCity.Documents.Pdf.Spec.IPdfArrayExt

Class IPdfArrayExt

Namespace
GrapeCity.Documents.Pdf.Spec
Assembly
GcDocs.Pdf.dll

Contains extension methods for the IPdfArray interface, allows working with PdfArray and PdfArrayObject in the same way.

public static class IPdfArrayExt
Inheritance
object
IPdfArrayExt
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Methods

Add(IPdfArray, IPdfObject)

Adds an item to the IPdfArray.

public static void Add(this IPdfArray array, IPdfObject item)

Parameters

array IPdfArray

The current PDF array.

item GrapeCity.Documents.Pdf.Spec.IPdfObject

The GrapeCity.Documents.Pdf.Spec.IPdfObject to add.

AddString(IPdfArray, string)

Adds a string to the IPdfArray.

public static IPdfObject AddString(this IPdfArray array, string value)

Parameters

array IPdfArray

The current array.

value string

The string.

Returns

GrapeCity.Documents.Pdf.Spec.IPdfObject

AsArray<T>(IPdfArray)

Converts all elements of this IPdfArray to T, and copies the converted values to a new array of T.

Returns null if some elements can't be converted to a T.

public static T[] AsArray<T>(this IPdfArray array) where T : IPdfObject

Parameters

array IPdfArray

The current array.

Returns

T[]

An array of T containing all values from this array.

Type Parameters

T

AsBoolArray(IPdfArray)

Converts all elements of this IPdfArray to bool values, and copies the converted values to a new array of bool.

Returns null if some elements can't be converted to a bool.

public static bool[] AsBoolArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

bool[]

An array of bool containing all values from this array.

AsDictArray(IPdfArray)

Converts all elements of this IPdfArray to IPdfDict, and copies the converted values to a new array of IPdfDict.

Returns null if some elements can't be converted to a IPdfDict.

public static IPdfDict[] AsDictArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

IPdfDict[]

An array of IPdfDict containing all values from this array.

AsFloatArray(IPdfArray)

Converts all elements of this IPdfArray to float values, and copies the converted values to a new array of floats.

Returns null if some elements can't be converted to an float.

public static float[] AsFloatArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

float[]

An array of floats containing all values from this array.

AsIntArray(IPdfArray)

Converts all elements of this IPdfArray to integer values, and copies the converted values to a new array of integers.

Returns null if some elements can't be converted to an integer.

public static int[] AsIntArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

int[]

An array of integers containing all values from this array.

AsNameArray(IPdfArray)

Converts all elements of this IPdfArray to PdfName, and copies the converted values to a new array of PdfName.

Returns null if some elements can't be converted to a PdfName.

public static PdfName[] AsNameArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

PdfName[]

An array of PdfName containing all values from this array.

AsNameArrayStr(IPdfArray)

Converts all elements of this IPdfArray to PdfName, and copies the converted values to a new array of string.

Returns null if some elements can't be converted to a PdfName.

public static string[] AsNameArrayStr(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

string[]

An array of string containing all values from this array.

AsRefArray(IPdfArray, bool)

Converts all elements of this IPdfArray to IPdfRef, and copies the converted values to a new array of IPdfRef.

Returns null if some elements can't be converted to a IPdfRef.

public static IPdfRef[] AsRefArray(this IPdfArray array, bool allowNull = false)

Parameters

array IPdfArray

The current array.

allowNull bool

Indicates whether the IPdfNull should be processed as valid value and converted to null.

Returns

IPdfRef[]

An array of IPdfRef containing all values from this array.

AsStringArray(IPdfArray)

Converts all elements of this IPdfArray to string values, and copies the converted values to a new array of strings.

Returns null if some elements can't be converted to a string.

public static string[] AsStringArray(this IPdfArray array)

Parameters

array IPdfArray

The current array.

Returns

string[]

An array of strings containing all values from this array.

Clear(IPdfArray)

Clears the IPdfArray.

public static void Clear(this IPdfArray array)

Parameters

array IPdfArray

The current PDF array.

Count(IPdfArray)

Gets the count of items in the IPdfArray.

public static int Count(this IPdfArray array)

Parameters

array IPdfArray

The current PDF array.

Returns

int

The count of items.

Get<T>(IPdfArray, int, bool)

Gets the value at the specified index, returns a null if the value cannot be converted to a T. Note! This method returns IPdfRef if T is IPdfRef, otherwise the method resolves the reference and returns actual object. Use GetItem(IPdfArray, int) method if you want to return "raw" value without any post-processing.

public static T Get<T>(this IPdfArray array, int index, bool addWarning = true) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to the T.

Returns

T

The value with the specified index.

Type Parameters

T

GetArray<T>(IPdfArray, int, bool, bool, bool)

Gets the array of T objects at the specified index. Returns null if the array does not exist or cannot be converted to an array of T.

public static T[] GetArray<T>(this IPdfArray array, int index, bool singleToArray, bool allowNulls, bool addWarning) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

singleToArray bool

Indicates whether to convert a single T value to an array.

allowNulls bool

Indicates whether to handle IPdfNull as null.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.

Returns

T[]

The array associated with the specified key, or null.

Type Parameters

T

GetEnum<T>(IPdfArray, int, T)

Gets the enum value at the specified index. If the value does not exist or cannot be converted to an enum, returns defValue.

public static T GetEnum<T>(this IPdfArray array, int index, T defValue) where T : struct

Parameters

array IPdfArray

The current array.

index int

The value index.

defValue T

The default value.

Returns

T

The value at the specified index, or defValue.

Type Parameters

T

GetEnum<T>(IPdfArray, int, T?)

Gets the nullable enum value at the specified index. If the value does not exist or cannot be converted to an enum, returns defValue (which can be null).

public static T? GetEnum<T>(this IPdfArray array, int index, T? defValue) where T : struct

Parameters

array IPdfArray

The current array.

index int

The value index.

defValue T?

The default value.

Returns

T?

The value at the specified index, or defValue.

Type Parameters

T

GetFloat(IPdfArray, int, float?)

Gets the float value at the specified index.

If the value cannot be converted to a float, returns defValue and adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog.

public static float? GetFloat(this IPdfArray array, int index, float? defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the item to return.

defValue float?

The default value.

Returns

float?

The value at the specified index.

GetFloat(IPdfArray, int, float)

Gets the float value at the specified index.

Returns defValue if the value cannot be converted to a float.

public static float GetFloat(this IPdfArray array, int index, float defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the item to return.

defValue float

The default value.

Returns

float

The value at the specified index.

GetFloatArray(IPdfArray, int, bool)

Gets the Float array at the specified index.

public static float[] GetFloatArray(this IPdfArray array, int index, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

singleToArray bool

Indicates whether to convert a single Float value to an array.

Returns

float[]

The array at the specified key, or null.

GetInt(IPdfArray, int, int)

Gets the int value at the specified index.

Returns defValue if the value cannot be converted to an int.

public static int GetInt(this IPdfArray array, int index, int defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the item to return.

defValue int

The default value.

Returns

int

The value at the specified index.

GetInt(IPdfArray, int, int?)

Gets the nullable int value at the specified index.

Returns defValue if the value cannot be converted to an int.

public static int? GetInt(this IPdfArray array, int index, int? defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the item to return.

defValue int?

The default value.

Returns

int?

The value at the specified index.

GetIntArray(IPdfArray, int, bool)

Gets the Integer array at the specified index.

public static int[] GetIntArray(this IPdfArray array, int index, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

singleToArray bool

Indicates whether to convert a single Integer value to an array.

Returns

int[]

The array at the specified key, or null.

GetItem(IPdfArray, int)

Gets an item at specified index.

public static IPdfObject GetItem(this IPdfArray array, int index)

Parameters

array IPdfArray

The current array.

index int

The item index.

Returns

GrapeCity.Documents.Pdf.Spec.IPdfObject

The GrapeCity.Documents.Pdf.Spec.IPdfObject with specified index.

GetName(IPdfArray, int, string)

Gets the PDF name at the specified index as a string.

Returns defValue if the value cannot be converted to a string.

public static string GetName(this IPdfArray array, int index, string defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the item to return.

defValue string

The default value.

Returns

string

The value at the specified index.

GetNameArray(IPdfArray, int, bool)

Gets the PDF Name array at the specified index.

public static PdfName[] GetNameArray(this IPdfArray array, int index, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

singleToArray bool

Indicates whether to convert a single PDF Name value to an array.

Returns

PdfName[]

The array at the specified key, or null.

GetNameArrayStr(IPdfArray, int, bool)

Gets the PDF Name array at the specified index, the PDF Name array represented as string.

public static string[] GetNameArrayStr(this IPdfArray array, int index, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

singleToArray bool

Indicates whether to convert a single PDF Name value to an array.

Returns

string[]

The array at the specified key, or null.

GetPdfStringBytes(IPdfArray, int)

Gets the bytes of the IPdfString at the specified index. If the value does not exist or cannot be converted to an IPdfString, returns null.

public static byte[] GetPdfStringBytes(this IPdfArray array, int index)

Parameters

array IPdfArray

The current array.

index int

The index of the string to return.

Returns

byte[]

The value at the specified index.

GetString(IPdfArray, int, string)

Gets the string at the specified index.

Returns defValue if the value cannot be converted to a string.

public static string GetString(this IPdfArray array, int index, string defValue)

Parameters

array IPdfArray

The current array.

index int

The index of the string to return.

defValue string

The default value.

Returns

string

The value at the specified index.

Insert(IPdfArray, int, IPdfObject)

Insert an item into IPdfArray.

public static void Insert(this IPdfArray array, int index, IPdfObject item)

Parameters

array IPdfArray

The current PDF array.

index int

The index of item.

item GrapeCity.Documents.Pdf.Spec.IPdfObject

The item to insert.

RemoveAt(IPdfArray, int)

Removes an item with specified index.

public static void RemoveAt(this IPdfArray array, int index)

Parameters

array IPdfArray

The current PDF array.

index int

The index of an item to remove.

RemoveRange(IPdfArray, int, int)

Removes a range of items.

public static void RemoveRange(this IPdfArray array, int startIndex, int count = -1)

Parameters

array IPdfArray

The current PDF array.

startIndex int

The index of start item.

count int

The count of items to remove.

Set(IPdfArray, int, IPdfObject)

Sets the value at the specified index.

public static void Set(this IPdfArray array, int index, IPdfObject item)

Parameters

array IPdfArray

The current IPdfArray.

index int

The value index.

item GrapeCity.Documents.Pdf.Spec.IPdfObject

The value to set.

SetCount(IPdfArray, int)

Sets the count of items in the array to a specified value. If the current count of items is less than count, pads the array with Instance objects. If the current count is greater than count, removes items from the end of the array.

public static void SetCount(this IPdfArray array, int count)

Parameters

array IPdfArray

The current PDF array.

count int

The required item count.

SetPdfStringBytes(IPdfArray, int, byte[])

Sets the IPdfString at the specified index. If the value is null, sets the item to PdfNull.

public static PdfString SetPdfStringBytes(this IPdfArray array, int index, byte[] value)

Parameters

array IPdfArray

The current array.

index int

The index of the item to set.

value byte[]

The value to set.

Returns

PdfString

The created PdfString

SetSilent(IPdfArray, int, IPdfObject)

Sets a value associated with a specified index. This method does not affect the value of Changed property.

public static void SetSilent(this IPdfArray array, int index, IPdfObject item)

Parameters

array IPdfArray

The current IPdfArray.

index int

The index of the value to set.

item GrapeCity.Documents.Pdf.Spec.IPdfObject

The value to set.

TryAsArray<T>(IPdfArray, out T[], bool, bool)

Tries to convert all elements of this IPdfArray to T, and copies the converted values to a new array of T. Returns true if all elements can be converted to a T or they are PDF Null and allowNulls is true.

public static bool TryAsArray<T>(this IPdfArray array, out T[] values, bool allowNulls, bool addWarning) where T : IPdfObject

Parameters

array IPdfArray

The current array.

values T[]

OUT: The array of T.

allowNulls bool

Indicates whether the IPdfNull should be handled as valid value and converted to null.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.

Returns

bool

Returns true if no errors occur.

Type Parameters

T

TryAsRect(IPdfArray, out IPdfNumber, out IPdfNumber, out IPdfNumber, out IPdfNumber)

Tries to convert the array to rectangle, the array should have 4 elements and all are numbers.

public static bool TryAsRect(this IPdfArray array, out IPdfNumber left, out IPdfNumber bottom, out IPdfNumber right, out IPdfNumber top)

Parameters

array IPdfArray

The current array.

left IPdfNumber

OUT: The X of left-bottom corner.

bottom IPdfNumber

OUT: The Y of left-bottom corner.

right IPdfNumber

OUT: The X of right-top corner.

top IPdfNumber

OUT: The Y of right-top corner.

Returns

bool

TryGet<T>(IPdfArray, int, out T, bool)

Tries to get the value at the specified index. Note! This method returns IPdfRef if T is IPdfRef, otherwise the method resolves the reference and returns actual object.

public static bool TryGet<T>(this IPdfArray array, int index, out T value, bool addWarning = true) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value T

OUT: The value at specified index.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to the T.

Returns

bool

true if successful; false otherwise.

Type Parameters

T

TryGet<T>(IPdfArray, int, out T, out bool, bool)

Tries to get the value at the specified index. Returns true if value exists and can be converted to a T, resolves a PDF reference if needed. Note! The method does not resolve reference if T is IPdfRef, otherwise the method resolves the reference and returns actual object.

public static bool TryGet<T>(this IPdfArray array, int index, out T value, out bool isNull, bool addWarning) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value T

OUT: The value.

isNull bool

OUT: Indicates whether the value is PDF null.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.

Returns

bool

Returns true if no errors occur.

Type Parameters

T

TryGetArray<T>(IPdfArray, int, out T[], bool, bool, bool)

Tries to get the array of T objects at the specified index.

public static bool TryGetArray<T>(this IPdfArray array, int index, out T[] value, bool singleToArray, bool allowNulls, bool addWarning) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value T[]

OUT: The array of T.

singleToArray bool

Indicates whether to convert a single T value to an array.

allowNulls bool

Indicates whether to handle IPdfNull as null.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.

Returns

bool

Returns true if no errors occur.

Type Parameters

T

TryGetArray<T>(IPdfArray, int, out T[], bool)

Tries to get the array at the specified index, if the value does not exist or cannot be converted to an array of T returns false.

public static bool TryGetArray<T>(this IPdfArray array, int index, out T[] value, bool singleToArray = false) where T : IPdfObject

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value T[]

OUT: The value.

singleToArray bool

Indicates whether to convert a single T value to an array.

Returns

bool

true if value exists, false otherwise.

Type Parameters

T

TryGetBool(IPdfArray, int, out bool)

Tries to get the bool value with the specified index.

public static bool TryGetBool(this IPdfArray array, int index, out bool value)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value bool

OUT: The integer value.

Returns

bool

true if value exists and can be converted to an bool; otherwise false.

TryGetEnum<T>(IPdfArray, int, out T)

Tries to get the enum value at the specified index. If the value does not exist or cannot be converted to an enum, returns false.

public static bool TryGetEnum<T>(this IPdfArray array, int index, out T value) where T : struct

Parameters

array IPdfArray

The current array.

index int

The value index.

value T

OUT. When this method returns, contains the enum value.

Returns

bool

true if value exists; otherwise, false.

Type Parameters

T

TryGetFloat(IPdfArray, int, out float?, bool)

Tries to get the nullable float value at the specified index.

public static bool TryGetFloat(this IPdfArray array, int index, out float? value, bool addWarning = true)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value float?

OUT: The float value.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.

Returns

bool

true if value exists and can be converted to a float; otherwise false.

TryGetFloat(IPdfArray, int, out float, bool)

Tries to get the float value at the specified index.

public static bool TryGetFloat(this IPdfArray array, int index, out float value, bool addWarning = true)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value float

OUT: The float value.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.

Returns

bool

true if value exists and can be converted to a float; otherwise false.

TryGetFloatArray(IPdfArray, int, out float[], bool)

Tries to get the Float array at the specified index.

public static bool TryGetFloatArray(this IPdfArray array, int index, out float[] value, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value float[]

OUT: The float array.

singleToArray bool

Indicates whether to convert a single Float value to an array.

Returns

bool

true if value at specified index can be converted to a float array; otherwise false.

TryGetInt(IPdfArray, int, out int, bool)

Tries to get the int value at the specified index.

public static bool TryGetInt(this IPdfArray array, int index, out int value, bool addWarning = true)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value int

OUT: The integer value.

addWarning bool

Indicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.

Returns

bool

true if value exists and can be converted to an int; otherwise false.

TryGetIntArray(IPdfArray, int, out int[], bool)

Tries to get the Integer array at the specified index.

public static bool TryGetIntArray(this IPdfArray array, int index, out int[] value, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value int[]

OUT: The integer array.

singleToArray bool

Indicates whether to convert a single Integer value to an array.

Returns

bool

true if value at specified index can be converted to an integer array; otherwise false.

TryGetName(IPdfArray, int, out string)

Tries to get the PDF name value with the specified index as a string.

public static bool TryGetName(this IPdfArray array, int index, out string value)

Parameters

array IPdfArray

The current IPdfArray.

index int

The index of the value to get.

value string

OUT: The string value.

Returns

bool

true if value exists and can be converted to a PDF name; otherwise false.

TryGetNameArray(IPdfArray, int, out PdfName[], bool)

Tries to get the PDF Name array at the specified index.

public static bool TryGetNameArray(this IPdfArray array, int index, out PdfName[] value, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value PdfName[]

OUT: The PDF Name array.

singleToArray bool

Indicates whether to convert a single PDF Name value to an array.

Returns

bool

true if value at specified index can be converted to an integer array; otherwise false.

TryGetNameArrayStr(IPdfArray, int, out string[], bool)

Tries to get the PDF Name array at the specified index, the PDF Name array represented as string.

public static bool TryGetNameArrayStr(this IPdfArray array, int index, out string[] value, bool singleToArray = false)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value string[]

OUT: The string array.

singleToArray bool

Indicates whether to convert a single PDF Name value to an array.

Returns

bool

true if value at specified index can be converted to an integer array; otherwise false.

TryGetString(IPdfArray, int, out string)

Tries to get the string value with the specified index.

public static bool TryGetString(this IPdfArray array, int index, out string value)

Parameters

array IPdfArray

The current array.

index int

The index of the value to get.

value string

OUT: The string value.

Returns

bool

true if value exists and can be converted to a string; otherwise false.