# PdfString class

> A PDF string: a sequence of bytes, which may hold text or binary data.

Namespace: [PdfNetStack.Objects](https://www.jadev-corp.com/api/pdfnetstack-objects/)  
Assembly: PdfNetStack.dll  
Package: `PdfNetStack`

A PDF string: a sequence of bytes, which may hold text or binary data.

```csharp
public sealed class PdfString : PdfObject
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfObject](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfobject/) ← 
[PdfString](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfstring/)

## Constructors

### <a id="PdfNetStack_Objects_PdfString__ctor_System_ReadOnlySpan_System_Byte__"></a> PdfString\(ReadOnlySpan&lt;byte\>\)

Creates a string holding a copy of <code class="paramref">bytes</code>.

```csharp
public PdfString(ReadOnlySpan<byte> bytes)
```

#### Parameters

`bytes` [ReadOnlySpan](https://learn.microsoft.com/dotnet/api/system.readonlyspan\-1)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)\>

## Properties

### <a id="PdfNetStack_Objects_PdfString_Bytes"></a> Bytes

The raw bytes.

```csharp
public ReadOnlySpan<byte> Bytes { get; }
```

#### Property Value

 [ReadOnlySpan](https://learn.microsoft.com/dotnet/api/system.readonlyspan\-1)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)\>

## Methods

### <a id="PdfNetStack_Objects_PdfString_FromText_System_String_"></a> FromText\(string\)

Creates a text string (ISO 32000-1, 7.9.2.2): PDFDocEncoding when every character fits,
otherwise UTF-16 with a byte order mark.

```csharp
public static PdfString FromText(string text)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Returns

 [PdfString](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfstring/)

### <a id="PdfNetStack_Objects_PdfString_ToString"></a> ToString\(\)

Returns a string that represents the current object.

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

A string that represents the current object.

### <a id="PdfNetStack_Objects_PdfString_ToText"></a> ToText\(\)

Decodes the bytes as a text string: UTF-16 or UTF-8 with a byte order mark, otherwise PDFDocEncoding.

```csharp
public string ToText()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Used in

- [Edit PDF pages in C# and .NET](https://www.jadev-corp.com/guides/edit-pages/)
- [Fill and create PDF forms in C# and .NET](https://www.jadev-corp.com/guides/forms/)
- [Low level PDF objects in C#](https://www.jadev-corp.com/guides/low-level-objects/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-objects/pdfstring/
