org.faceless.pdf2
Class PDFReader

java.lang.Object
  extended by org.faceless.pdf2.PDFReader

public final class PDFReader
extends Object

The PDFReader class adds the ability to load an existing PDF to the library. Note that this class is part of the "Extended Edition" of the library - although it's supplied with the package an "extended edition" license must be purchased to activate this class.

There are almost no public methods in this class - the only use for a PDFReader object is as a parameter the appropriate PDF.PDF(PDFReader) constructor.

The one exception to this is the getNumberOfRevisions() method, added in release 1.2.1. In order to explain this method it's necessary to go into a little detail about the file structure of a PDF document.

A PDF file may sometimes contain different versions of itself in the one file. These "revisions" show how the state of the document has changed over time. For most purposes this information isn't terribly useful - prior to version 1.2.1 only the latest revision was used - but they do play an important role when using Digital Signatures.

When a signature is applied to the file, the current revision is locked and any further changes to the file result in a new revision being made. With Adobe Acrobat several signatures can be applied, each one of which will result in a new revision.

It's important to remember that changes can be made a document after it's been signed, and provided that they're made in a new revision, the signature won't be invalidated - but the signature won't cover the whole of the document either. When validating a signed document this needs to be taken into account

Another interesting feature of revisions is that with a document with multiple revisions, it's possible to "roll back" to a previous version. This is done by passing in a specific revision number to the PDF.PDF(PDFReader,int) constructor - the PDF will be created as it was at the specified revision.

Parallel Operation note: Since 2.10 this class will use multiple threads in parallel where possible. The number of threads defaults to the available processors but can be controlled by setting the Threads property (typically by setting the org.faceless.pdf2.Threads System property) to the number of threads required. Each thread requires only minimal heap so it's safe to run as many as you like.

Since:
1.1.12

Constructor Summary
PDFReader(File in)
          Read an unencrypted PDF from the specified file.
PDFReader(File in, EncryptionHandler encrypt)
          Read an encrypted PDF from the specified File.
PDFReader(File in, EncryptionHandler[] encryptlist, float[] progress)
          Read a PDF from the specified InputStream.
PDFReader(File in, EncryptionHandler encrypt, float[] progress)
          Read a PDF from the specified InputStream.
PDFReader(File in, String password)
          Read an encrypted PDF from the specified File.
PDFReader(InputStream in)
          Read an encrypted PDF from the specified InputStream.
PDFReader(InputStream in, EncryptionHandler encrypt)
          Read an encrypted PDF from the specified InputStream.
PDFReader(InputStream in, EncryptionHandler[] encryptlist, float[] progress)
          Read a PDF from the specified InputStream.
PDFReader(InputStream in, EncryptionHandler encrypt, float[] progress)
          Read a PDF from the specified InputStream.
PDFReader(InputStream in, String password)
          Read an encrypted PDF from the specified InputStream.
 
Method Summary
 int getNumberOfRevisions()
           Return the number of revisions that have been made to this file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PDFReader

public PDFReader(File in)
          throws IOException
Read an unencrypted PDF from the specified file. This constructor requires less memory than than the PDFReader(InputStream) constructor, but takes slightly longer to run.

Parameters:
in - the File to read from
Throws:
IOException

PDFReader

public PDFReader(File in,
                 String password)
          throws IOException
Read an encrypted PDF from the specified File. The PDF is encrypted using the StandardEncryptionHandler and the specified password. This constructor is identical to calling new PDFReader(in, new StandardEncryptionHandler(password)), and it requires less memory than than the PDFReader(InputStream,String) constructor, but takes slightly longer to run.

Parameters:
in - the File to read from
password - the password needed to open the file
Throws:
IOException

PDFReader

public PDFReader(InputStream in)
          throws IOException
Read an encrypted PDF from the specified InputStream. The InputStream is not closed by this method, but should be closed by the user

Parameters:
in - the stream to read from
Throws:
IOException

PDFReader

public PDFReader(InputStream in,
                 String password)
          throws IOException
Read an encrypted PDF from the specified InputStream. The PDF is encrypted using the StandardEncryptionHandler and the specified password. This method is identical to calling new PDFReader(in, new StandardEncryptionHandler(password)). Please note the InputStream is not closed by this method, but should be closed by the user

Parameters:
in - the stream to read from
password - the password needed to open the file
Throws:
IOException

PDFReader

public PDFReader(InputStream in,
                 EncryptionHandler encrypt)
          throws IOException
Read an encrypted PDF from the specified InputStream. This constructor allows for a non-standard EncryptionHandler to be used to read the document. Please note the InputStream is not closed by this method, but should be closed by the user

Parameters:
in - the stream to read from
encrypt - the EncryptionHandler to use to decrypt the document, or null if no encryption handler is required
Throws:
IOException
Since:
2.0

PDFReader

public PDFReader(File in,
                 EncryptionHandler encrypt)
          throws IOException
Read an encrypted PDF from the specified File. This constructor allows for a non-standard EncryptionHandler to be used to read the document. It also uses less memory than the PDFReader(File, EncryptionHandler) constructor.

Parameters:
in - the stream to read from
encrypt - the EncryptionHandler to use to decrypt the document, or null if no encryption handler is required
Throws:
IOException
Since:
2.2.5

PDFReader

public PDFReader(InputStream in,
                 EncryptionHandler encrypt,
                 float[] progress)
          throws IOException
Read a PDF from the specified InputStream. The progress field is updated throughout the read with values from 0 to 1 indicating how much of the PDF has been read.

Parameters:
in - the stream to read from
encrypt - the EncryptionHandler to decrypt the PDF, or null if the PDF is unencrypted
progress - an optional array one item long, the first parameter of which will by updated throughout the read
Throws:
IOException
Since:
2.8

PDFReader

public PDFReader(File in,
                 EncryptionHandler encrypt,
                 float[] progress)
          throws IOException
Read a PDF from the specified InputStream. The progress field is updated throughout the read with values from 0 to 1 indicating how much of the PDF has been read.

Parameters:
in - the File to read from
encrypt - the EncryptionHandler to decrypt the PDF, or null if the PDF is unencrypted
progress - an optional array one item long, the first parameter of which will by updated throughout the read
Throws:
IOException
Since:
2.8

PDFReader

public PDFReader(InputStream in,
                 EncryptionHandler[] encryptlist,
                 float[] progress)
          throws IOException
Read a PDF from the specified InputStream. The progress field is updated throughout the read with values from 0 to 1 indicating how much of the PDF has been read.

Parameters:
in - the stream to read from
encryptlist - the list of EncryptionHandlers to use to try and decrypt the PDF.
progress - an optional array one item long, the first parameter of which will by updated throughout the read
Throws:
IOException
Since:
2.8.2

PDFReader

public PDFReader(File in,
                 EncryptionHandler[] encryptlist,
                 float[] progress)
          throws IOException
Read a PDF from the specified InputStream. The progress field is updated throughout the read with values from 0 to 1 indicating how much of the PDF has been read.

Parameters:
in - the File to read from
encryptlist - the list of EncryptionHandlers to use to try and decrypt the PDF.
progress - an optional array one item long, the first parameter of which will by updated throughout the read
Throws:
IOException
Since:
2.8.2
Method Detail

getNumberOfRevisions

public int getNumberOfRevisions()

Return the number of revisions that have been made to this file. Earlier revisions of a PDF file can be loaded by passing a revision number less than this value to the appropriate PDF.PDF(PDFReader,int) constructor.

This method was modified slightly in release 2.7 so that the original file now counts as a revision - in other words, this method always returns at least "1".

Since:
1.2.1


Copyright © 2001-2012 Big Faceless Organization