com.qoppa.pdf.source
Interface PDFContent


public interface PDFContent

Interface used to read PDF content. PDF content is read randomly and on demand, objects are located at arbitrary locations in a PDF file and we need to be able to read objects only when we need them. This interface provides method to read the contents from an arbitrary source (i.e. not a file).

Author:
Qoppa Software

Method Summary
 void append(byte[] addContent)
          Append content to this PDF.
 void close()
          Close or release any resources that this object holds.
 long length()
          Get the length of the content.
 int read(long position)
          Set the current position of the content and read the next byte.
 int read(long position, byte[] buffer, int offset, int len)
          Read the passed in number of bytes into a byte array.
 void setBytes(byte[] content, long position)
          Modifies some of the content in the PDF content.
 void writeContents(OutputStream outStream)
          Write the contents to an output stream.
 void writeContents(OutputStream outStream, long start, long length)
          Write a section of the content to an output stream.
 

Method Detail

read

int read(long position)
         throws IOException
Set the current position of the content and read the next byte.

Parameters:
position -
Returns:
The byte read from the content.
Throws:
IOException

read

int read(long position,
         byte[] buffer,
         int offset,
         int len)
         throws IOException
Read the passed in number of bytes into a byte array. The function should start reading from "position" in the content and should insert the bytes at the passed in offset into the byte array. If there are less than "len" bytes in the content, the method should read to the end of the content and return the number of bytes.read.

Parameters:
position - The location in the content at which to start reading.
buffer - The byte array into which to insert the read bytes.
offset - The offset in to the byte array at which to insert the read bytes.
len - The number of bytes to read.
Returns:
the number of bytes read.
Throws:
IOException

length

long length()
            throws IOException
Get the length of the content.

Returns:
The length of the content.
Throws:
IOException

writeContents

void writeContents(OutputStream outStream)
                   throws IOException
Write the contents to an output stream.

Parameters:
outStream -
Throws:
IOException

writeContents

void writeContents(OutputStream outStream,
                   long start,
                   long length)
                   throws IOException
Write a section of the content to an output stream.

Parameters:
outStream -
start -
length -
Throws:
IOException

setBytes

void setBytes(byte[] content,
              long position)
              throws IOException
Modifies some of the content in the PDF content.

Parameters:
content - The new content
position - The position at which to update the PDF content.
Throws:
IOException

append

void append(byte[] addContent)
            throws IOException
Append content to this PDF. This method is used when modifying a PDF by appending modified objects to the content.

Parameters:
addContent - The additional content.
Throws:
IOException

close

void close()
Close or release any resources that this object holds. This method is used when the PDF content will no longer be accessed. The intent is to proactively release any resources held by this object without waiting for finalization, such as open files or network connections.