00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef PDFDOC_H
00010 #define PDFDOC_H
00011
00012 #include <aconf.h>
00013
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017
00018 #include <stdio.h>
00019 #include "XRef.h"
00020 #include "Link.h"
00021 #include "Catalog.h"
00022 #include "Page.h"
00023
00024 class GString;
00025 class BaseStream;
00026 class OutputDev;
00027 class Links;
00028 class LinkAction;
00029 class LinkDest;
00030 class Outline;
00031
00032
00033
00034
00035
00036 class PDFDoc {
00037 public:
00038
00039 PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
00040 GString *userPassword = NULL);
00041 PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
00042 GString *userPassword = NULL);
00043 ~PDFDoc();
00044
00045
00046 GBool isOk() { return ok; }
00047
00048
00049 int getErrorCode() { return errCode; }
00050
00051
00052 GString *getFileName() { return fileName; }
00053
00054
00055 XRef *getXRef() { return xref; }
00056
00057
00058 Catalog *getCatalog() { return catalog; }
00059
00060
00061 BaseStream *getBaseStream() { return str; }
00062
00063
00064 double getPageWidth(int page)
00065 { return catalog->getPage(page)->getWidth(); }
00066 double getPageHeight(int page)
00067 { return catalog->getPage(page)->getHeight(); }
00068 int getPageRotate(int page)
00069 { return catalog->getPage(page)->getRotate(); }
00070
00071
00072 int getNumPages() { return catalog->getNumPages(); }
00073
00074
00075
00076 GString *readMetadata() { return catalog->readMetadata(); }
00077
00078
00079 Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
00080
00081
00082 void displayPage(OutputDev *out, int page, double hDPI, double vDPI,
00083 int rotate, GBool crop, GBool doLinks,
00084 GBool (*abortCheckCbk)(void *data) = NULL,
00085 void *abortCheckCbkData = NULL);
00086
00087
00088 void displayPages(OutputDev *out, int firstPage, int lastPage,
00089 double hDPI, double vDPI, int rotate,
00090 GBool crop, GBool doLinks,
00091 GBool (*abortCheckCbk)(void *data) = NULL,
00092 void *abortCheckCbkData = NULL);
00093
00094
00095 void displayPageSlice(OutputDev *out, int page,
00096 double hDPI, double vDPI,
00097 int rotate, GBool crop,
00098 int sliceX, int sliceY, int sliceW, int sliceH,
00099 GBool (*abortCheckCbk)(void *data) = NULL,
00100 void *abortCheckCbkData = NULL);
00101
00102
00103
00104 int findPage(int num, int gen) { return catalog->findPage(num, gen); }
00105
00106
00107
00108 LinkAction *findLink(double x, double y)
00109 { return links ? links->find(x, y) : (LinkAction *)NULL; }
00110
00111
00112 GBool onLink(double x, double y) { return links->onLink(x, y); }
00113
00114
00115
00116 LinkDest *findDest(GString *name)
00117 { return catalog->findDest(name); }
00118
00119 #ifndef DISABLE_OUTLINE
00120
00121 Outline *getOutline() { return outline; }
00122 #endif
00123
00124
00125 GBool isEncrypted() { return xref->isEncrypted(); }
00126
00127
00128 GBool okToPrint(GBool ignoreOwnerPW = gFalse)
00129 { return xref->okToPrint(ignoreOwnerPW); }
00130 GBool okToChange(GBool ignoreOwnerPW = gFalse)
00131 { return xref->okToChange(ignoreOwnerPW); }
00132 GBool okToCopy(GBool ignoreOwnerPW = gFalse)
00133 { return xref->okToCopy(ignoreOwnerPW); }
00134 GBool okToAddNotes(GBool ignoreOwnerPW = gFalse)
00135 { return xref->okToAddNotes(ignoreOwnerPW); }
00136
00137
00138 GBool isLinearized();
00139
00140
00141 Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
00142 Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
00143
00144
00145 double getPDFVersion() { return pdfVersion; }
00146
00147
00148 GBool saveAs(GString *name);
00149
00150
00151 private:
00152
00153 GBool setup(GString *ownerPassword, GString *userPassword);
00154 void checkHeader();
00155 void getLinks(Page *page);
00156
00157 GString *fileName;
00158 FILE *file;
00159 BaseStream *str;
00160 double pdfVersion;
00161 XRef *xref;
00162 Catalog *catalog;
00163 Links *links;
00164 #ifndef DISABLE_OUTLINE
00165 Outline *outline;
00166 #endif
00167
00168
00169 GBool ok;
00170 int errCode;
00171 };
00172
00173 #endif