Class PdfObjectExtensions
Namespace: AdCodicem.Pdf.Objects
Assembly: AdCodicem.Pdf.dll
Typed access to the object graph.
public static class PdfObjectExtensions
Inheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
Every accessor here but PdfObjectExtensions.GetRaw(PdfDictionary?, PdfName) resolves indirect references on the way. Reading a dictionary entry without resolving it is the single most common defect in code that manipulates PDF, because it works on the files you tested with and fails on the ones you did not.
Methods
AsArray(PdfObject?)
Returns the value as an array, resolving references.
public static PdfArray? AsArray(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsBoolean(PdfObject?)
Returns the value as a boolean, resolving references.
public static bool? AsBoolean(this PdfObject? value)
Parameters
value PdfObject?
Returns
bool?
AsDictionary(PdfObject?)
Returns the value as a dictionary, resolving references. A stream yields its own dictionary, because a stream is a dictionary that happens to carry data.
public static PdfDictionary? AsDictionary(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsInteger(PdfObject?)
Returns the value as an integer, resolving references. Reals with no fractional part, within the range of a Int64, qualify.
public static long? AsInteger(this PdfObject? value)
Parameters
value PdfObject?
Returns
long?
AsName(PdfObject?)
Returns the value as a name, resolving references.
public static PdfName? AsName(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsNumber(PdfObject?)
Returns the value as a number, resolving references.
public static double? AsNumber(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsStream(PdfObject?)
Returns the value as a stream, resolving references.
public static PdfStream? AsStream(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsString(PdfObject?)
Returns the value as a string object, resolving references.
public static PdfString? AsString(this PdfObject? value)
Parameters
value PdfObject?
Returns
AsText(PdfObject?)
Returns the value as text, resolving references.
public static string? AsText(this PdfObject? value)
Parameters
value PdfObject?
Returns
Get(PdfDictionary?, PdfName)
Gets a dictionary entry, resolving references.
public static PdfObject? Get(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetArray(PdfDictionary?, PdfName)
Gets a dictionary entry as an array.
public static PdfArray? GetArray(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetBoolean(PdfDictionary?, PdfName, bool)
Gets a dictionary entry as a boolean, or defaultValue when absent or ill-typed.
public static bool GetBoolean(this PdfDictionary? dictionary, PdfName key, bool defaultValue)
Parameters
dictionary PdfDictionary?
key PdfName
defaultValue bool
Returns
GetDictionary(PdfDictionary?, PdfName)
Gets a dictionary entry as a dictionary.
public static PdfDictionary? GetDictionary(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetInteger(PdfDictionary?, PdfName)
Gets a dictionary entry as an integer.
public static long? GetInteger(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
long?
GetInteger(PdfDictionary?, PdfName, long)
Gets a dictionary entry as an integer, or defaultValue when absent or ill-typed.
public static long GetInteger(this PdfDictionary? dictionary, PdfName key, long defaultValue)
Parameters
dictionary PdfDictionary?
key PdfName
defaultValue long
Returns
GetName(PdfDictionary?, PdfName)
Gets a dictionary entry as a name.
public static PdfName? GetName(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetNumber(PdfDictionary?, PdfName)
Gets a dictionary entry as a number.
public static double? GetNumber(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetNumber(PdfDictionary?, PdfName, double)
Gets a dictionary entry as a number, or defaultValue when absent or ill-typed.
public static double GetNumber(this PdfDictionary? dictionary, PdfName key, double defaultValue)
Parameters
dictionary PdfDictionary?
key PdfName
defaultValue double
Returns
GetRaw(PdfDictionary?, PdfName)
Gets a dictionary entry without resolving references, which the writer needs to preserve sharing.
public static PdfObject? GetRaw(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetStream(PdfDictionary?, PdfName)
Gets a dictionary entry as a stream.
public static PdfStream? GetStream(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
GetText(PdfDictionary?, PdfName)
Gets a dictionary entry as text.
public static string? GetText(this PdfDictionary? dictionary, PdfName key)
Parameters
dictionary PdfDictionary?
key PdfName
Returns
IsOfType(PdfDictionary?, PdfName)
Determines whether the dictionary declares the given /Type.
public static bool IsOfType(this PdfDictionary? dictionary, PdfName type)
Parameters
dictionary PdfDictionary?
type PdfName
Returns
Resolved(PdfObject?)
Resolves an object, tolerating null.
public static PdfObject? Resolved(this PdfObject? value)
Parameters
value PdfObject?