01: /*
02: * $Id: PDFPageList.java,v 1.1.1.1 2001/10/29 19:51:08 ezb Exp $
03: *
04: * $Date: 2001/10/29 19:51:08 $
05: *
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * 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: * This holds the pages
39: */
40: private Vector pages;
41:
42: /**
43: * This constructs a PDF Pages object.
44: */
45: public PDFPageList() {
46: super ("/Pages");
47: pages = new Vector();
48: }
49:
50: /**
51: * This adds a page to the document.
52: *
53: * @param page PDFPage to add
54: */
55: public void add(PDFPage page) {
56: pages.addElement(page);
57:
58: // Tell the page of ourselves
59: page.pdfPageList = this ;
60: }
61:
62: /**
63: * This returns a specific page. Used by the PDF class.
64: * @param page page number to return
65: * @return PDFPage at that position
66: */
67: public PDFPage getPage(int page) {
68: return (PDFPage) (pages.elementAt(page));
69: }
70:
71: /**
72: * @param os OutputStream to send the object to
73: * @exception IOException on error
74: */
75: public void write(OutputStream os) throws IOException {
76: // Write the object header
77: writeStart(os);
78:
79: // now the objects body
80:
81: // the Kids array
82: os.write("/Kids ".getBytes());
83: os.write(PDFObject.toArray(pages).getBytes());
84: os.write("\n".getBytes());
85:
86: // the number of Kids in this document
87: os.write("/Count ".getBytes());
88: os.write(Integer.toString(pages.size()).getBytes());
89: os.write("\n".getBytes());
90:
91: // finish off with its footer
92: writeEnd(os);
93: }
94:
95: } // end class PDFPageList
|