1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
12 #ifdef USE_GCC_PRAGMAS
25 //------------------------------------------------------------------------
27 //------------------------------------------------------------------------
32 void init(XRef
*xref
, Object
*tree
);
33 void parse(Object
*tree
);
34 GBool
lookup(UGooString
*name
, Object
*obj
);
36 int numEntries() { return length
; };
38 Object
getValue(int i
);
39 UGooString
*getName(int i
);
43 Entry(Array
*array
, int index
);
48 static int cmp(const void *key
, const void *entry
);
51 void addEntry(Entry
*entry
);
56 int size
, length
; // size is the number of entries in
57 // the array of Entry*
58 // length is the number of real Entry
63 EmbFile(GooString
*name
, GooString
*description
,
64 GooString
*createDate
,
65 GooString
*modDate
, Object objStr
) :
67 m_description(description
),
68 m_createDate(createDate
),
71 objStr
.copy(&m_objStr
);
83 GooString
*name() { return m_name
; }
84 GooString
*description() { return m_description
; }
85 GooString
*modDate() { return m_modDate
; }
86 GooString
*createDate() { return m_createDate
; }
87 Object
&streamObject() { return m_objStr
; }
91 GooString
*m_description
;
92 GooString
*m_createDate
;
97 //------------------------------------------------------------------------
99 //------------------------------------------------------------------------
105 Catalog(XRef
*xrefA
);
111 GBool
isOk() { return ok
; }
113 // Get number of pages.
114 int getNumPages() { return numPages
; }
117 Page
*getPage(int i
) { return pages
[i
-1]; }
119 // Get the reference for a page object.
120 Ref
*getPageRef(int i
) { return &pageRefs
[i
-1]; }
122 // Return base URI, or NULL if none.
123 GooString
*getBaseURI() { return baseURI
; }
125 // Return the contents of the metadata stream, or NULL if there is
127 GooString
*readMetadata();
129 // Return the structure tree root object.
130 Object
*getStructTreeRoot() { return &structTreeRoot
; }
132 // Find a page, given its object ID. Returns page number, or 0 if
134 int findPage(int num
, int gen
);
136 // Find a named destination. Returns the link destination, or
137 // NULL if <name> is not a destination.
138 LinkDest
*findDest(UGooString
*name
);
140 // Get the number of embedded files
141 int numEmbeddedFiles() { return embeddedFileNameTree
.numEntries(); }
143 // Get the i'th file embedded (at the Document level) in the document
144 EmbFile
*embeddedFile(int i
);
146 // Convert between page indices and page labels.
147 GBool
labelToIndex(GooString
*label
, int *index
);
148 GBool
indexToLabel(int index
, GooString
*label
);
150 Object
*getOutline() { return &outline
; }
152 Object
*getAcroForm() { return &acroForm
; }
164 pageLayoutSinglePage
,
166 pageLayoutTwoColumnLeft
,
167 pageLayoutTwoColumnRight
,
168 pageLayoutTwoPageLeft
,
169 pageLayoutTwoPageRight
172 // Returns the page mode.
173 PageMode
getPageMode() { return pageMode
; }
174 PageLayout
getPageLayout() { return pageLayout
; }
178 XRef
*xref
; // the xref table for this PDF file
179 Page
**pages
; // array of pages
180 Ref
*pageRefs
; // object ID for each page
181 int numPages
; // number of pages
182 int pagesSize
; // size of pages array
183 Object dests
; // named destination dictionary
184 NameTree destNameTree
; // named destination name-tree
185 NameTree embeddedFileNameTree
; // embedded file name-tree
186 GooString
*baseURI
; // base URI for URI-type links
187 Object metadata
; // metadata stream
188 Object structTreeRoot
; // structure tree root dictionary
189 Object outline
; // outline dictionary
190 Object acroForm
; // AcroForm dictionary
191 GBool ok
; // true if catalog is valid
192 PageLabelInfo
*pageLabelInfo
; // info about page labels
193 PageMode pageMode
; // page mode
194 PageLayout pageLayout
; // page layout
196 int readPageTree(Dict
*pages
, PageAttrs
*attrs
, int start
, int callDepth
);
197 Object
*findDestInTree(Object
*tree
, GooString
*name
, Object
*obj
);