KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > jpdf > PDFPageList


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

22 package gnu.jpdf;
23
24 import java.io.*;
25 import java.util.*;
26
27 /**
28  * This object contains the document's pages.
29  *
30  * @author Peter T. Mount
31  * @author Eric Z. Beard, ericzbeard@hotmail.com
32  * @author $Author: ezb $
33  * @version $Revision: 1.1.1.1 $, $Date: 2001/10/29 19:51:08 $
34  */

35 public class PDFPageList extends PDFObject
36 {
37   
38   /**
39    * This holds the pages
40    */

41   private Vector pages;
42         
43   /**
44    * This constructs a PDF Pages object.
45    */

46   public PDFPageList() {
47     super("/Pages");
48     pages = new Vector();
49   }
50         
51   /**
52    * This adds a page to the document.
53    *
54    * @param page PDFPage to add
55    */

56   public void add(PDFPage page) {
57     pages.addElement(page);
58             
59     // Tell the page of ourselves
60
page.pdfPageList = this;
61   }
62         
63   /**
64    * This returns a specific page. Used by the PDF class.
65    * @param page page number to return
66    * @return PDFPage at that position
67    */

68   public PDFPage getPage(int page) {
69     return (PDFPage)(pages.elementAt(page));
70   }
71         
72   /**
73    * @param os OutputStream to send the object to
74    * @exception IOException on error
75    */

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

82     // the Kids array
83
os.write("/Kids ".getBytes());
84     os.write(PDFObject.toArray(pages).getBytes());
85     os.write("\n".getBytes());
86             
87     // the number of Kids in this document
88
os.write("/Count ".getBytes());
89     os.write(Integer.toString(pages.size()).getBytes());
90     os.write("\n".getBytes());
91             
92     // finish off with its footer
93
writeEnd(os);
94   }
95  
96 } // end class PDFPageList
97
Popular Tags