# PDFStream Class

> Represents a stream of data within a PDF document.

- Product: Adobe PDF Library 21
- Language: .NET Framework
- Version: APDFL21.0.0PlusP1e
- HTML page: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFStream
- Version index: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/llms.txt

```csharp
class PDFStream : PDFObject
```

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

**Inherits from:** [`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObject.md)

## Description

Represents a stream of data within a PDF document.

All objects in a PDF document are built from a collection of simpler objects that represent fundamental datatypes like numbers, strings and arrays.

PDFObject and its subclasses allow direct access and manipulation of these simple objects. Some subclasses represent single data elements (e.g. PDFInteger represents a single integer value); other subclasses represent a collection of PDFObjects (e.g. PDFArray is an indexed array of data elements).

A PDFStream represents a stream of unsigned bytes, and may be inserted into any collection object. It includes a dictionary that describes how the data in the stream is encoded and other useful information about the stream. A PDFStream is always an indirect object.

PDFStreams can be encoded using built-in filters. These filters include compression schemes for most popular image formats, and text encoding translators to permit safe transmission of the document over the Internet. The data in a PDFStream will be automatically encoded when it is created; the user can read either the encoded (raw) or decoded (filtered) data.

PDFStreams can be used for any large collection of data that need not be read into memory all at once, including image data, multimedia data or XML markup.

**Referenced by:** [`Form`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Form.md), [`ICCBasedColorSpace`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/ICCBasedColorSpace.md), [`Image`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Image.md), [`PostScript`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PostScript.md), [`PostScriptCalculatorFunction`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PostScriptCalculatorFunction.md)

**Uses types:** [`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md), [`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md), [`PDFDict`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFDict.md), [`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObject.md), [`PDFObjectComparison`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/PDFObjectComparison.md), [`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObjectEnumProc.md), [`PDFStreamOpenMode`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/PDFStreamOpenMode.md)

## Constructors

### PDFStream

```csharp
Datalogics.PDFL.PDFStream.PDFStream(System.IO.Stream stream, Document doc, PDFDict encoding_dict, PDFArray encoding_params)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): System.IO.Stream which will provide data for this PDFStream
- `doc` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): Document object containing this PDFStream
- `encoding_dict` ([`PDFDict`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFDict.md)): PDFDict describing properties of this stream, including the encoding
- `encoding_params` ([`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md)): PDFArray describing parameters for encoding this stream

General constructor

### PDFStream

```csharp
Datalogics.PDFL.PDFStream.PDFStream(System.IO.Stream stream, PDFObject docFromObj, PDFDict encoding_dict, PDFArray encoding_params)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): System.IO.Stream which will provide data for this PDFStream
- `docFromObj` ([`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObject.md)): The new PDFArray will be created in the same document as this object.
- `encoding_dict` ([`PDFDict`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFDict.md)): PDFDict describing properties of this stream, including the encoding
- `encoding_params` ([`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md)): PDFArray describing parameters for encoding this stream

General constructor

## Properties

### Dict

```csharp
PDFDict Datalogics.PDFL.PDFStream.Dict { get; }
```

The encoding dictionary for the stream. This includes all required information for decoding the stream, such as filter names and decode parameters.

### Document

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

The Document of which this object is a member.

Returns null if the Document is not known by PDFL, or if it is a temporary document.

If the Document is not null, then it shares the same internal data with other Document objects that refer to the same file. Document objects returned this way do not contribute to the internal count that keeps the Document open, and will become invalid if the main reference to the document is disposed.

### FilteredStream

```csharp
System.IO.Stream Datalogics.PDFL.PDFStream.FilteredStream { get; }
```

### Generation

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

The generation number for this object.

Only indirect objects have a generation number.

**Exceptions**

- `ApplicationException`: direct objects do not have a generation number.

### ID

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

The ID number for this object.

Only indirect objects have an ID number.

**Exceptions**

- `ApplicationException`: direct objects do not have an ID number.

### Indirect

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

Indicates if this object is indirect or direct.

### Length

```csharp
int Datalogics.PDFL.PDFStream.Length { get; }
```

The encoded length of the stream in bytes.

### PDFHashValue

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

The 32-bit hash value for this object.

The hash value is used internally to quickly access the object, and is not generally useful for PDFObject users. Note that two PDFObjects with equal hash values are not necessarily equal; use Equals() to check for equality.

### StreamPos

```csharp
int Datalogics.PDFL.PDFStream.StreamPos { get; }
```

The byte offset of this stream in the PDF file.

**Exceptions**

- `ApplicationException`: will be thrown if the document has not been saved since creating the stream

### UnfilteredStream

```csharp
System.IO.Stream Datalogics.PDFL.PDFStream.UnfilteredStream { get; }
```

## Methods

### Clone

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

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The target document in which to create the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObject.md)): The reference object whose document will be used for the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFObject.md)): the other PDFObject to compare.

**Returns:** [`PDFObjectComparison`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/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`

### GetFilteredStream

```csharp
System.IO.Stream Datalogics.PDFL.PDFStream.GetFilteredStream()
```

**Returns:** `System.IO.Stream`

The stream data of this object, decoded according to the filter data in its dictionary.

### GetStream

```csharp
System.IO.Stream Datalogics.PDFL.PDFStream.GetStream(PDFStreamOpenMode mode)
```

**Parameters**

- `mode` ([`PDFStreamOpenMode`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/PDFStreamOpenMode.md))

**Returns:** `System.IO.Stream`

The stream data of this object, processed according to the mode

### GetUnfilteredStream

```csharp
System.IO.Stream Datalogics.PDFL.PDFStream.GetUnfilteredStream()
```

**Returns:** `System.IO.Stream`

The unfiltered data of this stream object.

### SetData

```csharp
void Datalogics.PDFL.PDFStream.SetData(System.IO.Stream stream, PDFDict encoding_dict, PDFArray encoding_params)
```

**Parameters**

- `stream` (`System.IO.Stream`)
- `encoding_dict` ([`PDFDict`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFDict.md))
- `encoding_params` ([`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md))

**Returns:** `void`

Replace the data in this PDFStream

### ToString

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

**Returns:** `override string`

A string describing this PDFStream, including its indirect/direct status and ID.

Returns a string representation of this PDFStream.
