[]
Contains extension methods for the IPdfArray interface, allows working with PdfArray and PdfArrayObject in the same way.
public static class IPdfArrayExt
Adds an item to the IPdfArray.
public static void Add(this IPdfArray array, IPdfObject item)
array
IPdfArrayThe current PDF array.
item
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe GrapeCity.Documents.Pdf.Spec.IPdfObject to add.
Adds a string to the IPdfArray.
public static IPdfObject AddString(this IPdfArray array, string value)
array
IPdfArrayThe current array.
value
stringThe string.
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
array
IPdfArrayThe current array.
An array of T
containing all values from this array.
T
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)
array
IPdfArrayThe current array.
An array of bool containing all values from this array.
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)
array
IPdfArrayThe current array.
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)
array
IPdfArrayThe current array.
An array of floats containing all values from this array.
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)
array
IPdfArrayThe current array.
An array of integers containing all values from this array.
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)
array
IPdfArrayThe current array.
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)
array
IPdfArrayThe current array.
An array of string containing all values from this array.
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)
array
IPdfArrayThe current array.
allowNull
boolIndicates whether the IPdfNull should be processed as valid value and converted to null.
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)
array
IPdfArrayThe current array.
An array of strings containing all values from this array.
Clears the IPdfArray.
public static void Clear(this IPdfArray array)
array
IPdfArrayThe current PDF array.
Gets the count of items in the IPdfArray.
public static int Count(this IPdfArray array)
array
IPdfArrayThe current PDF array.
The count of items.
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog
if value at the specified index can't be converted to the T
.
The value with the specified index.
T
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
singleToArray
boolIndicates whether to convert a single T
value to an array.
allowNulls
boolIndicates whether to handle IPdfNull as null.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.
The array associated with the specified key, or null.
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
array
IPdfArrayThe current array.
index
intThe value index.
defValue
TThe default value.
The value at the specified index, or defValue
.
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
array
IPdfArrayThe current array.
index
intThe value index.
defValue
T?The default value.
The value at the specified index, or defValue
.
T
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)
array
IPdfArrayThe current array.
index
intThe index of the item to return.
defValue
float?The default value.
The value at the specified index.
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)
array
IPdfArrayThe current array.
index
intThe index of the item to return.
defValue
floatThe default value.
The value at the specified index.
Gets the Float array at the specified index.
public static float[] GetFloatArray(this IPdfArray array, int index, bool singleToArray = false)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
singleToArray
boolIndicates whether to convert a single Float value to an array.
The array at the specified key, or null.
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)
array
IPdfArrayThe current array.
index
intThe index of the item to return.
defValue
intThe default value.
The value at the specified index.
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)
array
IPdfArrayThe current array.
index
intThe index of the item to return.
defValue
int?The default value.
The value at the specified index.
Gets the Integer array at the specified index.
public static int[] GetIntArray(this IPdfArray array, int index, bool singleToArray = false)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
singleToArray
boolIndicates whether to convert a single Integer value to an array.
The array at the specified key, or null.
Gets an item at specified index.
public static IPdfObject GetItem(this IPdfArray array, int index)
array
IPdfArrayThe current array.
index
intThe item index.
The GrapeCity.Documents.Pdf.Spec.IPdfObject with specified index.
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)
array
IPdfArrayThe current array.
index
intThe index of the item to return.
defValue
stringThe default value.
The value at the specified index.
Gets the PDF Name array at the specified index.
public static PdfName[] GetNameArray(this IPdfArray array, int index, bool singleToArray = false)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
The array at the specified key, or null.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
The array at the specified key, or null.
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)
array
IPdfArrayThe current array.
index
intThe index of the string to return.
The value at the specified index.
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)
array
IPdfArrayThe current array.
index
intThe index of the string to return.
defValue
stringThe default value.
The value at the specified index.
Insert an item into IPdfArray.
public static void Insert(this IPdfArray array, int index, IPdfObject item)
array
IPdfArrayThe current PDF array.
index
intThe index of item.
item
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe item to insert.
Removes an item with specified index.
public static void RemoveAt(this IPdfArray array, int index)
array
IPdfArrayThe current PDF array.
index
intThe index of an item to remove.
Removes a range of items.
public static void RemoveRange(this IPdfArray array, int startIndex, int count = -1)
array
IPdfArrayThe current PDF array.
startIndex
intThe index of start item.
count
intThe count of items to remove.
Sets the value at the specified index.
public static void Set(this IPdfArray array, int index, IPdfObject item)
array
IPdfArrayThe current IPdfArray.
index
intThe value index.
item
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe value to set.
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)
array
IPdfArrayThe current PDF array.
count
intThe required item count.
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)
array
IPdfArrayThe current array.
index
intThe index of the item to set.
value
byte[]The value to set.
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)
array
IPdfArrayThe current IPdfArray.
index
intThe index of the value to set.
item
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe value to set.
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
array
IPdfArrayThe current array.
values
T[]OUT: The array of T
.
allowNulls
boolIndicates whether the IPdfNull should be handled as valid value and converted to null.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.
Returns true if no errors occur.
T
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)
array
IPdfArrayThe current array.
left
IPdfNumberOUT: The X of left-bottom corner.
bottom
IPdfNumberOUT: The Y of left-bottom corner.
right
IPdfNumberOUT: The X of right-top corner.
top
IPdfNumberOUT: The Y of right-top corner.
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
TOUT: The value at specified index.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog
if value at the specified index can't be converted to the T
.
true if successful; false otherwise.
T
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
TOUT: The value.
isNull
boolOUT: Indicates whether the value is PDF null.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.
Returns true if no errors occur.
T
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
T[]OUT: The array of T
.
singleToArray
boolIndicates whether to convert a single T
value to an array.
allowNulls
boolIndicates whether to handle IPdfNull as null.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.
Returns true if no errors occur.
T
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
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
T[]OUT: The value.
singleToArray
boolIndicates whether to convert a single T
value to an array.
true if value exists, false otherwise.
T
Tries to get the bool value with the specified index.
public static bool TryGetBool(this IPdfArray array, int index, out bool value)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
boolOUT: The integer value.
true if value exists and can be converted to an bool; otherwise false.
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
array
IPdfArrayThe current array.
index
intThe value index.
value
TOUT. When this method returns, contains the enum value.
true if value exists; otherwise, false.
T
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
float?OUT: The float value.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.
true if value exists and can be converted to a float; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
floatOUT: The float value.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.
true if value exists and can be converted to a float; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
float[]OUT: The float array.
singleToArray
boolIndicates whether to convert a single Float value to an array.
true if value at specified index can be converted to a float array; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
intOUT: The integer value.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if value at the specified index can't be converted to int.
true if value exists and can be converted to an int; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
int[]OUT: The integer array.
singleToArray
boolIndicates whether to convert a single Integer value to an array.
true if value at specified index can be converted to an integer array; otherwise false.
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)
array
IPdfArrayThe current IPdfArray.
index
intThe index of the value to get.
value
stringOUT: The string value.
true if value exists and can be converted to a PDF name; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
PdfName[]OUT: The PDF Name array.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
true if value at specified index can be converted to an integer array; otherwise false.
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)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
string[]OUT: The string array.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
true if value at specified index can be converted to an integer array; otherwise false.
Tries to get the string value with the specified index.
public static bool TryGetString(this IPdfArray array, int index, out string value)
array
IPdfArrayThe current array.
index
intThe index of the value to get.
value
stringOUT: The string value.
true if value exists and can be converted to a string; otherwise false.