Package org.apache.fop.pdf
Class PDFStream
- java.lang.Object
-
- org.apache.fop.pdf.PDFObject
-
- org.apache.fop.pdf.AbstractPDFStream
-
- org.apache.fop.pdf.PDFStream
-
- All Implemented Interfaces:
PDFWritable
- Direct Known Subclasses:
ObjectStream
,PDFCMap
,PDFEmbeddedFile
,PDFICCStream
,PDFLinearization.HintTable
,PDFMetadata
public class PDFStream extends AbstractPDFStream
Class representing a PDF stream.A derivative of the PDF Object, a PDF Stream has not only a dictionary but a stream of PDF commands. The stream of commands is where the real work is done, the dictionary just provides information like the stream length.
-
-
Field Summary
Fields Modifier and Type Field Description private char[]
charBuffer
protected StreamCache
data
The stream of PDF commandsprivate java.io.Writer
streamWriter
-
Constructor Summary
Constructors Constructor Description PDFStream()
Create an empty stream objectPDFStream(boolean encodeOnTheFly)
PDFStream(PDFDictionary dictionary)
PDFStream(PDFDictionary dictionary, boolean encodeOnTheFly)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String s)
Append data to the streamvoid
add(java.lang.StringBuffer sb)
Append data to the streamprivate void
flush()
java.io.OutputStream
getBufferOutputStream()
Returns an OutputStream that can be used to write to the buffer which is used to build up the PDF stream.java.io.Writer
getBufferWriter()
Returns a Writer that writes to the OutputStream of the buffer.int
getDataLength()
Returns the size of the content.protected int
getSizeHint()
Returns a value that hints at the size of the encoded stream.int
output(java.io.OutputStream stream)
Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this objectprotected void
outputRawStreamData(java.io.OutputStream out)
Sends the raw stream data to the target OutputStream.void
setData(byte[] data)
Used to set the contents of the PDF stream.private void
setUp()
java.lang.String
streamHashCode()
-
Methods inherited from class org.apache.fop.pdf.AbstractPDFStream
encodeAndWriteStream, encodeStream, get, getChildren, getDefaultFilterName, getDictionary, getFilterList, multipleFiltersAllowed, outputStreamData, populateStreamDict, prepareImplicitFilters, put, registerChildren, setDocument, setupFilterList
-
Methods inherited from class org.apache.fop.pdf.PDFObject
contentEquals, encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, outputInline, referencePDF, setObjectNumber, setObjectNumber, setObjectNumber, setParent, toPDF, toPDFString
-
-
-
-
Field Detail
-
data
protected StreamCache data
The stream of PDF commands
-
streamWriter
private transient java.io.Writer streamWriter
-
charBuffer
private transient char[] charBuffer
-
-
Constructor Detail
-
PDFStream
public PDFStream()
Create an empty stream object
-
PDFStream
public PDFStream(PDFDictionary dictionary)
-
PDFStream
public PDFStream(PDFDictionary dictionary, boolean encodeOnTheFly)
-
PDFStream
public PDFStream(boolean encodeOnTheFly)
-
-
Method Detail
-
setUp
private void setUp()
-
add
public void add(java.lang.String s)
Append data to the stream- Parameters:
s
- the string of PDF to add
-
add
public void add(java.lang.StringBuffer sb)
Append data to the stream- Parameters:
sb
- the string buffer of PDF to add
-
flush
private void flush() throws java.io.IOException
- Throws:
java.io.IOException
-
getBufferWriter
public java.io.Writer getBufferWriter()
Returns a Writer that writes to the OutputStream of the buffer.- Returns:
- the Writer
-
getBufferOutputStream
public java.io.OutputStream getBufferOutputStream() throws java.io.IOException
Returns an OutputStream that can be used to write to the buffer which is used to build up the PDF stream.- Returns:
- the OutputStream
- Throws:
java.io.IOException
- In case of an I/O problem
-
setData
public void setData(byte[] data) throws java.io.IOException
Used to set the contents of the PDF stream.- Parameters:
data
- the contents as a byte array- Throws:
java.io.IOException
- in case of an I/O problem
-
getDataLength
public int getDataLength()
Returns the size of the content.- Returns:
- size of the content
-
getSizeHint
protected int getSizeHint() throws java.io.IOException
Returns a value that hints at the size of the encoded stream. This is used to optimize buffer allocation so fewer buffer reallocations are necessary.- Specified by:
getSizeHint
in classAbstractPDFStream
- Returns:
- an estimated size (0 if no hint can be given)
- Throws:
java.io.IOException
- in case of an I/O problem
-
outputRawStreamData
protected void outputRawStreamData(java.io.OutputStream out) throws java.io.IOException
Sends the raw stream data to the target OutputStream.- Specified by:
outputRawStreamData
in classAbstractPDFStream
- Parameters:
out
- OutputStream to write to- Throws:
java.io.IOException
- In case of an I/O problem
-
output
public int output(java.io.OutputStream stream) throws java.io.IOException
Overload the base object method so we don't have to copy byte arrays around so much Write the PDF represention of this object- Overrides:
output
in classAbstractPDFStream
- Parameters:
stream
- the stream to write the PDF to- Returns:
- the number of bytes written
- Throws:
java.io.IOException
- if there is an error writing to the stream
-
streamHashCode
public java.lang.String streamHashCode() throws java.io.IOException
- Throws:
java.io.IOException
-
-