001: /*
002: * $Id: PDFCatalog.java,v 1.2 2001/11/16 15:26:04 ezb Exp $
003: *
004: * $Date: 2001/11/16 15:26:04 $
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: */
021: package gnu.jpdf;
022:
023: import java.io.*;
024:
025: /**
026: * <p>This class implements the PDF Catalog,
027: * also known as the root node</p>
028: *
029: * @author Peter T. Mount
030: * @author Eric Z. Beard, ericzbeard@hotmail.com
031: * @author $Author: ezb $
032: * @version $Revision: 1.2 $, $Date: 2001/11/16 15:26:04 $
033: */
034: public class PDFCatalog extends PDFObject {
035: /**
036: * The pages of the document
037: */
038: private PDFPageList pdfPageList;
039:
040: /**
041: * The outlines of the document
042: */
043: private PDFOutline outlines;
044:
045: /**
046: * The initial page mode
047: */
048: private int pagemode;
049:
050: /**
051: * This constructs a PDF Catalog object
052: *
053: * @param pdfPageList The PDFPageList object that's the root
054: * of the documents page tree
055: * @param pagemode How the document should appear when opened.
056: * Allowed values are USENONE, USEOUTLINES, USETHUMBS or FULLSCREEN.
057: */
058: public PDFCatalog(PDFPageList pdfPageList, int pagemode) {
059: super ("/Catalog");
060: this .pdfPageList = pdfPageList;
061: this .pagemode = pagemode;
062: }
063:
064: /**
065: * This sets the root outline object
066: * @param outline The root outline
067: */
068: protected void setOutline(PDFOutline outline) {
069: this .outlines = outline;
070: }
071:
072: /**
073: * @param os OutputStream to send the object to
074: * @exception IOException on error
075: */
076: public void write(OutputStream os) throws IOException {
077: // Write the object header
078: writeStart(os);
079:
080: // now the objects body
081:
082: // the /Pages object
083: os.write("/Pages ".getBytes());
084: os.write(pdfPageList.toString().getBytes());
085: os.write("\n".getBytes());
086:
087: // the Outlines object
088: if (outlines != null) {
089: //if(outlines.getLast()>-1) {
090: os.write("/Outlines ".getBytes());
091: os.write(outlines.toString().getBytes());
092: os.write("\n".getBytes());
093: //}
094: }
095:
096: // the /PageMode setting
097: os.write("/PageMode ".getBytes());
098: os.write(PDFDocument.PDF_PAGE_MODES[pagemode].getBytes());
099: os.write("\n".getBytes());
100:
101: // finish off with its footer
102: writeEnd(os);
103: }
104: } // end class PDFCatalog
|