public class PdfStream extends PdfDictionary
Modifier and Type | Field and Description |
---|---|
protected int |
compressionLevel |
protected PdfOutputStream |
outputStream |
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, UNENCRYPTED
Modifier | 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.
|
protected |
PdfStream(OutputStream outputStream) |
|
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'.
|
protected void |
copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Copies object content from object 'from'.
|
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) |
protected PdfObject |
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, copyTo, 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, clone, copyTo, copyTo, copyTo, copyTo, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, makeIndirect, release, setIndirectReference, setModified, setState
protected int compressionLevel
protected PdfOutputStream outputStream
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();
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)
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();
doc
- the pdf document
in which this stream lies
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()
protected PdfStream(OutputStream outputStream)
public PdfOutputStream getOutputStream()
public int getCompressionLevel()
DeflaterOutputStream
.
public void setCompressionLevel(int compressionLevel)
DeflaterOutputStream
.
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()
PdfName.DCTDecode
and PdfName.JPXDecode
filters will be ignored.
PdfStream
. Byte content will be null
, if the PdfStream
was created by InputStream
.
public byte[] getBytes(boolean decoded)
PdfName.DCTDecode
and PdfName.JPXDecode
filters will be ignored.
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. 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.
protected PdfObject newInstance()
PdfObject
newInstance
in class PdfDictionary
protected long getOffset()
protected void updateLength(int length)
length
- the new length
PdfReader.checkPdfStreamLength(PdfStream)
protected void copyContent(PdfObject from, PdfDocument document)
PdfDictionary
copyContent
in class PdfDictionary
from
- object to copy content from.
document
- document to copy object to.
protected void copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
PdfDictionary
copyContent
in class PdfDictionary
from
- object to copy content from.
document
- document to copy object to.
copyFilter
- ICopyFilter
a filter that will apply on dictionaries and array Use NullCopyFilter
for no filtering
protected void initOutputStream(OutputStream stream)
protected void releaseContent()
releaseContent
in class PdfDictionary
protected InputStream getInputStream()
Copyright © 1998–2022 iText Group NV. All rights reserved.