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