public class PdfStream extends PdfDictionary
Modifier and Type | Field and Description |
---|---|
protected int |
compressionLevel |
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING
Constructor and Description |
---|
PdfStream()
Creates an empty PdfStream instance.
|
PdfStream(byte[] bytes)
Creates a PdfStream instance.
|
PdfStream(byte[] bytes, int compressionLevel)
Constructs a PdfStream -object.
|
PdfStream(int compressionLevel)
Constructs a PdfStream -object.
|
PdfStream(PdfDocument doc, InputStream inputStream)
Creates an efficient stream.
|
PdfStream(PdfDocument doc, InputStream inputStream, int compressionLevel)
Creates an efficient stream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
copyContent(PdfObject from, PdfDocument document)
Copies object content from object 'from'.
|
PdfStream |
copyTo(PdfDocument document)
Copies object to a specified document.
|
PdfStream |
copyTo(PdfDocument document, boolean allowDuplicating)
Copies object to a specified document.
|
byte[] |
getBytes()
Gets decoded stream bytes.
|
byte[] |
getBytes(boolean decoded)
Gets stream bytes.
|
int |
getCompressionLevel()
Gets compression level of this PdfStream.
|
protected InputStream |
getInputStream() |
int |
getLength() |
protected long |
getOffset() |
PdfOutputStream |
getOutputStream()
Gets output stream.
|
byte |
getType()
Gets object type.
|
protected void |
initOutputStream(OutputStream stream) |
PdfStream |
makeIndirect(PdfDocument document)
Marks object to be saved as indirect.
|
PdfStream |
makeIndirect(PdfDocument document, PdfIndirectReference reference)
Marks object to be saved as indirect.
|
protected PdfStream |
newInstance()
Creates new instance of object.
|
protected void |
releaseContent()
Release content of PdfStream.
|
void |
setCompressionLevel(int compressionLevel)
Sets compression level of this PdfStream.
|
void |
setData(byte[] bytes)
Sets bytes as stream's content.
|
void |
setData(byte[] bytes, boolean append)
Sets or appends bytes to stream content.
|
protected void |
updateLength(int length)
Update length manually in case its correction.
|
clear, clone, containsKey, containsValue, copyTo, directEntrySet, directValues, entrySet, get, get, getAsArray, getAsBool, getAsBoolean, getAsDictionary, getAsFloat, getAsInt, getAsName, getAsNumber, getAsRectangle, getAsStream, getAsString, isEmpty, keySet, mergeDifferent, put, putAll, remove, size, toString, values, values
checkState, clearState, clone, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isStream, isString, release, setIndirectReference, setModified, setState
public PdfStream(byte[] bytes, int compressionLevel)
PdfStream
-object.
bytes
- initial content of PdfOutputStream
.
compressionLevel
- the compression level (0 = best speed, 9 = best compression, -1 is default)
public PdfStream(byte[] bytes)
bytes
- bytes to write to the PdfStream
public PdfStream(PdfDocument doc, InputStream inputStream, int compressionLevel)
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();
inputStream
- the data to write to this stream
compressionLevel
- the compression level (0 = best speed, 9 = best compression, -1 is default)
public PdfStream(PdfDocument doc, InputStream inputStream)
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();
inputStream
- the data to write to this stream
public PdfStream(int compressionLevel)
PdfStream
-object.
compressionLevel
- the compression level (0 = best speed, 9 = best compression, -1 is default)
public PdfStream()
public PdfOutputStream getOutputStream()
public int getCompressionLevel()
Deflater
.
public void setCompressionLevel(int compressionLevel)
Deflater
.
compressionLevel
- the compression level (0 = best speed, 9 = best compression, -1 is default)
public byte getType()
PdfObject
getType
in class PdfDictionary
public int getLength()
public byte[] getBytes()
public byte[] getBytes(boolean decoded)
decoded
- true if to get decoded stream bytes, otherwise false.
PdfStream
. Byte content will be null
, if the PdfStream
was created by InputStream
.
public void setData(byte[] bytes)
bytes
as stream's content. Could not be used with streams which were created by InputStream
.
bytes
- new content for stream; if null
then stream's content will be discarded
public void setData(byte[] bytes, boolean append)
bytes
to stream content. Could not be used with streams which were created by InputStream
.
bytes
- new content for stream; 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
public PdfStream makeIndirect(PdfDocument document)
makeIndirect
in class PdfDictionary
document
- a document the indirect reference will belong to.
public PdfStream makeIndirect(PdfDocument document, PdfIndirectReference reference)
makeIndirect
in class PdfDictionary
document
- a document the indirect reference will belong to.
public PdfStream copyTo(PdfDocument document)
copyTo
in class PdfDictionary
document
- document to copy object to.
public PdfStream copyTo(PdfDocument document, boolean allowDuplicating)
copyTo
in class PdfDictionary
document
- document to copy object to.
allowDuplicating
- indicates if to allow copy objects which already have been copied. If object is associated with any indirect reference and allowDuplicating is false then already existing reference will be returned instead of copying object. If allowDuplicating is true then object will be copied and new indirect reference will be assigned.
protected PdfStream newInstance()
PdfObject
newInstance
in class PdfDictionary
protected long getOffset()
protected void updateLength(int length)
PdfReader.checkPdfStreamLength()
method.
protected void copyContent(PdfObject from, PdfDocument document)
PdfObject
copyContent
in class PdfDictionary
from
- object to copy content from.
document
- document to copy object to.
protected void initOutputStream(OutputStream stream)
protected void releaseContent()
releaseContent
in class PdfDictionary
protected InputStream getInputStream()
Copyright © 1998–2016 iText Group NV. All rights reserved.