Table of Contents

Class PdfStream

Namespace
iText.Kernel.Pdf
Assembly
itext.kernel.dll

Representation of a stream as described in the PDF Specification.

public class PdfStream : PdfDictionary
Inheritance
PdfStream
Inherited Members
Extension Methods

Constructors

PdfStream()

Creates an empty PdfStream instance.

public PdfStream()

PdfStream(byte[])

Creates a PdfStream instance.

public PdfStream(byte[] bytes)

Parameters

bytes byte[]

bytes to write to the PdfStream

PdfStream(byte[], int)

Constructs a PdfStream -object.

public PdfStream(byte[] bytes, int compressionLevel)

Parameters

bytes byte[]

initial content of PdfOutputStream.

compressionLevel int

the compression level (0 = best speed, 9 = best compression, -1 is default)

PdfStream(Stream)

protected PdfStream(Stream outputStream)

Parameters

outputStream Stream

PdfStream(int)

Constructs a PdfStream -object.

public PdfStream(int compressionLevel)

Parameters

compressionLevel int

the compression level (0 = best speed, 9 = best compression, -1 is default)

PdfStream(PdfDocument, Stream)

Creates an efficient stream.

public PdfStream(PdfDocument doc, Stream inputStream)

Parameters

doc PdfDocument

the pdf document in which this stream lies

inputStream Stream

the data to write to this stream

Remarks

Creates an efficient stream. No temporary array is ever created. The InputStream is totally consumed but is not closed. The general usage is:

PdfDocument document = ?;
InputStream in = ?;
PdfStream stream = new PdfStream(document, in);
stream.flush();
in.close();

PdfStream(PdfDocument, Stream, int)

Creates an efficient stream.

public PdfStream(PdfDocument doc, Stream inputStream, int compressionLevel)

Parameters

doc PdfDocument

the pdf document in which this stream lies

inputStream Stream

the data to write to this stream

compressionLevel int

the compression level (0 = best speed, 9 = best compression, -1 is default)

Remarks

Creates an efficient stream. No temporary array is ever created. The InputStream is totally consumed but is not closed. The general usage is:

PdfDocument document = ?;
InputStream in = ?;
PdfStream stream = new PdfStream(document, in, PdfOutputStream.DEFAULT_COMPRESSION);
?
stream.flush();
in.close();

Fields

compressionLevel

protected int compressionLevel

Field Value

int

outputStream

protected PdfOutputStream outputStream

Field Value

PdfOutputStream

Methods

CopyContent(PdfObject, PdfDocument)

protected override void CopyContent(PdfObject from, PdfDocument document)

Parameters

from PdfObject
document PdfDocument

CopyContent(PdfObject, PdfDocument, ICopyFilter)

protected override void CopyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)

Parameters

from PdfObject
document PdfDocument
copyFilter ICopyFilter

GetBytes()

Gets decoded stream bytes.

public virtual byte[] GetBytes()

Returns

byte[]

byte content of the PdfStream . Byte content will be null , if the PdfStream was created by InputStream.

Remarks

Gets decoded stream bytes. Note, DCTDecode and JPXDecode filters will be ignored.

GetBytes(bool)

Gets stream bytes.

public virtual byte[] GetBytes(bool decoded)

Parameters

decoded bool

true if to get decoded stream bytes, otherwise false.

Returns

byte[]

byte content of the PdfStream . Byte content will be null , if the PdfStream was created by InputStream.

Remarks

Gets stream bytes. Note, DCTDecode and JPXDecode filters will be ignored.

GetCompressionLevel()

Gets compression level of this PdfStream.

public virtual int GetCompressionLevel()

Returns

int

compression level.

Remarks

Gets compression level of this PdfStream. For more details @see DeflaterOutputStream.

GetInputStream()

protected virtual Stream GetInputStream()

Returns

Stream

GetLength()

public virtual int GetLength()

Returns

int

GetObjectType()

public override byte GetObjectType()

Returns

byte

GetOffset()

protected virtual long GetOffset()

Returns

long

GetOutputStream()

Gets output stream.

public virtual PdfOutputStream GetOutputStream()

Returns

PdfOutputStream

output stream

InitOutputStream(Stream)

protected virtual void InitOutputStream(Stream stream)

Parameters

stream Stream

NewInstance()

protected override PdfObject NewInstance()

Returns

PdfObject

ReleaseContent()

Release content of PdfStream.

protected override void ReleaseContent()

SetCompressionLevel(int)

Sets compression level of this PdfStream.

public virtual void SetCompressionLevel(int compressionLevel)

Parameters

compressionLevel int

the compression level (0 = best speed, 9 = best compression, -1 is default)

Remarks

Sets compression level of this PdfStream. For more details @see DeflaterOutputStream.

SetData(byte[])

Sets bytes as stream's content.

public virtual void SetData(byte[] bytes)

Parameters

bytes byte[]

new content for stream; if null then stream's content will be discarded

Remarks

Sets bytes as stream's content. Could not be used with streams which were created by InputStream.

SetData(byte[], bool)

Sets or appends bytes to stream content.

public virtual void SetData(byte[] bytes, bool append)

Parameters

bytes byte[]

New content for stream. These bytes are considered to be a raw data (i.e. not encoded/compressed/encrypted) and if it's not true, the corresponding filters shall be set to the PdfStream object manually. Data compression generally should be configured via SetCompressionLevel(int) and is handled on stream writing to the output document. If null and append is false then stream's content will be discarded.

append bool

If set to true then bytes will be appended to the end, rather then replace original content. The original content will be decoded if needed.

Remarks

Sets or appends bytes to stream content. Could not be used with streams which were created by InputStream.

UpdateLength(int)

Update length manually in case its correction.

protected virtual void UpdateLength(int length)

Parameters

length int

the new length

See Also
iText.Kernel.Pdf.PdfReader.CheckPdfStreamLength(iText.Kernel.Pdf.PdfStream)