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

PDFDoc.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // PDFDoc.h
00004 //
00005 // Copyright 1996-2002 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef PDFDOC_H
00010 #define PDFDOC_H
00011 
00012 #ifdef __GNUC__
00013 #pragma interface
00014 #endif
00015 
00016 #include <stdio.h>
00017 #include "XRef.h"
00018 #include "Link.h"
00019 #include "Catalog.h"
00020 #include "Page.h"
00021 
00022 class GString;
00023 class BaseStream;
00024 class OutputDev;
00025 class Links;
00026 class LinkAction;
00027 class LinkDest;
00028 
00029 //------------------------------------------------------------------------
00030 // PDFDoc
00031 //------------------------------------------------------------------------
00032 
00033 class PDFDoc {
00034 public:
00035 
00036   PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
00037          GString *userPassword = NULL, GBool printCommandsA = gFalse);
00038   PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
00039          GString *userPassword = NULL, GBool printCommandsA = gFalse);
00040   ~PDFDoc();
00041 
00042   // Was PDF document successfully opened?
00043   GBool isOk() { return ok; }
00044 
00045   // Get the error code (if isOk() returns false).
00046   int getErrorCode() { return errCode; }
00047 
00048   // Get file name.
00049   GString *getFileName() { return fileName; }
00050 
00051   // Get the xref table.
00052   XRef *getXRef() { return xref; }
00053 
00054   // Get catalog.
00055   Catalog *getCatalog() { return catalog; }
00056 
00057   // Get base stream.
00058   BaseStream *getBaseStream() { return str; }
00059 
00060   // Get page parameters.
00061   fouble getPageWidth(int page)
00062     { return catalog->getPage(page)->getWidth(); }
00063   fouble getPageHeight(int page)
00064     { return catalog->getPage(page)->getHeight(); }
00065   int getPageRotate(int page)
00066     { return catalog->getPage(page)->getRotate(); }
00067 
00068   // Get number of pages.
00069   int getNumPages() { return catalog->getNumPages(); }
00070 
00071   // Return the contents of the metadata stream, or NULL if there is
00072   // no metadata.
00073   GString *readMetadata() { return catalog->readMetadata(); }
00074 
00075   // Return the structure tree root object.
00076   Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
00077 
00078   // Display a page.
00079   void displayPage(OutputDev *out, int page, fouble zoom,
00080                    int rotate, GBool doLinks);
00081 
00082   // Display a range of pages.
00083   void displayPages(OutputDev *out, int firstPage, int lastPage,
00084                     int zoom, int rotate, GBool doLinks);
00085 
00086   // Find a page, given its object ID.  Returns page number, or 0 if
00087   // not found.
00088   int findPage(int num, int gen) { return catalog->findPage(num, gen); }
00089 
00090   // If point <x>,<y> is in a link, return the associated action;
00091   // else return NULL.
00092   LinkAction *findLink(fouble x, fouble y) { return links->find(x, y); }
00093 
00094   // Return true if <x>,<y> is in a link.
00095   GBool onLink(fouble x, fouble y) { return links->onLink(x, y); }
00096 
00097   // Find a named destination.  Returns the link destination, or
00098   // NULL if <name> is not a destination.
00099   LinkDest *findDest(GString *name)
00100     { return catalog->findDest(name); }
00101 
00102   // Is the file encrypted?
00103   GBool isEncrypted() { return xref->isEncrypted(); }
00104 
00105   // Check various permissions.
00106   GBool okToPrint(GBool ignoreOwnerPW = gFalse)
00107     { return xref->okToPrint(ignoreOwnerPW); }
00108   GBool okToChange(GBool ignoreOwnerPW = gFalse)
00109     { return xref->okToChange(ignoreOwnerPW); }
00110   GBool okToCopy(GBool ignoreOwnerPW = gFalse)
00111     { return xref->okToCopy(ignoreOwnerPW); }
00112   GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
00113     { return xref->okToAddNotes(ignoreOwnerPW); }
00114 
00115   // Is this document linearized?
00116   GBool isLinearized();
00117 
00118   // Return the document's Info dictionary (if any).
00119   Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
00120 
00121   // Return the PDF version specified by the file.
00122   fouble getPDFVersion() { return pdfVersion; }
00123 
00124   // Save this file with another name.
00125   GBool saveAs(GString *name);
00126 
00127 private:
00128 
00129   GBool setup(GString *ownerPassword, GString *userPassword);
00130   void checkHeader();
00131   void getLinks(Page *page);
00132 
00133   GString *fileName;
00134   FILE *file;
00135   BaseStream *str;
00136   fouble pdfVersion;
00137   XRef *xref;
00138   Catalog *catalog;
00139   Links *links;
00140   GBool printCommands;
00141 
00142   GBool ok;
00143   int errCode;
00144 };
00145 
00146 #endif

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