Package pdf
Class PDFStream
- java.lang.Object
-
- pdf.PDFObject
-
- pdf.PDFStream
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
PDFImage
public class PDFStream extends PDFObject implements java.io.Serializable
This class implements a PDF stream object. In PDF, streams contain data like the graphic operators that render a page, or the pixels of an image.In PDF, a stream can be compressed using several different methods, or left uncompressed. Here we support both uncompressed, and FlateDecode as it's supported by the java core.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class pdf.PDFObject
objser, pdfDocument
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetDeflate()Returs true if the stream will be compressed.java.io.OutputStreamgetOutputStream()Returns the OutputStream that will append to this stream.java.io.ByteArrayOutputStreamgetStream()This is for extenders, and provides access to the stream.java.io.PrintWritergetWriter()Creates a PrintWriter that will append to this stream.voidsetDeflate(boolean mode)voidwrite(java.io.OutputStream os)Writes the object to the output stream.voidwriteStream(java.io.OutputStream os)This inserts the Streams length, then the actual stream, finally the end of stream/object markers.-
Methods inherited from class pdf.PDFObject
getPDFDocument, getSerialID, getType, toArray, toString, writeEnd, writeStart
-
-
-
-
Constructor Detail
-
PDFStream
public PDFStream()
Constructs a plain stream.By default, the stream will be compressed.
-
PDFStream
public PDFStream(java.lang.String type)
Constructs a stream. The supplied type is stored in the stream's header and is used by other objects that extend the PDFStream class (like PDFImage).By default, the stream will be compressed.
- Parameters:
type- type for the stream- See Also:
PDFImage
-
-
Method Detail
-
setDeflate
public void setDeflate(boolean mode)
- Parameters:
mode- true will FlatDecode the stream
-
getDeflate
public boolean getDeflate()
Returs true if the stream will be compressed.- Returns:
- true if compression is enabled
-
getOutputStream
public java.io.OutputStream getOutputStream()
Returns the OutputStream that will append to this stream.- Returns:
- The stream for this object
-
getWriter
public java.io.PrintWriter getWriter()
Creates a PrintWriter that will append to this stream.- Returns:
- a PrintWriter to write to the stream
-
getStream
public java.io.ByteArrayOutputStream getStream()
This is for extenders, and provides access to the stream.- Returns:
- ByteArrayOutputStream containing the contents.
-
write
public void write(java.io.OutputStream os) throws java.io.IOExceptionDescription copied from class:PDFObjectWrites the object to the output stream. This method must be overidden.
Note: It should not write any other objects, even if they are it's Kids, as they will be written by the calling routine.
-
writeStream
public void writeStream(java.io.OutputStream os) throws java.io.IOExceptionThis inserts the Streams length, then the actual stream, finally the end of stream/object markers.This is intended for anyone extending PDFStream, as objects containing streams do no use writeEnd(), and they must be able to write the actual stream.
- Parameters:
os- OutputStream to send the object to- Throws:
java.io.IOException- on error
-
-