Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Page.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // Page.h
00004 //
00005 // Copyright 1996-2002 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef PAGE_H
00010 #define PAGE_H
00011 
00012 #ifdef __GNUC__
00013 #pragma interface
00014 #endif
00015 
00016 #include "Object.h"
00017 
00018 class Dict;
00019 class XRef;
00020 class OutputDev;
00021 class Links;
00022 class Catalog;
00023 
00024 //------------------------------------------------------------------------
00025 
00026 struct PDFRectangle {
00027   fouble x1, y1, x2, y2;
00028 };
00029 
00030 //------------------------------------------------------------------------
00031 // PageAttrs
00032 //------------------------------------------------------------------------
00033 
00034 class PageAttrs {
00035 public:
00036 
00037   // Construct a new PageAttrs object by merging a dictionary
00038   // (of type Pages or Page) into another PageAttrs object.  If
00039   // <attrs> is NULL, uses defaults.
00040   PageAttrs(PageAttrs *attrs, Dict *dict);
00041 
00042   // Destructor.
00043   ~PageAttrs();
00044 
00045   // Accessors.
00046   PDFRectangle *getBox() { return limitToCropBox ? &cropBox : &mediaBox; }
00047   PDFRectangle *getMediaBox() { return &mediaBox; }
00048   PDFRectangle *getCropBox() { return &cropBox; }
00049   GBool isCropped() { return haveCropBox; }
00050   PDFRectangle *getBleedBox() { return &bleedBox; }
00051   PDFRectangle *getTrimBox() { return &trimBox; }
00052   PDFRectangle *getArtBox() { return &artBox; }
00053   int getRotate() { return rotate; }
00054   GString *getLastModified()
00055     { return lastModified.isString()
00056         ? lastModified.getString() : (GString *)NULL; }
00057   Dict *getBoxColorInfo()
00058     { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }
00059   Dict *getGroup()
00060     { return group.isDict() ? group.getDict() : (Dict *)NULL; }
00061   Stream *getMetadata()
00062     { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }
00063   Dict *getPieceInfo()
00064     { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }
00065   Dict *getSeparationInfo()
00066     { return separationInfo.isDict()
00067         ? separationInfo.getDict() : (Dict *)NULL; }
00068   Dict *getResourceDict()
00069     { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }
00070 
00071 private:
00072 
00073   GBool readBox(Dict *dict, char *key, PDFRectangle *box);
00074 
00075   PDFRectangle mediaBox;
00076   PDFRectangle cropBox;
00077   GBool haveCropBox;
00078   GBool limitToCropBox;
00079   PDFRectangle bleedBox;
00080   PDFRectangle trimBox;
00081   PDFRectangle artBox;
00082   int rotate;
00083   Object lastModified;
00084   Object boxColorInfo;
00085   Object group;
00086   Object metadata;
00087   Object pieceInfo;
00088   Object separationInfo;
00089   Object resources;
00090 };
00091 
00092 //------------------------------------------------------------------------
00093 // Page
00094 //------------------------------------------------------------------------
00095 
00096 class Page {
00097 public:
00098 
00099   // Constructor.
00100   Page(XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA,
00101        GBool printCommandsA);
00102 
00103   // Destructor.
00104   ~Page();
00105 
00106   // Is page valid?
00107   GBool isOk() { return ok; }
00108 
00109   // Get page parameters.
00110   PDFRectangle *getBox() { return attrs->getBox(); }
00111   PDFRectangle *getMediaBox() { return attrs->getMediaBox(); }
00112   PDFRectangle *getCropBox() { return attrs->getCropBox(); }
00113   GBool isCropped() { return attrs->isCropped(); }
00114   fouble getWidth() { return attrs->getBox()->x2 - attrs->getBox()->x1; }
00115   fouble getHeight() { return attrs->getBox()->y2 - attrs->getBox()->y1; }
00116   PDFRectangle *getBleedBox() { return attrs->getBleedBox(); }
00117   PDFRectangle *getTrimBox() { return attrs->getTrimBox(); }
00118   PDFRectangle *getArtBox() { return attrs->getArtBox(); }
00119   int getRotate() { return attrs->getRotate(); }
00120   GString *getLastModified() { return attrs->getLastModified(); }
00121   Dict *getBoxColorInfo() { return attrs->getBoxColorInfo(); }
00122   Dict *getGroup() { return attrs->getGroup(); }
00123   Stream *getMetadata() { return attrs->getMetadata(); }
00124   Dict *getPieceInfo() { return attrs->getPieceInfo(); }
00125   Dict *getSeparationInfo() { return attrs->getSeparationInfo(); }
00126 
00127   // Get resource dictionary.
00128   Dict *getResourceDict() { return attrs->getResourceDict(); }
00129 
00130   // Get annotations array.
00131   Object *getAnnots(Object *obj) { return annots.fetch(xref, obj); }
00132 
00133   // Get contents.
00134   Object *getContents(Object *obj) { return contents.fetch(xref, obj); }
00135 
00136   // Display a page.
00137   void display(OutputDev *out, fouble dpi, int rotate,
00138                Links *links, Catalog *catalog);
00139 
00140 private:
00141 
00142   XRef *xref;                   // the xref table for this PDF file
00143   int num;                      // page number
00144   PageAttrs *attrs;             // page attributes
00145   Object annots;                // annotations array
00146   Object contents;              // page contents
00147   GBool printCommands;          // print the drawing commands (for debugging)
00148   GBool ok;                     // true if page is valid
00149 };
00150 
00151 #endif

Generated on Sat Nov 5 16:18:16 2005 for OPIE by  doxygen 1.4.2