iText 8.0.5 API
iText.Kernel.Pdf.PdfStream Class Reference

Representation of a stream as described in the PDF Specification. More...

Inheritance diagram for iText.Kernel.Pdf.PdfStream:
iText.Kernel.Pdf.PdfDictionary iText.Kernel.Pdf.PdfObject

Public Member Functions

  PdfStream (byte[] bytes, int compressionLevel)
  Constructs a PdfStream -object. More...
 
  PdfStream (byte[] bytes)
  Creates a PdfStream instance. More...
 
  PdfStream (PdfDocument doc, Stream inputStream, int compressionLevel)
  Creates an efficient stream. More...
 
  PdfStream (PdfDocument doc, Stream inputStream)
  Creates an efficient stream. More...
 
  PdfStream (int compressionLevel)
  Constructs a PdfStream -object. More...
 
  PdfStream ()
  Creates an empty PdfStream instance. More...
 
virtual PdfOutputStream  GetOutputStream ()
  Gets output stream. More...
 
virtual int  GetCompressionLevel ()
  Gets compression level of this PdfStream. More...
 
virtual void  SetCompressionLevel (int compressionLevel)
  Sets compression level of this PdfStream. More...
 
override byte  GetObjectType ()
  Gets object type. More...
 
virtual int  GetLength ()
 
virtual byte[]  GetBytes ()
  Gets decoded stream bytes. More...
 
virtual byte[]  GetBytes (bool decoded)
  Gets stream bytes. More...
 
virtual void  SetData (byte[] bytes)
  Sets bytes as stream's content. More...
 
virtual void  SetData (byte[] bytes, bool append)
  Sets or appends bytes to stream content. More...
 
- Public Member Functions inherited from iText.Kernel.Pdf.PdfDictionary
  PdfDictionary ()
  Creates a new PdfDictionary instance. More...
 
  PdfDictionary (IDictionary< PdfName, PdfObject > map)
  Creates a new PdfDictionary instance. More...
 
  PdfDictionary (ICollection< KeyValuePair< PdfName, PdfObject >> entrySet)
  Creates a new PdfDictionary instance. More...
 
  PdfDictionary (iText.Kernel.Pdf.PdfDictionary dictionary)
  Creates a new PdfDictionary instance. More...
 
virtual int  Size ()
  Returns the number of key-value pairs in this PdfDictionary. More...
 
virtual bool  IsEmpty ()
  Returns true if there are no key-value pairs in this PdfDictionary. More...
 
virtual bool  ContainsKey (PdfName key)
  Returns true if this PdfDictionary contains the specified key. More...
 
virtual bool  ContainsValue (PdfObject value)
  Returns true if this PdfDictionary contains the specified value. More...
 
virtual PdfObject  Get (PdfName key)
  Returns the value associated to this key. More...
 
virtual PdfArray  GetAsArray (PdfName key)
  Returns the value associated to this key as a PdfArray. More...
 
virtual iText.Kernel.Pdf.PdfDictionary  GetAsDictionary (PdfName key)
  Returns the value associated to this key as a PdfDictionary. More...
 
virtual PdfStream  GetAsStream (PdfName key)
  Returns the value associated to this key as a PdfStream. More...
 
virtual PdfNumber  GetAsNumber (PdfName key)
  Returns the value associated to this key as a PdfNumber. More...
 
virtual PdfName  GetAsName (PdfName key)
  Returns the value associated to this key as a PdfName. More...
 
virtual PdfString  GetAsString (PdfName key)
  Returns the value associated to this key as a PdfString. More...
 
virtual PdfBoolean  GetAsBoolean (PdfName key)
  Returns the value associated to this key as a PdfBoolean. More...
 
virtual Rectangle  GetAsRectangle (PdfName key)
  Returns the value associated to this key as a Rectangle. More...
 
virtual ? float  GetAsFloat (PdfName key)
  Returns the value associated to this key as a Float. More...
 
virtual ? int  GetAsInt (PdfName key)
  Returns the value associated to this key as an Integer. More...
 
virtual ? bool  GetAsBool (PdfName key)
  Returns the value associated to this key as a Boolean. More...
 
virtual PdfObject  Put (PdfName key, PdfObject value)
  Inserts the value into this PdfDictionary and associates it with the specified key. More...
 
virtual PdfObject  Remove (PdfName key)
  Removes the specified key from this PdfDictionary. More...
 
virtual void  PutAll (iText.Kernel.Pdf.PdfDictionary d)
  Inserts all the key-value pairs into this PdfDictionary. More...
 
virtual void  Clear ()
  Removes all key-value pairs from this PdfDictionary. More...
 
virtual ICollection< PdfName KeySet ()
  Returns all the keys of this PdfDictionary as a Set. More...
 
virtual ICollection< PdfObject Values (bool asDirects)
  Returns all the values of this map in a Collection. More...
 
virtual ICollection< PdfObject Values ()
  Returns all the values of this map in a Collection. More...
 
virtual ICollection< KeyValuePair< PdfName, PdfObject > >  EntrySet ()
  Returns a Set holding the key-value pairs as Map::Entry objects. More...
 
override String  ToString ()
 
virtual iText.Kernel.Pdf.PdfDictionary  Clone (IList< PdfName > excludeKeys)
  Creates clones of the dictionary in the current document. More...
 
virtual iText.Kernel.Pdf.PdfDictionary  CopyTo (PdfDocument document, IList< PdfName > excludeKeys, bool allowDuplicating)
  Copies dictionary to specified document. More...
 
virtual iText.Kernel.Pdf.PdfDictionary  CopyTo (PdfDocument document, IList< PdfName > excludeKeys, bool allowDuplicating, ICopyFilter copyFilter)
  Copies dictionary to specified document. More...
 
virtual PdfObject  Get (PdfName key, bool asDirect)
 
virtual void  MergeDifferent (iText.Kernel.Pdf.PdfDictionary other)
  This method merges different fields from two dictionaries into the current one More...
 
- Public Member Functions inherited from iText.Kernel.Pdf.PdfObject
void  Flush ()
  Flushes the object to the document. More...
 
void  Flush (bool canBeInObjStm)
  Flushes the object to the document. More...
 
virtual PdfIndirectReference  GetIndirectReference ()
  Gets the indirect reference associated with the object. More...
 
virtual bool  IsIndirect ()
  Checks if object is indirect. More...
 
virtual PdfObject  MakeIndirect (PdfDocument document, PdfIndirectReference reference)
  Marks object to be saved as indirect. More...
 
virtual PdfObject  MakeIndirect (PdfDocument document)
  Marks object to be saved as indirect. More...
 
virtual bool  IsFlushed ()
  Indicates is the object has been flushed or not. More...
 
virtual bool  IsModified ()
  Indicates is the object has been set as modified or not. More...
 
virtual PdfObject  Clone ()
  Creates clone of the object which belongs to the same document as original object. More...
 
virtual PdfObject  Clone (ICopyFilter filter)
  Creates clone of the object which belongs to the same document as original object. More...
 
virtual PdfObject  CopyTo (PdfDocument document)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, bool allowDuplicating)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, ICopyFilter copyFilter)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, bool allowDuplicating, ICopyFilter copyFilter)
  Copies object to a specified document. More...
 
virtual PdfObject  SetModified ()
  Sets the 'modified' flag to the indirect object, the flag denotes that the object was modified since the document opening. More...
 
virtual bool  IsReleaseForbidden ()
  Checks if it's forbidden to release this PdfObject instance. More...
 
virtual void  Release ()
 
virtual bool  IsNull ()
  Checks if this PdfObject is of the type PdfNull. More...
 
virtual bool  IsBoolean ()
  Checks if this PdfObject is of the type PdfBoolean. More...
 
virtual bool  IsNumber ()
  Checks if this PdfObject is of the type PdfNumber. More...
 
virtual bool  IsString ()
  Checks if this PdfObject is of the type PdfString. More...
 
virtual bool  IsName ()
  Checks if this PdfObject is of the type PdfName. More...
 
virtual bool  IsArray ()
  Checks if this PdfObject is of the type PdfArray. More...
 
virtual bool  IsDictionary ()
  Checks if this PdfObject is of the type PdfDictionary. More...
 
virtual bool  IsStream ()
  Checks if this PdfObject is of the type PdfStream. More...
 
virtual bool  IsIndirectReference ()
  Checks if this PdfObject is of the type PdfIndirectReference. More...
 
virtual bool  IsLiteral ()
  Checks if this PdfObject is of the type PdfLiteral. More...
 

Package Functions

  PdfStream (Stream outputStream)
 
override PdfObject  NewInstance ()
  Creates new instance of object. More...
 
virtual long  GetOffset ()
 
virtual void  UpdateLength (int length)
  Update length manually in case its correction. More...
 
override void  CopyContent (PdfObject from, PdfDocument document)
  Copies object content from object 'from'. More...
 
override void  CopyContent (PdfObject from, PdfDocument document, ICopyFilter copyFilter)
  Copies object content from object 'from'. More...
 
virtual void  InitOutputStream (Stream stream)
 
override void  ReleaseContent ()
  Release content of PdfStream. More...
 
virtual Stream  GetInputStream ()
 
- Package Functions inherited from iText.Kernel.Pdf.PdfObject
virtual PdfObject  SetIndirectReference (PdfIndirectReference indirectReference)
 
virtual bool  CheckState (short state)
  Checks state of the flag of current object. More...
 
virtual PdfObject  SetState (short state)
  Sets special states of current object. More...
 
virtual PdfObject  ClearState (short state)
  Clear state of the flag of current object. More...
 

Package Attributes

int  compressionLevel
 
PdfOutputStream  outputStream
 
- Package Attributes inherited from iText.Kernel.Pdf.PdfObject
PdfIndirectReference  indirectReference = null
  If object is flushed the indirect reference is kept here. More...
 

Additional Inherited Members

- Static Public Attributes inherited from iText.Kernel.Pdf.PdfObject
const byte  ARRAY = 1
 
const byte  BOOLEAN = 2
 
const byte  DICTIONARY = 3
 
const byte  LITERAL = 4
 
const byte  INDIRECT_REFERENCE = 5
 
const byte  NAME = 6
 
const byte  NULL = 7
 
const byte  NUMBER = 8
 
const byte  STREAM = 9
 
const byte  STRING = 10
 
- Static Package Attributes inherited from iText.Kernel.Pdf.PdfObject
const short  FLUSHED = 1
  Indicates if the object has been flushed. More...
 
const short  FREE = 1 << 1
  Indicates that the indirect reference of the object could be reused or have to be marked as free. More...
 
const short  READING = 1 << 2
  Indicates that definition of the indirect reference of the object still not found (e.g. keys in XRefStm). More...
 
const short  MODIFIED = 1 << 3
  Indicates that object changed (is used in append mode). More...
 
const short  ORIGINAL_OBJECT_STREAM = 1 << 4
  Indicates that the indirect reference of the object represents ObjectStream from original document. More...
 
const short  MUST_BE_FLUSHED = 1 << 5
  For internal usage only. More...
 
const short  MUST_BE_INDIRECT = 1 << 6
  Indicates that the object shall be indirect when it is written to the document. More...
 
const short  FORBID_RELEASE = 1 << 7
  Indicates that the object is highly sensitive and we do not want to release it even if release() is called. More...
 
const short  READ_ONLY = 1 << 8
  Indicates that we do not want this object to be ever written into the resultant document (because of multiple objects read from the same reference inconsistency). More...
 
const short  UNENCRYPTED = 1 << 9
  Indicates that this object is not encrypted in the encrypted document. More...
 

Detailed Description

Representation of a stream as described in the PDF Specification.

Constructor & Destructor Documentation

◆ PdfStream() [1/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( byte[]  bytes,
int  compressionLevel 
)
inline

Constructs a PdfStream -object.

Parameters
bytes initial content of PdfOutputStream.
compressionLevel the compression level (0 = best speed, 9 = best compression, -1 is default)

◆ PdfStream() [2/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( byte[]  bytes )
inline

Creates a PdfStream instance.

Parameters
bytes bytes to write to the PdfStream

◆ PdfStream() [3/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( PdfDocument  doc,
Stream  inputStream,
int  compressionLevel 
)
inline

Creates an efficient stream.

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();
Parameters
doc the pdf document in which this stream lies
inputStream the data to write to this stream
compressionLevel the compression level (0 = best speed, 9 = best compression, -1 is default)

◆ PdfStream() [4/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( PdfDocument  doc,
Stream  inputStream 
)
inline

Creates an efficient stream.

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();
Parameters
doc the pdf document in which this stream lies
inputStream the data to write to this stream

◆ PdfStream() [5/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( int  compressionLevel )
inline

Constructs a PdfStream -object.

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

◆ PdfStream() [6/6]

iText.Kernel.Pdf.PdfStream.PdfStream ( )
inline

Creates an empty PdfStream instance.

Member Function Documentation

◆ CopyContent() [1/2]

override void iText.Kernel.Pdf.PdfStream.CopyContent ( PdfObject  from,
PdfDocument  document 
)
inlinepackagevirtual

Copies object content from object 'from'.

Reimplemented from iText.Kernel.Pdf.PdfDictionary.

◆ CopyContent() [2/2]

override void iText.Kernel.Pdf.PdfStream.CopyContent ( PdfObject  from,
PdfDocument  document,
ICopyFilter  copyFilter 
)
inlinepackagevirtual

Copies object content from object 'from'.

Reimplemented from iText.Kernel.Pdf.PdfDictionary.

◆ GetBytes() [1/2]

virtual byte [] iText.Kernel.Pdf.PdfStream.GetBytes ( )
inlinevirtual

Gets decoded stream bytes.

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

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

◆ GetBytes() [2/2]

virtual byte [] iText.Kernel.Pdf.PdfStream.GetBytes ( bool  decoded )
inlinevirtual

Gets stream bytes.

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

Parameters
decoded true if to get decoded stream bytes, otherwise false.
Returns
byte content of the PdfStream . Byte content will be null , if the PdfStream was created by InputStream.

◆ GetCompressionLevel()

virtual int iText.Kernel.Pdf.PdfStream.GetCompressionLevel ( )
inlinevirtual

Gets compression level of this PdfStream.

Gets compression level of this PdfStream. For more details

See also
iText.IO.Source.DeflaterOutputStream.
Returns
compression level.

◆ GetObjectType()

override byte iText.Kernel.Pdf.PdfStream.GetObjectType ( )
inlinevirtual

Gets object type.

Returns
object type.

Reimplemented from iText.Kernel.Pdf.PdfDictionary.

◆ GetOutputStream()

virtual PdfOutputStream iText.Kernel.Pdf.PdfStream.GetOutputStream ( )
inlinevirtual

Gets output stream.

Returns
output stream

◆ NewInstance()

override PdfObject iText.Kernel.Pdf.PdfStream.NewInstance ( )
inlinepackagevirtual

Creates new instance of object.

Returns
new instance of object.

Reimplemented from iText.Kernel.Pdf.PdfDictionary.

◆ ReleaseContent()

override void iText.Kernel.Pdf.PdfStream.ReleaseContent ( )
inlinepackagevirtual

Release content of PdfStream.

Reimplemented from iText.Kernel.Pdf.PdfDictionary.

◆ SetCompressionLevel()

virtual void iText.Kernel.Pdf.PdfStream.SetCompressionLevel ( int  compressionLevel )
inlinevirtual

Sets compression level of this PdfStream.

Sets compression level of this PdfStream. For more details

See also
iText.IO.Source.DeflaterOutputStream.
Parameters
compressionLevel the compression level (0 = best speed, 9 = best compression, -1 is default)

◆ SetData() [1/2]

virtual void iText.Kernel.Pdf.PdfStream.SetData ( byte[]  bytes )
inlinevirtual

Sets bytes as stream's content.

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

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

◆ SetData() [2/2]

virtual void iText.Kernel.Pdf.PdfStream.SetData ( byte[]  bytes,
bool  append 
)
inlinevirtual

Sets or appends bytes to stream content.

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

Parameters
bytes 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 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.

◆ UpdateLength()

virtual void iText.Kernel.Pdf.PdfStream.UpdateLength ( int  length )
inlinepackagevirtual

Update length manually in case its correction.

Parameters
length the new length
See also
PdfReader.CheckPdfStreamLength(PdfStream)