PdfStream Class
Represents a sequence of bytes. PdfStream consists of a Dictionary and a Length number of bytes that represent, a potentially and usually encoded, stream's data.
public sealed class PdfStream : PdfBasicContainer
Public NotInheritable Class PdfStream
Inherits PdfBasicContainer
- Inheritance:
- System.ObjectPdfStream
Properties
DecodedLength
(Optional; PDF 1.5) A non-negative System.Int32 representing the number of bytes in the decoded (defiltered) PdfStream. It can be used to determine, for example, whether enough disk space is available to write a PdfStream to a file.
This value shall be considered a hint only; for some stream filters, it may not be possible to determine this value precisely.
Property Value
- System.Nullable<System.Int32>
A non-negative System.Int32 representing the number of bytes in the decoded (defiltered) PdfStream.
Exceptions
- System.ArgumentOutOfRangeException
Value is less than zero.
Value is not according to PDF Specification ISO 32000-1:2008.
See Also
Dictionary
Gets the stream's dictionary.
public PdfDictionary Dictionary { get; }
Public ReadOnly Property Dictionary As PdfDictionary
Property Value
The stream's dictionary.
Filters
Gets the filters applied to this PdfStream.
public PdfFilterCollection Filters { get; }
Public ReadOnly Property Filters As PdfFilterCollection
Property Value
The filters applied to this PdfStream.
Length
(Required) The number of bytes from the beginning of the line following the keyword stream to the last byte just before the keyword endstream. (There may be an additional EOL marker, preceding endstream, that is not included in the count and is not logically part of the stream data.) See 7.3.8.2, "Stream Extent", for further discussion.
Property Value
- System.Int32
The number of bytes from the beginning of the line following the keyword stream to the last byte just before the keyword endstream.
Exceptions
- System.ArgumentOutOfRangeException
Value is less than zero.
Value is not according to PDF Specification ISO 32000-1:2008.
See Also
ObjectType
Gets the Stream value.
public override PdfBasicObjectType ObjectType { get; }
Public Overrides ReadOnly Property ObjectType As PdfBasicObjectType
Property Value
The Stream value.
Overrides
Methods
Clone(Boolean)
Makes a deep clone of the PdfStream with optionally cloning descendant PdfIndirectObjects.
public PdfStream Clone(bool shallowIndirect)
Public Function Clone(shallowIndirect As Boolean) As PdfStream
Parameters
shallowIndirect
- System.Boolean
if set to true descendant PdfIndirectObjects won't be cloned.
Returns
Clone(Func<PdfIndirectObject, PdfBasicObject>)
Makes a deep clone of the PdfStream with parameter that controls the cloning of PdfIndirectObjects.
public PdfStream Clone(Func<PdfIndirectObject, PdfBasicObject> indirectObjectClone)
Public Function Clone(indirectObjectClone As Func(Of PdfIndirectObject, PdfBasicObject)) As PdfStream
Parameters
indirectObjectClone
- System.Func<PdfIndirectObject, PdfBasicObject>
A parameter that controls the cloning of PdfIndirectObjects.
Returns
Create()
Creates a new instance of the PdfStream class.
Returns
Remarks
GemBox.Pdf assembly doesn't publicly expose constructors for types assignable from PdfObject (except PdfDocument), PdfContentElement, and PdfBasicObject types. These types are instead instantiated either through static Create or other factory methods.
Reasons for this is to support either the current or future extensibility of the type without affecting backward compatibility and without using composition to reduce the number of object allocations.
For example, PdfNumber type is implemented as PdfInteger and internal PdfReal type. When using Create(Double) method, GemBox.Pdf assembly is able to create either PdfReal or PdfInteger, or return a cached instance of PdfInteger available for an implementation-defined interval of integers, thus reducing memory overhead.
PdfString and PdfName types have several internal implementations that reduce the number of System.Array allocations.
PdfArray type is currently implemented as a dynamic array. In the future, GemBox.Pdf assembly might provide an internal implementation that is immutable (without a need to use composition) to reduce memory overhead and optimize cloning operation.
PdfDictionary type is currently implemented as a hash table with a separate chaining collision resolution. In the future, GemBox.Pdf assembly might provide an internal implementation that uses dynamic array (without a need to use composition) if number of entries is small, to reduce memory overhead and, potentially, improve performance.
All these current and future implementations would not be possible in a backward compatible way (without unnecessary usage of composition) if constructors were publicly exposed.
See Also
Open(PdfStreamDataMode, PdfStreamDataState, PdfStreamDataOptions)
Opens this PdfStream so its data can be accessed.
public Stream Open(PdfStreamDataMode mode, PdfStreamDataState state, PdfStreamDataOptions options = PdfStreamDataOptions.Default)
Public Function Open(mode As PdfStreamDataMode, state As PdfStreamDataState, options As PdfStreamDataOptions = PdfStreamDataOptions.Default) As Stream
Parameters
The mode in which PdfStream data should be opened.
state
- PdfStreamDataState
The state in which PdfStream data should be opened.
options
- PdfStreamDataOptions
The options with which PdfStream data should be opened.
Returns
- System.IO.Stream
A System.IO.Stream that can be used to either read or write PdfStream data.
Remarks
Decoded data is cached in the PdfStream or is removed from the PdfStream based on the following combination of parameters:
mode is Read, state is Encoded and options doesn't have the CacheDecoded set: | If decoded data was cached in the PdfStream, it is removed. |
mode is Read, state is Decoded and options has the CacheDecoded set: | If decoded data was not cached in the PdfStream and returned decoded data System.IO.Stream is read to the end, its (decoded) data is cached in the PdfStream. |
mode is Write, state is Decoded and options has the CacheDecoded set: | Decoded data written to the returned System.IO.Stream is cached in the PdfStream. PdfStream data will be encoded when encoded data is requested. |
Any other combination of mode , state and options : | Cached decoded data in the PdfStream remains unchanged. |
Returned System.IO.Stream must be disposed after it is no longer needed, otherwise, subsequent opening of PdfStream will fail.
Exceptions
- System.InvalidOperationException
PdfStream is already opened. Make sure that System.IO.Stream instance returned from Open(PdfStreamDataMode, PdfStreamDataState, PdfStreamDataOptions) method is disposed before calling Open(PdfStreamDataMode, PdfStreamDataState, PdfStreamDataOptions) method again.
- System.NotSupportedException
PdfStream specifies external data (through F entry) that is currently not supported.
ToString()
Returns a System.String that represents this PdfStream instance.
Returns
- System.String
A System.String that represents this PdfStream instance.
Overrides
Remarks
This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).
Inherited Properties
Indirect | Gets the PdfIndirectObject if this PdfBasicContainer is Value or null otherwise. (Inherited from PdfBasicContainer) |
IsReadOnly | Gets a value indicating whether the PdfBasicContainer and all of its descendants are read-only. (Inherited from PdfBasicContainer) |
Null | Gets the single instance of Null type. (Inherited from PdfBasicObject) |
Inherited Methods
Equals(System.Object) | Determines whether the specified System.Object is equal to this PdfBasicContainer instance. (Inherited from PdfBasicContainer) |
GetHashCode() | Returns a hash code for this PdfBasicContainer instance. (Inherited from PdfBasicContainer) |