]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/PDFDoc.h
e679db9795edec920d234882c4ce902da48b732f
[thirdparty/cups.git] / pdftops / PDFDoc.h
1 //========================================================================
2 //
3 // PDFDoc.h
4 //
5 // Copyright 1996 Derek B. Noonburg
6 //
7 //========================================================================
8
9 #ifndef PDFDOC_H
10 #define PDFDOC_H
11
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
15
16 #include <stdio.h>
17 #include "Link.h"
18 #include "Catalog.h"
19 #include "Page.h"
20
21 class GString;
22 class BaseStream;
23 class XRef;
24 class OutputDev;
25 class Links;
26 class LinkAction;
27 class LinkDest;
28
29 //------------------------------------------------------------------------
30 // PDFDoc
31 //------------------------------------------------------------------------
32
33 class PDFDoc {
34 public:
35
36 PDFDoc(GString *fileName1, GString *userPassword = NULL);
37 PDFDoc(BaseStream *str, GString *userPassword = NULL);
38 ~PDFDoc();
39
40 // Was PDF document successfully opened?
41 GBool isOk() { return ok; }
42
43 // Get file name.
44 GString *getFileName() { return fileName; }
45
46 // Get catalog.
47 Catalog *getCatalog() { return catalog; }
48
49 // Get base stream.
50 BaseStream *getBaseStream() { return str; }
51
52 // Get page parameters.
53 double getPageWidth(int page)
54 { return catalog->getPage(page)->getWidth(); }
55 double getPageHeight(int page)
56 { return catalog->getPage(page)->getHeight(); }
57 int getPageRotate(int page)
58 { return catalog->getPage(page)->getRotate(); }
59
60 // Get number of pages.
61 int getNumPages() { return catalog->getNumPages(); }
62
63 // Display a page.
64 void displayPage(OutputDev *out, int page, double zoom,
65 int rotate, GBool doLinks);
66
67 // Display a range of pages.
68 void displayPages(OutputDev *out, int firstPage, int lastPage,
69 int zoom, int rotate, GBool doLinks);
70
71 // Find a page, given its object ID. Returns page number, or 0 if
72 // not found.
73 int findPage(int num, int gen) { return catalog->findPage(num, gen); }
74
75 // If point <x>,<y> is in a link, return the associated action;
76 // else return NULL.
77 LinkAction *findLink(double x, double y) { return links->find(x, y); }
78
79 // Return true if <x>,<y> is in a link.
80 GBool onLink(double x, double y) { return links->onLink(x, y); }
81
82 // Find a named destination. Returns the link destination, or
83 // NULL if <name> is not a destination.
84 LinkDest *findDest(GString *name)
85 { return catalog->findDest(name); }
86
87 // Is the file encrypted?
88 GBool isEncrypted() { return xref->isEncrypted(); }
89
90 // Check various permissions.
91 GBool okToPrint() { return xref->okToPrint(); }
92 GBool okToChange() { return xref->okToChange(); }
93 GBool okToCopy() { return xref->okToCopy(); }
94 GBool okToAddNotes() { return xref->okToAddNotes(); }
95
96 // Is this document linearized?
97 GBool isLinearized();
98
99 // Return the document's Info dictionary (if any).
100 Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
101
102 // Return the PDF version specified by the file.
103 double getPDFVersion() { return pdfVersion; }
104
105 // Save this file with another name.
106 GBool saveAs(GString *name);
107
108 private:
109
110 GBool setup(GString *userPassword);
111 void checkHeader();
112 void getLinks(Page *page);
113
114 GString *fileName;
115 FILE *file;
116 BaseStream *str;
117 double pdfVersion;
118 XRef *xref;
119 Catalog *catalog;
120 Links *links;
121
122 GBool ok;
123 };
124
125 #endif