KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > jpdf > PDFCatalog


1 /*
2  * $Id: PDFCatalog.java,v 1.2 2001/11/16 15:26:04 ezb Exp $
3  *
4  * $Date: 2001/11/16 15:26:04 $
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21 package gnu.jpdf;
22
23 import java.io.*;
24
25 /**
26  * <p>This class implements the PDF Catalog,
27  * also known as the root node</p>
28  *
29  * @author Peter T. Mount
30  * @author Eric Z. Beard, ericzbeard@hotmail.com
31  * @author $Author: ezb $
32  * @version $Revision: 1.2 $, $Date: 2001/11/16 15:26:04 $
33  */

34 public class PDFCatalog extends PDFObject
35 {
36   /**
37    * The pages of the document
38    */

39   private PDFPageList pdfPageList;
40     
41   /**
42    * The outlines of the document
43    */

44   private PDFOutline outlines;
45   
46   /**
47    * The initial page mode
48    */

49   private int pagemode;
50   
51   /**
52    * This constructs a PDF Catalog object
53    *
54    * @param pdfPageList The PDFPageList object that's the root
55    * of the documents page tree
56    * @param pagemode How the document should appear when opened.
57    * Allowed values are USENONE, USEOUTLINES, USETHUMBS or FULLSCREEN.
58    */

59   public PDFCatalog(PDFPageList pdfPageList,int pagemode) {
60     super("/Catalog");
61     this.pdfPageList = pdfPageList;
62     this.pagemode = pagemode;
63   }
64   
65   /**
66    * This sets the root outline object
67    * @param outline The root outline
68    */

69   protected void setOutline(PDFOutline outline) {
70     this.outlines = outline;
71   }
72   
73   /**
74    * @param os OutputStream to send the object to
75    * @exception IOException on error
76    */

77   public void write(OutputStream os) throws IOException {
78     // Write the object header
79
writeStart(os);
80     
81     // now the objects body
82

83     // the /Pages object
84
os.write("/Pages ".getBytes());
85     os.write(pdfPageList.toString().getBytes());
86     os.write("\n".getBytes());
87             
88     // the Outlines object
89
if(outlines!=null) {
90       //if(outlines.getLast()>-1) {
91
os.write("/Outlines ".getBytes());
92       os.write(outlines.toString().getBytes());
93       os.write("\n".getBytes());
94       //}
95
}
96             
97     // the /PageMode setting
98
os.write("/PageMode ".getBytes());
99     os.write(PDFDocument.PDF_PAGE_MODES[pagemode].getBytes());
100     os.write("\n".getBytes());
101             
102     // finish off with its footer
103
writeEnd(os);
104   }
105 } // end class PDFCatalog
106

107
Popular Tags