1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
10 #pragma implementation
23 #include "OutputDev.h"
28 //------------------------------------------------------------------------
30 //------------------------------------------------------------------------
32 PDFDoc::PDFDoc(BaseFile file1, GString *fileName1) {
51 str = new FileStream(file, 0, -1, &obj);
60 error(-1, "Couldn't read xref table");
65 catalog = new Catalog(xref->getCatalog(&catObj));
67 if (!catalog->isOk()) {
68 error(-1, "Couldn't read page catalog");
90 void PDFDoc::displayPage(OutputDev *out, int page, int zoom, int rotate,
93 double x1, y1, x2, y2;
98 printf("***** page %d *****\n", page);
99 catalog->getPage(page)->display(out, zoom, rotate);
104 for (i = 0; i < links->getNumLinks(); ++i) {
105 link = links->getLink(i);
106 link->getBorder(&x1, &y1, &x2, &y2, &w);
108 out->drawLinkBorder(x1, y1, x2, y2, w);
114 void PDFDoc::displayPages(OutputDev *out, int firstPage, int lastPage,
115 int zoom, int rotate) {
119 for (page = firstPage; page <= lastPage; ++page) {
121 printf("***** page %d *****\n", page);
122 p = catalog->getPage(page);
123 p->display(out, zoom, rotate);
127 GBool PDFDoc::saveAs(GString *name) {
132 if (!(f = fopen(name->getCString(), "wb"))) {
133 error(-1, "Couldn't open file '%s'", name->getCString());
137 while ((n = bfread(buf, 1, sizeof(buf), file)) > 0)
138 fwrite(buf, 1, n, f);
143 void PDFDoc::getLinks(int page) {
146 links = new Links(catalog->getPage(page)->getAnnots(&obj),
147 catalog->getBaseURI());