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.7'
section 3.2.7 (page 60-63).
PdfObject
,
PdfDictionary
Modifier and Type | Field and Description |
---|---|
static int |
BEST_COMPRESSION
A possible compression level.
|
static int |
BEST_SPEED
A possible compression level.
|
protected boolean |
compressed
is the stream compressed?
|
protected int |
compressionLevel
The level of compression.
|
static int |
DEFAULT_COMPRESSION
A possible compression level.
|
protected InputStream |
inputStream |
protected int |
inputStreamLength |
static int |
NO_COMPRESSION
A possible compression level.
|
protected int |
rawLength |
protected PdfIndirectReference |
ref |
protected ByteArrayOutputStream |
streamBytes |
protected PdfWriter |
writer |
Modifier | Constructor and Description |
---|---|
protected |
PdfStream()
Constructs a
PdfStream -object. |
|
PdfStream(byte[] bytes)
Constructs a
PdfStream -object. |
|
PdfStream(InputStream inputStream,
PdfWriter writer)
Creates an efficient stream.
|
Modifier and Type | Method and Description |
---|---|
void |
flateCompress()
Compresses the stream.
|
void |
flateCompress(int compressionLevel)
Compresses the stream.
|
int |
getRawLength()
Gets the raw length of the stream.
|
protected void |
superToPdf(PdfWriter writer,
OutputStream os) |
void |
toPdf(PdfWriter writer,
OutputStream os)
Writes the PDF representation of this
PdfDictionary as an
array of byte to the given OutputStream . |
String |
toString()
Returns a string representation of this
PdfDictionary . |
void |
writeContent(OutputStream os)
Writes the data content to an
OutputStream . |
void |
writeLength()
Writes the stream length to the
PdfWriter . |
contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsStream, getAsString, getDirectObject, getKeys, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, putEx, remove, size
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
public static final int DEFAULT_COMPRESSION
public static final int NO_COMPRESSION
public static final int BEST_SPEED
public static final int BEST_COMPRESSION
protected boolean compressed
protected int compressionLevel
protected ByteArrayOutputStream streamBytes
protected InputStream inputStream
protected PdfIndirectReference ref
protected int inputStreamLength
protected PdfWriter writer
protected int rawLength
public PdfStream(byte[] bytes)
PdfStream
-object.bytes
- content of the new PdfObject
as an array of byte
.public PdfStream(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 IOException
PdfWriter
.
This method must be called and can only be called if the constructor PdfStream(InputStream,PdfWriter)
is used to create the stream.
IOException
- on errorPdfStream(InputStream,PdfWriter)
public int getRawLength()
public void flateCompress()
public void flateCompress(int compressionLevel)
compressionLevel
- the compression level (0 = best speed, 9 = best compression, -1 is default)protected void superToPdf(PdfWriter writer, OutputStream os) throws IOException
IOException
public void toPdf(PdfWriter writer, OutputStream os) throws IOException
PdfDictionary
PdfDictionary
as an
array of byte
to the given OutputStream
.toPdf
in class PdfDictionary
writer
- for backwards compatibilityos
- the OutputStream
to write the bytes to.IOException
PdfDictionary.toPdf(com.lowagie.text.pdf.PdfWriter, java.io.OutputStream)
public void writeContent(OutputStream os) throws IOException
OutputStream
.os
- the destination to write toIOException
- on errorpublic String toString()
PdfDictionary
PdfDictionary
.
The string doesn't contain any of the content of this dictionary.
Rather the string "dictionary" is returned, possibly followed by the
type of this PdfDictionary
, if set.toString
in class PdfDictionary
PdfDictionary
PdfObject.toString()
Copyright © 2018. All rights reserved.