KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > etymon > pjx > util > PdfCatalog


1 package com.etymon.pjx.util;
2
3 //import java.io.*;
4
//import java.util.*;
5
import com.etymon.pjx.*;
6
7 /**
8    Provides methods related to a PDF document's catalog dictionary.
9    @author Nassib Nassar
10 */

11 public class PdfCatalog {
12
13     /**
14            A <code>PdfName</code> object representing the name
15            <code>Root</code>.
16     */

17     protected static final PdfName PDFNAME_ROOT = new PdfName("Root");
18
19     /**
20        The manager associated with this document.
21     */

22     protected PdfManager _m;
23
24     /**
25        Constructs a <code>PdfCatalog</code> instance based on a
26        specified <code>PdfManager</code>.
27      */

28     public PdfCatalog(PdfManager manager) {
29
30         _m = manager;
31         
32     }
33
34     /**
35        Retrieves an indirect reference to the document's catalog.
36        @return the indirect reference.
37        @throws PdfFormatException
38      */

39     public PdfReference getCatalog() throws PdfFormatException {
40         synchronized (this) {
41             synchronized (_m) {
42
43                 PdfDictionary trailer = _m.getTrailerDictionary();
44                 
45                 Object JavaDoc obj = trailer.getMap().get(PDFNAME_ROOT);
46                 
47                 if ( !(obj instanceof PdfReference) ) {
48                     throw new PdfFormatException("Catalog dictionary is not an indirect reference.");
49                 }
50                 
51                 return (PdfReference)obj;
52
53             }
54         }
55     }
56     
57 }
58
Popular Tags