Class PdfStream
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
intthe 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
intthe 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
PdfDocumentthe pdf document in which this stream lies
inputStream
Streamthe 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
PdfDocumentthe pdf document in which this stream lies
inputStream
Streamthe data to write to this stream
compressionLevel
intthe 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
outputStream
protected PdfOutputStream outputStream
Field Value
Methods
CopyContent(PdfObject, PdfDocument)
protected override void CopyContent(PdfObject from, PdfDocument document)
Parameters
from
PdfObjectdocument
PdfDocument
CopyContent(PdfObject, PdfDocument, ICopyFilter)
protected override void CopyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Parameters
from
PdfObjectdocument
PdfDocumentcopyFilter
ICopyFilter
GetBytes()
Gets decoded stream bytes.
public virtual byte[] GetBytes()
Returns
- byte[]
byte content of the
PdfStream
. Byte content will be null , if thePdfStream
was created byInputStream
.
Remarks
GetBytes(bool)
Gets stream bytes.
public virtual byte[] GetBytes(bool decoded)
Parameters
decoded
booltrue if to get decoded stream bytes, otherwise false.
Returns
- byte[]
byte content of the
PdfStream
. Byte content will be null , if thePdfStream
was created byInputStream
.
Remarks
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
GetLength()
public virtual int GetLength()
Returns
GetObjectType()
public override byte GetObjectType()
Returns
GetOffset()
protected virtual long GetOffset()
Returns
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
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
intthe 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
andappend
is false then stream's content will be discarded.append
boolIf 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
intthe new length
- See Also
-
iText.Kernel.Pdf.PdfReader.CheckPdfStreamLength(iText.Kernel.Pdf.PdfStream)