00001
00002
00003
00004
00005
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
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
00043 GBool isOk() { return ok; }
00044
00045
00046 int getErrorCode() { return errCode; }
00047
00048
00049 GString *getFileName() { return fileName; }
00050
00051
00052 XRef *getXRef() { return xref; }
00053
00054
00055 Catalog *getCatalog() { return catalog; }
00056
00057
00058 BaseStream *getBaseStream() { return str; }
00059
00060
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
00069 int getNumPages() { return catalog->getNumPages(); }
00070
00071
00072
00073 GString *readMetadata() { return catalog->readMetadata(); }
00074
00075
00076 Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); }
00077
00078
00079 void displayPage(OutputDev *out, int page, fouble zoom,
00080 int rotate, GBool doLinks);
00081
00082
00083 void displayPages(OutputDev *out, int firstPage, int lastPage,
00084 int zoom, int rotate, GBool doLinks);
00085
00086
00087
00088 int findPage(int num, int gen) { return catalog->findPage(num, gen); }
00089
00090
00091
00092 LinkAction *findLink(fouble x, fouble y) { return links->find(x, y); }
00093
00094
00095 GBool onLink(fouble x, fouble y) { return links->onLink(x, y); }
00096
00097
00098
00099 LinkDest *findDest(GString *name)
00100 { return catalog->findDest(name); }
00101
00102
00103 GBool isEncrypted() { return xref->isEncrypted(); }
00104
00105
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
00116 GBool isLinearized();
00117
00118
00119 Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
00120
00121
00122 fouble getPDFVersion() { return pdfVersion; }
00123
00124
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