public class PdfStream extends PdfDictionary
PdfStream
is the Pdf stream object.
A stream, like a string, is a sequence of characters. However, an application can
read a small portion of a stream at a time, while a string must be read in its entirety.
For this reason, objects with potentially large amounts of data, such as images and
page descriptions, are represented as streams.
A stream consists of a dictionary that describes a sequence of characters, followed by
the keyword stream, followed by zero or more lines of characters, followed by
the keyword endstream.
All streams must be PdfIndirectObject
s. The stream dictionary must be a direct
object. The keyword stream that follows the stream dictionary should be followed by
a carriage return and linefeed or just a linefeed.
Remark: In this version only the FLATEDECODE-filter is supported.
This object is described in the 'Portable Document Format Reference Manual version 1.3'
section 4.8 (page 41-53).
PdfObject
,
PdfDictionary
Modifier and Type | Field and Description |
---|---|
protected boolean |
compressed
is the stream compressed?
|
(package private) static byte[] |
ENDSTREAM |
protected java.io.InputStream |
inputStream |
protected int |
inputStreamLength |
protected int |
rawLength |
protected PdfIndirectReference |
ref |
(package private) static int |
SIZESTREAM |
(package private) static byte[] |
STARTSTREAM |
protected java.io.ByteArrayOutputStream |
streamBytes |
protected PdfWriter |
writer |
Modifier | Constructor and Description |
---|---|
protected |
PdfStream()
Constructs a
PdfStream -object. |
|
PdfStream(byte[] bytes)
Constructs a
PdfStream -object. |
|
PdfStream(java.io.InputStream inputStream,
PdfWriter writer)
Creates an efficient stream.
|
Modifier and Type | Method and Description |
---|---|
void |
flateCompress()
Compresses the stream.
|
int |
getRawLength()
Gets the raw length of the stream.
|
protected void |
superToPdf(PdfWriter writer,
java.io.OutputStream os) |
void |
toPdf(PdfWriter writer,
java.io.OutputStream os)
Returns the PDF representation of this
PdfDictionary . |
void |
writeContent(java.io.OutputStream os)
Writes the data content to an
OutputStream . |
void |
writeLength()
Writes the stream length to the
PdfWriter . |
contains, get, getKeys, isCatalog, isDictionaryType, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, putDel, putEx, remove, size, toString
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
protected boolean compressed
protected java.io.ByteArrayOutputStream streamBytes
protected java.io.InputStream inputStream
protected PdfIndirectReference ref
protected int inputStreamLength
protected PdfWriter writer
protected int rawLength
static final byte[] STARTSTREAM
static final byte[] ENDSTREAM
static final int SIZESTREAM
public PdfStream(byte[] bytes)
PdfStream
-object.bytes
- content of the new PdfObject
as an array of byte
.public PdfStream(java.io.InputStream inputStream, PdfWriter writer)
InputStream
is totally consumed but is not closed. The general usage is:
InputStream in = ...; PdfStream stream = new PdfStream(in, writer); stream.flateCompress(); writer.addToBody(stream); stream.writeLength(); in.close();
inputStream
- the data to write to this streamwriter
- the PdfWriter
for this streamprotected PdfStream()
PdfStream
-object.public void writeLength() throws java.io.IOException
PdfWriter
.
This method must be called and can only be called if the contructor PdfStream(InputStream,PdfWriter)
is used to create the stream.
java.io.IOException
- on errorPdfStream(InputStream,PdfWriter)
public int getRawLength()
public void flateCompress()
protected void superToPdf(PdfWriter writer, java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void toPdf(PdfWriter writer, java.io.OutputStream os) throws java.io.IOException
PdfDictionary
PdfDictionary
.toPdf
in class PdfDictionary
writer
- for backwards compatibilityos
- the outputstream to write the bytes to.java.io.IOException
PdfDictionary.toPdf(com.lowagie.text.pdf.PdfWriter, java.io.OutputStream)
public void writeContent(java.io.OutputStream os) throws java.io.IOException
OutputStream
.os
- the destination to write tojava.io.IOException
- on error