PdfName Class

A name (ISO 32000-2, 7.3.5): an atomic symbol such as /Type. It is immutable and compared by its bytes.

public sealed class PdfName : PdfObject, IEquatable<PdfName>

Remarks

A name is a sequence of bytes. PdfName.Value is that sequence decoded as UTF-8, the recommended encoding (7.3.5), or as ISO-8859-1 when it is not valid UTF-8; creating a name from a string encodes it as UTF-8.

Inheritance
PdfObject PdfName
Implements

Constructors

NameDescription
PdfName(string)Initializes a new instance of the PdfName class.

PdfName(string)

PdfName.cs

Initializes a new instance of the PdfName class.

public PdfName(string value)

Parameters

value string
The name, without the leading slash. It is encoded as UTF-8.

Exceptions

ArgumentException
value contains the null character, which a name cannot contain (7.3.5).

Properties

NameDescription
KindGets the kind of the object.
ValueGets the name, without the leading slash.

Gets the kind of the object.

public override PdfObjectKind Kind { get; }

Property value

PdfObjectKind

Gets the name, without the leading slash.

public string Value { get; }

Property value

string

Methods

NameDescription
Create(string)Creates a name, or gets the shared instance of a name the library knows.
Equals(PdfName?)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Determines whether the specified object is equal to the current object.
GetHashCode()Serves as the default hash function.

Create(string)

PdfName.cs

Creates a name, or gets the shared instance of a name the library knows.

public static PdfName Create(string value)

Parameters

value string
The name, without the leading slash.

Returns

PdfName The name.

Exceptions

ArgumentException
value contains the null character, which a name cannot contain (7.3.5).

Equals overloads

Equals(PdfName?)

PdfName.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PdfName? other)
Parameters
other PdfName?
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

PdfName.cs

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current object.
Returns

bool true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

PdfName.cs

Serves as the default hash function.

public override int GetHashCode()

Returns

int A hash code for the current object.

Operators

NameDescription
operator ==(PdfName?, PdfName?)Indicates whether two names are equal.
implicit operator PdfName(string)Converts a string to a name.
operator !=(PdfName?, PdfName?)Indicates whether two names are different.

operator ==(PdfName?, PdfName?)

PdfName.cs

Indicates whether two names are equal.

public static bool operator ==(PdfName? left, PdfName? right)

Parameters

left PdfName?
The first name.
right PdfName?
The second name.

Returns

bool true when the names have the same bytes.

implicit operator PdfName(string)

PdfName.cs

Converts a string to a name.

public static implicit operator PdfName(string value)

Parameters

value string
The name, without the leading slash.

Returns

PdfName

operator !=(PdfName?, PdfName?)

PdfName.cs

Indicates whether two names are different.

public static bool operator !=(PdfName? left, PdfName? right)

Parameters

left PdfName?
The first name.
right PdfName?
The second name.

Returns

bool true when the names have different bytes.