[]
Contains extension methods for the IPdfDict interface, allows working with PdfDict and PdfDictObject in the same way.
public static class IPdfDictExt
Clears the dictionary.
public static bool Clear(this IPdfDict dict)
dict
IPdfDictThe current dictionary.
Determines whether this IPdfDict contains the specified key.
public static bool ContainsKey(this IPdfDict dict, PdfName key)
true if this IPdfDict contains an element with the specified key, false otherwise.
Copies from the current dictionary to dest
all properties
except those specified in propsToExclude
.
dest
can be null
, in that case it will be initialized
if there are any properties to copy.
public static void CopyToExcluding(this IPdfDict dict, ref PdfDict dest, HashSet<PdfName> propsToExclude)
dict
IPdfDictThe current dictionary.
dest
PdfDictThe PdfDict object (can be null
).
propsToExclude
System.Collections.Generic.HashSet<T><PdfName>The names of properties to exclude.
Gets the count of items in the IPdfDict.
public static int Count(this IPdfDict dict)
dict
IPdfDictThe current dictionary.
Converts the IPdfDict to a string.
public static string DictToString(IPdfDict dict)
Gets the value associated with the specified key,
if the value does not exist or cannot be converted to a T
returns the defValue
.
Note! This method returns IPdfRef if T
is IPdfRef,
otherwise the method resolves the reference and returns actual object.
public static T Get<T>(this IPdfDict dict, PdfName key, T defValue) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
TThe default value.
The value associated with the specified key, or null
T
Gets the value associated with the specified key,
if the value does not exist or cannot be converted to a T
returns null.
Note! This method returns IPdfRef if T
is IPdfRef,
otherwise the method resolves the reference and returns actual object.
public static T Get<T>(this IPdfDict dict, PdfName key, bool addWarning = true) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
addWarning
boolIndicates whether to add a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if errors occur.
The value associated with the specified key, or null
T
Gets the array of T
objects associated with the specified key.
Returns null if the array does not exist or cannot be converted to an array of T
.
public static T[] GetArray<T>(this IPdfDict dict, PdfName key, bool singleToArray = false) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the array.
singleToArray
boolIndicates whether to convert a single T
value to an array.
The array associated with the specified key, or null.
T
Gets the value at the specified path. The path can contain IPdfName objects which are interpreted as dictionary keys, or integers which are interpreted as IPdfArray indices.
public static T GetAtPath<T>(this IPdfDict dict, params object[] path) where T : IPdfObject
dict
IPdfDictThe current dictionary.
path
object[]The path to the value.
The value associated with the specified path, or null if the value could not be found.
T
Gets the Boolean value associated with the specified key.
If the value does not exist or cannot be converted to a Boolean,
returns defValue
(which can be null).
public static bool GetBool(this IPdfDict dict, PdfName key, bool defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
boolThe default value.
The value associated with the specified key, or null.
Gets the nullable Boolean value associated with the specified key.
If the value does not exist or cannot be converted to a Boolean,
returns defValue
(which can be null).
public static bool? GetBool(this IPdfDict dict, PdfName key, bool? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
bool?The default value.
The value associated with the specified key, or null.
Gets the Boolean array associated with the specified key. Returns null if the array does not exist or cannot be converted to a Boolean array.
public static bool[] GetBoolArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single Boolean value to an array.
The array associated with the specified key, or null.
Gets the System.Drawing.Color associated with the specified key (in a PDF a System.Drawing.Color should be represented as an array of 1, 3 or 4 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Drawing.Color.
public static Color GetColor(this IPdfDict dict, PdfName key, Color defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Drawing.ColorThe default value.
The value associated with the specified key.
Gets the System.Drawing.Color associated with the specified key (in a PDF a System.Drawing.Color should be represented as an array of 1, 3 or 4 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Drawing.Color.
public static Color? GetColor(this IPdfDict dict, PdfName key, Color? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Drawing.Color?The default value.
The value associated with the specified key.
Gets the RGB System.Drawing.Color associated with the specified key (in a PDF an RGB System.Drawing.Color should be represented as an array of 3 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Drawing.Color.
public static Color GetDeviceRGBColor(this IPdfDict dict, PdfName key, Color defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Drawing.ColorThe default value.
The value associated with the specified key.
Gets the IPdfDict array associated with the specified key. Returns null if the array does not exist or cannot be converted to an IPdfDict array.
public static IPdfDict[] GetDictArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single IPdfDict to an array.
The array associated with the specified key, or null.
Gets the nullable Double value associated with the specified key.
If the value does not exist or cannot be converted to a Double,
returns defValue
(which can be null).
public static double? GetDouble(this IPdfDict dict, PdfName key, double? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
double?The default value.
The value associated with the specified key, or defValue
.
Gets the enum value associated with the specified key.
If the value does not exist or cannot be converted to an enum,
returns defValue
.
public static T GetEnum<T>(this IPdfDict dict, PdfName key, T defValue) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
TThe default value.
The value associated with the specified key, or defValue
.
T
Gets the nullable enum value associated with the specified key.
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 IPdfDict dict, PdfName key, T? defValue) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
T?The default value.
The value associated with the specified key, or defValue
.
T
Gets the nullable Float value associated with the specified key.
If the value does not exist or cannot be converted to a Float,
returns defValue
(which can be null).
public static float? GetFloat(this IPdfDict dict, PdfName key, float? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
float?The default value.
The value associated with the specified key, or defValue
.
Gets the Float value associated with the specified key.
If the value does not exist or cannot be converted to a Float,
returns defValue
.
public static float GetFloat(this IPdfDict dict, PdfName key, float defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
floatThe default value.
The value associated with the specified key, or defValue
.
Gets the float array associated with the specified key. Returns null if the array does not exist or cannot be converted to a float array.
public static float[] GetFloatArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single float value to an array.
The array associated with the specified key, or null.
Gets the nullable Integer value associated with the specified key.
If the value does not exist or cannot be converted to an Integer,
returns defValue
.
public static int GetInt(this IPdfDict dict, PdfName key, int defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
intThe default value.
The value associated with the specified key, or defValue
.
Gets the Integer value associated with the specified key.
If the value does not exist or cannot be converted to an Integer,
returns defValue
(which can be null).
public static int? GetInt(this IPdfDict dict, PdfName key, int? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
int?The default value.
The value associated with the specified key, or defValue
.
Gets the Integer array associated with the specified key. Returns null if the array does not exist or cannot be converted to an Integer array.
public static int[] GetIntArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single Integer value to an array.
The array associated with the specified key, or null.
Gets the System.Numerics.Matrix3x2 associated with the specified key (in a PDF a System.Numerics.Matrix3x2 should be represented as an array of 6 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Numerics.Matrix3x2.
public static Matrix3x2? GetMatrix(this IPdfDict dict, PdfName key, Matrix3x2? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Numerics.Matrix3x2?The default value.
The value associated with the specified key.
Gets the System.Numerics.Matrix3x2 associated with the specified key (in a PDF a System.Numerics.Matrix3x2 should be represented as an array of 6 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Numerics.Matrix3x2.
public static Matrix3x2 GetMatrix(this IPdfDict dict, PdfName key, Matrix3x2 defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Numerics.Matrix3x2The default value.
The value associated with the specified key.
Gets the PDF Name value associated with the specified key.
If the value does not exist or cannot be converted to a PDF Name,
returns defValue
(which can be null).
public static string GetName(this IPdfDict dict, PdfName key, string defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
stringThe default value.
The value associated with the specified key, or null.
Gets the PdfName array associated with the specified key. Returns null if the array does not exist or cannot be converted to a PdfName array.
public static PdfName[] GetNameArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single PdfName to an array.
The array associated with the specified key, or null.
Gets the PDF Name array associated with the specified key. Returns null if the array does not exist or cannot be converted to a PDF Name array.
public static string[] GetNameArrayStr(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
The array associated with the specified key, or null.
Gets the Offsets associated with the specified key (in a PDF a Offsets should be represented as an array of 4 floats).
Gets defValue
if the value does not exist or cannot be converted to an Offsets.
public static Offsets GetOffsets(this IPdfDict dict, PdfName key, Offsets defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
OffsetsThe default value.
The value associated with the specified key.
Gets the Offsets associated with the specified key (in a PDF an Offsets should be represented as an array of 4 floats).
Gets defValue
if the value does not exist or cannot be converted to an Offsets.
public static Offsets? GetOffsets(this IPdfDict dict, PdfName key, Offsets? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
Offsets?The default value.
The value associated with the specified key.
Gets the PdfDateTime value associated with the specified key.
If the value does not exist or cannot be converted to a PdfDateTime,
returns defValue
(which can be null).
public static PdfDateTime? GetPdfDateTime(this IPdfDict dict, PdfName key, PdfDateTime? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
PdfDateTime?The default value.
The value associated with the specified key, or null.
Gets the PdfEnum<TEnum> value associated with the specified key.
If the value does not exist returns defValue
.
public static PdfEnum<T> GetPdfEnum<T>(this IPdfDict dict, PdfName key, T defValue) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
TThe default value.
The value associated with the specified key, or defValue
.
T
Gets the nullable PdfEnum<TEnum> value associated with the specified key.
If the value does not exist returns defValue
(which can be null).
public static PdfEnum<T>? GetPdfEnum<T>(this IPdfDict dict, PdfName key, T? defValue) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
T?The default value.
The value associated with the specified key, or defValue
.
T
Gets the bytes of the IPdfString associated with the specified key. If the value does not exist or cannot be converted to an IPdfString, returns null.
public static byte[] GetPdfStringBytes(this IPdfDict dict, PdfName key)
The value associated with the specified key, or null.
Gets the System.Drawing.RectangleF associated with the specified key (in a PDF a System.Drawing.RectangleF should be represented as an array of 4 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Drawing.RectangleF.
public static RectangleF GetRect(this IPdfDict dict, PdfName key, RectangleF defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Drawing.RectangleFThe default value.
The value associated with the specified key.
Gets the System.Drawing.RectangleF associated with the specified key (in a PDF a System.Drawing.RectangleF should be represented as an array of 4 floats).
Gets defValue
if the value does not exist or cannot be converted to a System.Drawing.RectangleF.
public static RectangleF? GetRect(this IPdfDict dict, PdfName key, RectangleF? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
System.Drawing.RectangleF?The default value.
The value associated with the specified key.
Gets the array of IPdfRef objects associated with the specified key, Returns null if the array does not exist or cannot be converted to an array of IPdfRef.
public static IPdfRef[] GetRefArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the array.
singleToArray
boolIndicates whether to convert a single IPdfRef value to an array.
The array associated with the specified key, or null.
Returns the decoded stream data if IPdfDict is a PdfStreamObjectBase.
public static byte[] GetStreamData(IPdfDict dict)
dict
IPdfDictGets the String value associated with the specified key.
If the value does not exist or cannot be converted to a String,
returns defValue
(which can be null).
public static string GetString(this IPdfDict dict, PdfName key, string defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
defValue
stringThe default value.
The value associated with the specified key, or null.
Gets the String array associated with the specified key. Returns null if the array does not exist or cannot be converted to a String array.
public static string[] GetStringArray(this IPdfDict dict, PdfName key, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
singleToArray
boolIndicates whether to convert a single String value to an array.
The array associated with the specified key, or null.
Gets the string associated with the specified key. The string can be specified in the PDF as a PDF string or a PDF name.
Gets defValue
if the value does not exist or cannot be converted to a string.
public static string GetStringOrName(this IPdfDict dict, PdfName key, string defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
defValue
stringThe default value.
The value associated with the specified key.
Removes the value associated with the specified key.
public static bool Remove(this IPdfDict dict, PdfName key)
true if the element was successfully removed, false otherwise.
Removes all entries related to the stream: Length, Filter, DecodeParms. The method does not change the Changed flag.
public static void RemoveStreamEntries(this IPdfDict dict)
dict
IPdfDictSets the PDF Name value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void Set(this IPdfDict dict, PdfName key, IPdfName value, IPdfName defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
IPdfNameThe value to set.
defValue
IPdfNameThe default value.
Sets the value associated with the specified key.
If value
is null, the entry specified by the key will be removed.
public static void Set(this IPdfDict dict, PdfName key, IPdfObject value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to set.
value
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe value to set.
Sets the Boolean value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetBool(this IPdfDict dict, PdfName key, bool? value, bool? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
bool?The value to set.
defValue
bool?The default value.
Sets the Color value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetColor(this IPdfDict dict, PdfName key, Color? value, Color? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
System.Drawing.Color?The value to set.
defValue
System.Drawing.Color?The default value.
Sets the RGB System.Drawing.Color value associated with the specified key (in a PDF an RGB System.Drawing.Color should be represented as an array of 3 floats).
public static void SetDeviceRGBColor(this IPdfDict dict, PdfName key, Color? value, Color? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to set.
value
System.Drawing.Color?The value to set.
defValue
System.Drawing.Color?The default value.
Sets the Double value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetDouble(this IPdfDict dict, PdfName key, double? value, double? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
double?The value to set.
defValue
double?The default value.
Sets the float value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetFloat(this IPdfDict dict, PdfName key, float? value, float? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
float?The value to set.
defValue
float?The default value.
Sets the float array associated with the specified key. If the value is null, removes the key from the dictionary.
public static void SetFloatArray(this IPdfDict dict, PdfName key, float[] value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
float[]The value to set.
Sets the Integer value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetInt(this IPdfDict dict, PdfName key, int? value, int? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
int?The value to set.
defValue
int?The default value.
Sets the int array associated with the specified key. If the value is null, removes the key from the dictionary.
public static void SetIntArray(this IPdfDict dict, PdfName key, int[] value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
int[]The value to set.
Sets the System.Numerics.Matrix3x2 value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetMatrix(this IPdfDict dict, PdfName key, Matrix3x2? value, Matrix3x2? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
System.Numerics.Matrix3x2?The value to set.
defValue
System.Numerics.Matrix3x2?The default value.
Sets the PDF Name value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
Note! The method converts a string to the PdfName.
public static void SetName(this IPdfDict dict, PdfName key, string value, string defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringThe value to set.
defValue
stringThe default value.
Sets or removes the PDF name array associated with a specified key
.
If the specified value
is null,
the value is removed from the current dictionary.
Otherwise the value is set.
public static void SetNameArray(this IPdfDict dict, PdfName key, string[] value, bool singleToArray = true)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
string[]The value to set.
singleToArray
boolIf true and value
contains exactly one element,
the array will be stored as a simple PDF name object.
Sets the PDF Name value associated with the specified key. If the value is null or empty, removes the key from the dictionary. Note! The method converts a string to the PdfName.
public static void SetNameNotEmpty(this IPdfDict dict, PdfName key, string value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringThe value to set.
Sets the Offsets value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetOffsets(this IPdfDict dict, PdfName key, Offsets? value, Offsets? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
Offsets?The value to set.
defValue
Offsets?The default value.
Sets the PdfDateTime value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetPdfDateTime(this IPdfDict dict, PdfName key, PdfDateTime? value, PdfDateTime? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
PdfDateTime?The value to set.
defValue
PdfDateTime?The default value.
Sets the nullable PdfEnum<TEnum> value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
Note! The method converts a PdfEnum<TEnum> to the PdfName.
public static void SetPdfEnum<T>(this IPdfDict dict, PdfName key, PdfEnum<T>? value, T? defValue) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
PdfEnum<T>?The value to set.
defValue
T?The default value.
T
Sets the IPdfString associated with the specified key to the specified value. If the value is null, removes the key from the dictionary. Returns the created PdfString.
public static PdfString SetPdfStringBytes(this IPdfDict dict, PdfName key, byte[] value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the string.
value
byte[]The value to set.
Sets the System.Drawing.RectangleF value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
public static void SetRect(this IPdfDict dict, PdfName key, RectangleF? value, RectangleF? defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
System.Drawing.RectangleF?The value to set.
defValue
System.Drawing.RectangleF?The default value.
Sets the String value representing the Rich Text associated with the specified key.
If the value is null or empty removes the key from the dictionary.
Note! The method converts a string to the PdfString.
Note! The method encloses the value
with PdfConsts.c_RichStringPrefix and
PdfConsts.c_RichStringSuffix
public static void SetRichTextNotEmpty(this IPdfDict dict, PdfName key, string value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringThe value to set.
Sets the value associated with the specified key without affecting the Changed value.
If value
is null, the entry specified by the key will be removed.
public static void SetSilent(this IPdfDict dict, PdfName key, IPdfObject value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to set.
value
GrapeCity.Documents.Pdf.Spec.IPdfObjectThe value to set.
Sets the String value associated with the specified key.
If the value is null or is equal to defValue
,
removes the key from the dictionary.
Note! The method converts a string to the PdfString.
public static void SetString(this IPdfDict dict, PdfName key, string value, string defValue)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringThe value to set.
defValue
stringThe default value.
Sets or removes the PDF string array associated with a specified key
.
If the specified value
is null,
the value is removed from the current dictionary.
Otherwise the value is set.
public static void SetStringArray(this IPdfDict dict, PdfName key, IEnumerable<string> value, bool singleToArray = true)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
System.Collections.Generic.IEnumerable<T><string>The value to set.
singleToArray
boolIf true and value
contains exactly one element,
the array will be stored as a simple PDF string object.
Sets the String value associated with the specified key. If the value is null or empty removes the key from the dictionary. Note! The method converts a string to the PdfString.
public static void SetStringNotEmpty(this IPdfDict dict, PdfName key, string value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringThe value to set.
Tries to get the value associated with the specified key,
if the value does not exist or cannot be converted to a T
returns false.
public static bool TryGet<T>(this IPdfDict dict, PdfName key, out T value, bool addWarning = true) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
TOUT: The 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 the T
.
true if value exists, false otherwise.
T
Tries to get the value associated with the specified key,
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 IPdfDict dict, PdfName key, out T value, out bool isNull, bool addWarning) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
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 gets the array of T
objects associated with the specified key.
public static bool TryGetArray<T>(IPdfDict dict, PdfName key, out T[] value, bool singleToArray, bool allowNulls, bool addWarning) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the array.
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 associated with the specified key,
if the value does not exist or cannot be converted to an array of T
returns false.
public static bool TryGetArray<T>(this IPdfDict dict, PdfName key, out T[] value, bool singleToArray = false) where T : IPdfObject
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
T[]OUT: The value.
singleToArray
boolIndicates whether to convert a single T
value to an array.
true if value exists, false otherwise.
T
Gets the value at the specified path. The path can contain IPdfName objects which are interpreted as dictionary keys, or integers which are interpreted as IPdfArray indices.
public static bool TryGetAtPath<T>(IPdfDict dict, out T value, out bool isNull, bool addWarning, params object[] path) where T : IPdfObject
dict
IPdfDictThe current dictionary.
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.
path
object[]The path to the value.
The value associated with the specified path, or null if the value could not be found.
T
Tries to get the Boolean value associated with the specified key. If the value does not exist or cannot be converted to a Boolean, returns false.
public static bool TryGetBool(this IPdfDict dict, PdfName key, out bool value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
boolOUT. When this method returns, contains the Boolean value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
true if value exists; otherwise, false.
Tries to get the bool array associated with the specified key.
public static bool TryGetBoolArray(this IPdfDict dict, PdfName key, out bool[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
bool[]OUT: The array of bool.
singleToArray
boolIndicates whether to convert a single bool value to an array.
true if successful; false otherwise.
Tries to get the System.Drawing.Color associated with the specified key (in a PDF a System.Drawing.Color should be represented as an array of 1, 3 or 4 floats).
Adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to System.Drawing.Color.
public static bool TryGetColor(this IPdfDict dict, PdfName key, out Color value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
System.Drawing.ColorOUT: the value associated with the specified key.
True if the key was found and the value could be converted to a System.Drawing.Color, false otherwise.
Tries to get the RGB System.Drawing.Color associated with the specified key (in a PDF an RGB System.Drawing.Color should be represented as an array of 3 floats).
Adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to System.Drawing.Color.
public static bool TryGetDeviceRGBColor(this IPdfDict dict, PdfName key, out Color value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
System.Drawing.ColorOUT: the value associated with the specified key.
True if the key was found and the value could be converted to a System.Drawing.Color, false otherwise.
Tries to gets the array of IPdfDict objects associated with the specified key.
public static bool TryGetDictArray(this IPdfDict dict, PdfName key, out IPdfDict[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the array.
value
IPdfDict[]OUT: The array of IPdfDict.
singleToArray
boolIndicates whether to convert a single IPdfDict value to an array.
true if successful, false otherwise.
Tries to get the Double value associated with the specified key. If the value does not exist or cannot be converted to a Double, returns false.
public static bool TryGetDouble(this IPdfDict dict, PdfName key, out double value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
doubleOUT. When this method returns, contains the Double value.
true if value exists; otherwise, false.
Tries to get the enum value associated with the specified key. If the value does not exist or cannot be converted to an enum, returns false.
public static bool TryGetEnum<T>(this IPdfDict dict, PdfName key, out T value) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
TOUT. When this method returns, contains the enum value.
true if value exists; otherwise, false.
T
Tries to get the Float value associated with the specified key. If the value does not exist or cannot be converted to a Float, returns false.
public static bool TryGetFloat(this IPdfDict dict, PdfName key, out float value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
floatOUT. When this method returns, contains the Float value.
true if value exists; otherwise, false.
Tries to get the float array associated with the specified key.
public static bool TryGetFloatArray(this IPdfDict dict, PdfName key, out float[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
float[]OUT: The array of float.
singleToArray
boolIndicates whether to convert a single float value to an array.
true if successful; false otherwise.
Tries to get the Integer value associated with the specified key. If the value does not exist or cannot be converted to an Integer, returns false.
public static bool TryGetInt(this IPdfDict dict, PdfName key, out int value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
intOUT. When this method returns, contains the Integer value.
true if value exists; otherwise, false.
Tries to get the Integer array associated with the specified key.
public static bool TryGetIntArray(this IPdfDict dict, PdfName key, out int[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
int[]OUT: The array of int.
singleToArray
boolIndicates whether to convert a single Integer value to an array.
true if successful; false otherwise.
Tries to get the System.Numerics.Matrix3x2 associated with the specified key (in a PDF a System.Numerics.Matrix3x2 should be represented as an array of 6 floats).
Adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to System.Numerics.Matrix3x2.
public static bool TryGetMatrix(this IPdfDict dict, PdfName key, out Matrix3x2 value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
System.Numerics.Matrix3x2OUT: the value associated with the specified key.
True if the key was found and the value could be converted to a System.Numerics.Matrix3x2, false otherwise.
Tries to get the PDF Name value associated with the specified key. If the value does not exist or cannot be converted to a PDF Name, returns false.
public static bool TryGetName(this IPdfDict dict, PdfName key, out string value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringOUT. When this method returns, contains the PDF Name value.
true if value exists; otherwise, false.
Tries to get the PDF Name array associated with the specified key.
public static bool TryGetNameArray(this IPdfDict dict, PdfName key, out PdfName[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
PdfName[]OUT: The array of PdfName.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
The array associated with the specified key, or null.
Tries to get the PDF Name array associated with the specified key, the PDF names converted to strings.
public static bool TryGetNameArrayStr(this IPdfDict dict, PdfName key, out string[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
string[]OUT: The array of strings.
singleToArray
boolIndicates whether to convert a single PDF Name value to an array.
The array associated with the specified key, or null.
Tries to get the Offsets associated with the specified key (in a PDF an Offsets should be represented as an array of 4 floats).
Adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to Offsets.
public static bool TryGetOffsets(this IPdfDict dict, PdfName key, out Offsets value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
OffsetsOUT: the value associated with the specified key.
True if the key was found and the value could be converted to an Offsets, false otherwise.
Tries to get the PdfDateTime value associated with the specified key. If the value does not exist or cannot be converted to the PdfDateTime, returns false.
public static bool TryGetPdfDateTime(this IPdfDict dict, PdfName key, out PdfDateTime? value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
PdfDateTime?OUT. When this method returns, contains the PdfDateTime value.
true if value exists; otherwise, false.
Tries to get the PdfEnum<TEnum> value associated with the specified key. If the value does not exist or cannot be converted to an enum, returns false.
public static bool TryGetPdfEnum<T>(this IPdfDict dict, PdfName key, out PdfEnum<T> value) where T : struct
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
PdfEnum<T>OUT. When this method returns, contains the enum value.
true if value exists; otherwise, false.
T
Tries to get the System.Drawing.RectangleF associated with the specified key (in a PDF a System.Drawing.RectangleF should be represented as an array of 4 floats).
Adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to System.Drawing.RectangleF.
public static bool TryGetRect(this IPdfDict dict, PdfName key, out RectangleF value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
System.Drawing.RectangleFOUT: the value associated with the specified key.
True if the key was found and the value could be converted to a System.Drawing.RectangleF, false otherwise.
Tries to gets the array of IPdfRef objects associated with the specified key.
public static bool TryGetRefArray(this IPdfDict dict, PdfName key, out IPdfRef[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the array.
value
IPdfRef[]OUT: The array of IPdfRef.
singleToArray
boolIndicates whether to convert a single IPdfRef value to an array.
true if successful, false otherwise.
Tries to get the String value associated with the specified key. If the value does not exist or cannot be converted to a String, returns false.
public static bool TryGetString(this IPdfDict dict, PdfName key, out string value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
stringOUT. When this method returns, contains the String value.
true if value exists; otherwise, false.
Tries to get the string array associated with the specified key.
public static bool TryGetStringArray(this IPdfDict dict, PdfName key, out string[] value, bool singleToArray = false)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key identifying the value.
value
string[]OUT: The array of string.
singleToArray
boolIndicates whether to convert a single string value to an array.
true if successful; false otherwise.
Tries to get the string associated with the specified key. The string can be specified in the PDF as a PDF string or a PDF name.
Optionally adds a warning to GrapeCity.Documents.Pdf.GcPdfDocument.ParserLog if the value exists but cannot be converted to a PdfString.
public static bool TryGetStringOrName(this IPdfDict dict, PdfName key, out string value, bool addWarning = true)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value to get.
value
stringOUT: the value associated with the specified key.
addWarning
boolSpecifies whether to add a warning if the value could not be converted.
True if the key was found and the value could be converted to a Boolean, false otherwise.
Tries to get a value with specified key. The method does not perform any processing of the value and returns it as is.
public static bool TryGetValue(this IPdfDict dict, PdfName key, out IPdfObject value)
dict
IPdfDictThe current dictionary.
key
PdfNameThe key of the value.
value
GrapeCity.Documents.Pdf.Spec.IPdfObjectOUT: The value.
true if value exists, false otherwise.