01: package com.etymon.pjx.util;
02:
03: //import java.io.*;
04: //import java.util.*;
05: import com.etymon.pjx.*;
06:
07: /**
08: Provides methods related to a PDF document's catalog dictionary.
09: @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 obj = trailer.getMap().get(PDFNAME_ROOT);
46:
47: if (!(obj instanceof PdfReference)) {
48: throw new PdfFormatException(
49: "Catalog dictionary is not an indirect reference.");
50: }
51:
52: return (PdfReference) obj;
53:
54: }
55: }
56: }
57:
58: }
|