# PDFString Class

> Represents an array of unsigned bytes within a PDF document.

- Product: Adobe PDF Library 18
- Language: .NET
- Version: APDFL18.0.5PlusP2e
- HTML page: https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFString
- Version index: https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/llms.txt

```csharp
class PDFString : PDFObject
```

**Namespace:** `Datalogics::PDFL`

**Inherits from:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

## Description

Represents an array of unsigned bytes within a PDF document.

A PDFString is a single data element that represents an array of unsigned bytes. It may be inserted into any collection object. PDFString may be a string of human readable text, but this is not required, and it may be stored either as characters or as hex values.

**Referenced by:** [`NameTree`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/NameTree.md), [`PDFString`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFString.md)

**Uses types:** [`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md), [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md), [`PDFObjectComparison`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFObjectComparison.md), [`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md), [`PDFString`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFString.md)

## Constructors

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(string value, Document doc, bool indirect, bool storedAsHex)
```

*constructor*

**Parameters**

- `value` (`string`): String stored in this PDFString
- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): Document object containing this PDFString
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values

String constructor

The provided string value is a Unicode string object. If it only contains characters within the PDFDocEncoding character set, it will be stored in that encoding; otherwise it will be stored in the document as UTF-16BE.

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(string value, Document doc, bool indirect, bool storedAsHex, bool storedAsUTF16)
```

*constructor*

**Parameters**

- `value` (`string`): String stored in this PDFString
- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): Document object containing this PDFString
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values
- `storedAsUTF16` (`bool`): flag indicating this PDFString should be stored as UTF-16BE, even if it could be encoded as PDFDocEncoding

String constructor

The provided string value is a Unicode string object. If storedAsUTF16 is true, it will be stored in the document at UTF-16BE. Otherwise it will be stored as PDFDocEncoding if it only contains characters within the PDFDocEncoding character set, else it will be stored as UTF-16BE.

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(string value, PDFObject docFromObj, bool indirect, bool storedAsHex)
```

*constructor*

**Parameters**

- `value` (`string`): String stored in this PDFString
- `docFromObj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): The new PDFString will be created in the same document as this object.
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values

String constructor

The provided string value is a Unicode string object. If it only contains characters within the PDFDocEncoding character set, it will be stored in that encoding; otherwise it will be stored in the document as UTF-16BE.

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(string value, PDFObject docFromObj, bool indirect, bool storedAsHex, bool storedAsUTF16)
```

*constructor*

**Parameters**

- `value` (`string`): String stored in this PDFString
- `docFromObj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): The new PDFString will be created in the same document as this object.
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values
- `storedAsUTF16` (`bool`): flag indicating this PDFString should be stored as UTF-16BE, even if it could be encoded as PDFDocEncoding

String constructor

The provided string value is a Unicode string object. If storedAsUTF16 is true, it will be stored in the document at UTF-16BE. Otherwise it will be stored as PDFDocEncoding if it only contains characters within the PDFDocEncoding character set, else it will be stored as UTF-16BE.

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(System.Byte[] value, Document doc, bool indirect, bool storedAsHex)
```

*constructor*

**Parameters**

- `value` (`System.Byte[]`): Array of bytes stored in this PDFString
- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): Document object containing this PDFString
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values

General constructor

### PDFString

```csharp
Datalogics.PDFL.PDFString.PDFString(System.Byte[] value, PDFObject docFromObj, bool indirect, bool storedAsHex)
```

*constructor*

**Parameters**

- `value` (`System.Byte[]`): Array of bytes stored in this PDFString
- `docFromObj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): The new PDFString will be created in the same document as this object.
- `indirect` (`bool`): flag marking this as an indirect PDFObject
- `storedAsHex` (`bool`): flag indicating this PDFString should be stored as hex values

General constructor

## Properties

### Bytes

```csharp
System.Byte [] Datalogics.PDFL.PDFString.Bytes { get; }
```

### Document

```csharp
Document Datalogics.PDFL.PDFObject.Document { get; }
```

### Generation

```csharp
int Datalogics.PDFL.PDFObject.Generation { get; }
```

### ID

```csharp
int Datalogics.PDFL.PDFObject.ID { get; }
```

### Indirect

```csharp
bool Datalogics.PDFL.PDFObject.Indirect { get; }
```

### PDFHashValue

```csharp
int Datalogics.PDFL.PDFObject.PDFHashValue { get; }
```

### StoredAsHex

```csharp
bool Datalogics.PDFL.PDFString.StoredAsHex { get; }
```

### Value

```csharp
string Datalogics.PDFL.PDFString.Value { get; }
```

## Methods

### Clone

```csharp
PDFObject Datalogics.PDFL.PDFObject.Clone()
```

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object.

Makes a new copy of this PDFObject in memory, in the same document and using same direct/indirect setting as this PDFObject.

### Clone

```csharp
PDFObject Datalogics.PDFL.PDFObject.Clone(Document doc)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): The target document in which to create the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the specified document.

Makes a new copy of this PDFObject in memory, in the supplied document, using the same direct/indirect setting as this PDFObject.

### Clone

```csharp
PDFObject Datalogics.PDFL.PDFObject.Clone(Document doc, bool indirect)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/Document.md)): The target document in which to create the copy.
- `indirect` (`bool`): If true, the copy will be an indirect object; if false, it will be direct.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the specified document.

Makes a new copy of this PDFObject in memory, in the supplied document, using supplied direct/indirect setting.

### Clone

```csharp
PDFObject Datalogics.PDFL.PDFObject.Clone(PDFObject obj)
```

**Parameters**

- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): The reference object whose document will be used for the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the same document as obj.

Makes a new copy of this PDFObject in memory, in the same document as another object, using the same direct/indirect setting as this PDFObject.

### Clone

```csharp
PDFObject Datalogics.PDFL.PDFObject.Clone(PDFObject obj, bool indirect)
```

**Parameters**

- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): The reference object whose document will be used for the copy.
- `indirect` (`bool`): If true, the copy will be an indirect object; if false, it will be direct.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the same document as obj.

Makes a new copy of this PDFObject in memory, in the same document as another object, using supplied direct/indirect setting.

### CompareTo

```csharp
PDFObjectComparison Datalogics.PDFL.PDFObject.CompareTo(PDFObject rhs)
```

**Parameters**

- `rhs` ([`PDFObject`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObject.md)): the other PDFObject to compare.

**Returns:** [`PDFObjectComparison`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/enum/PDFObjectComparison.md)

A PDFObjectComparison value that relates this object to the rhs object

Compares this object to another object. The result is useful for ordering or sorting PDFObjects. No other significance should be attached to the result. In particular, an unequal result indicates nothing about the type of either object.

The result is valid only within a single instance of the document.

### Destroy

```csharp
void Datalogics.PDFL.PDFObject.Destroy()
```

**Returns:** `void`

Destroys this object.

This method does nothing if this object is a direct scalar object.

If a composite object (an array, dictionary or stream) is destroyed: All the direct objects in it are automatically destroyed.
The indirect objects in it are not destroyed.

### Dispose

```csharp
void Datalogics.PDFL.PDFObject.Dispose()
```

**Returns:** `void`

### EnumPDFObjects

```csharp
bool Datalogics.PDFL.PDFObject.EnumPDFObjects(PDFObjectEnumProc enumProc)
```

**Parameters**

- `enumProc` ([`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/DotNet/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md)): A user-supplied callback to call for each element of the object. of obj. Neither proc nor any routine called by proc may modify the object. Doing so can produce undefined results or errors. For example, if the object is an array, enumProc must not call Remove(); if the object is a dictionary, enumProc must not call Put().

**Returns:** `bool`

Returns true if every call to enumProc returned true. As soon as any call to enumProc returns false, the enumeration stops and EnumPDFObject() returns false.

Enumerates the elements of a PDFObject by calling a user-supplied procedure for each component of the object. For scalars or strings, the proc is not called, and CosObjEnum() returns true.
For dictionaries, proc is called for each key-value pair. The order in which the key-value pairs are enumerated is undefined.
For arrays, proc is called with each element as the first paramater to proc, and the NULL object as the second parameter. Array elements are enumerated in ascending order of index.
For streams, proc is called once, with the stream's dictionary as the first parameter to the proc and the NULL object as the second parameter.

### Equals

```csharp
override bool Datalogics.PDFL.PDFObject.Equals(object obj)
```

**Parameters**

- `obj` (`object`)

**Returns:** `override bool`

### ToString

```csharp
override string Datalogics.PDFL.PDFString.ToString()
```

**Returns:** `override string`

A string describing this PDFString.

Returns a string representation of this PDFString.

The string includes the object's indirect status, value, and hex storage flag.
