Skip to main content

Class PdfObjectExtensions

Namespace: AdCodicem.Pdf.Objects
Assembly: AdCodicem.Pdf.dll

Typed access to the object graph.

public static class PdfObjectExtensions

Inheritance​

object ← PdfObjectExtensions

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​

PdfArray?

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​

PdfDictionary?

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​

PdfName?

AsNumber(PdfObject?)​

Returns the value as a number, resolving references.

public static double? AsNumber(this PdfObject? value)

Parameters​

value PdfObject?

Returns​

double?

AsStream(PdfObject?)​

Returns the value as a stream, resolving references.

public static PdfStream? AsStream(this PdfObject? value)

Parameters​

value PdfObject?

Returns​

PdfStream?

AsString(PdfObject?)​

Returns the value as a string object, resolving references.

public static PdfString? AsString(this PdfObject? value)

Parameters​

value PdfObject?

Returns​

PdfString?

AsText(PdfObject?)​

Returns the value as text, resolving references.

public static string? AsText(this PdfObject? value)

Parameters​

value PdfObject?

Returns​

string?

Get(PdfDictionary?, PdfName)​

Gets a dictionary entry, resolving references.

public static PdfObject? Get(this PdfDictionary? dictionary, PdfName key)

Parameters​

dictionary PdfDictionary?

key PdfName

Returns​

PdfObject?

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​

PdfArray?

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​

bool

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​

PdfDictionary?

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​

long

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​

PdfName?

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​

double?

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​

double

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​

PdfObject?

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​

PdfStream?

GetText(PdfDictionary?, PdfName)​

Gets a dictionary entry as text.

public static string? GetText(this PdfDictionary? dictionary, PdfName key)

Parameters​

dictionary PdfDictionary?

key PdfName

Returns​

string?

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​

bool

Resolved(PdfObject?)​

Resolves an object, tolerating null.

public static PdfObject? Resolved(this PdfObject? value)

Parameters​

value PdfObject?

Returns​

PdfObject?