KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > faceless > pdf > PDFReader


1 // $Id: PDFReader.java,v 1.4 2003/11/04 17:16:01 mike Exp $
2

3 package org.faceless.pdf;
4
5 import java.io.*;
6
7 /**
8  * <p>
9  * The <tt>PDFReader</tt> class adds the ability to load an existing PDF to the
10  * library. <b>Note that this class is part of the "Extended Edition" of the
11  * library</b> - although it's supplied with the package an "extended edition"
12  * license must be purchased to activate this class.
13  * </p><p>
14  * There are almost no public methods in this class - the only use for a
15  * <tt>PDFReader</tt> object is as a parameter the appropriate {@link PDF}
16  * constructor.
17  * </p><p>
18  * The one exception to this is the {link #getNumberOfRevisions} method, added
19  * in release 1.2.1. In order to explain this method it's necessary to go into
20  * a little detail about the file structure of a PDF document
21  * </p><p>
22  * A PDF file may sometimes contain different versions of itself in the one file.
23  * These "revisions" show how the state of the document has changed over time. For
24  * most purposes this information isn't terribly useful - prior to version 1.2.1
25  * only the latest revision was used - but they do play an important role when
26  * using Digital Signatures.
27  * </p><p>
28  * When a signature is applied to the file, the current revision is locked and
29  * any further changes to the file result in a new revision being made. With
30  * Adobe Acrobat several signatures can be applied, each one of which will result
31  * in a new revision.
32  * </p><p>
33  * It's important to remember that changes can be made a document <i>after</i>
34  * it's been signed, and provided that they're made in a new revision, the
35  * signature won't be invalidated - but the signature won't cover the whole
36  * of the document. When validating a signed document this needs to be taken
37  * into account
38  * </p><p>
39  * Another interesting feature of revisions is that with a document with multiple
40  * revisions, it's possible to "roll back" to a previous version. This is done by
41  * passing in a specific revision number to the {@link PDF#PDF(PDFReader,int)}
42  * constructor - the PDF will be created as it was at the specified revision.
43  * </p><p>
44  * Finally, although a PDF document containing multiple revisions can be read,
45  * when it's written out it will be "flattened" into a single revision.
46  * </p>
47  * @version $Revision: 1.4 $
48  */

49 public class PDFReader extends PeeredObject
50 {
51     final org.faceless.pdf2.PDFReader reader;
52
53     Object JavaDoc getPeer()
54     {
55         return reader;
56     }
57
58     /**
59      * Parse a PDF from the specified <tt>InputStream</tt>
60      * @param pdfstream the InputStream containing the PDF file to parse
61      */

62     public PDFReader(InputStream pdfstream)
63         throws IOException
64     {
65     reader = new org.faceless.pdf2.PDFReader(pdfstream);
66     }
67
68     /**
69      * Parse a PDF from the specified <tt>InputStream</tt>
70      * @param pdfstream the InputStream containing the PDF file to parse
71      * @param password the password required to open this document
72      */

73     public PDFReader(InputStream pdfstream, String JavaDoc password)
74         throws IOException
75     {
76     reader = new org.faceless.pdf2.PDFReader(pdfstream, password);
77     }
78
79     /**
80      * Parse a PDF from the specified file. This method reads the
81      * PDF directly from the disk, which is slower but uses less memory.
82      * @param file the PDF file to parse
83      */

84     public PDFReader(File file)
85         throws IOException
86     {
87     reader = new org.faceless.pdf2.PDFReader(file);
88     }
89
90     /**
91      * Parse a PDF from the specified file. This method reads the
92      * PDF directly from the disk, which is slower but uses less memory.
93      * @param file the PDF file to parse
94      * @param password the password required to open this document
95      */

96     public PDFReader(File file, String JavaDoc password)
97         throws IOException
98     {
99     reader = new org.faceless.pdf2.PDFReader(file, password);
100     }
101
102
103     /**
104      * Returns the number of revisions that have been made to this file. Earlier
105      * revisions of a PDF file can be loaded by passing a revision number between
106      * greater than or equal to zero and less than this value to the appropriate
107      * {@link PDF} constructor.
108      * @since 1.2.1
109      */

110     public int getNumberOfRevisions()
111     {
112         return reader.getNumberOfRevisions();
113     }
114
115     public void finalize() { reader.finalize(); }
116 }
117
Popular Tags