1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
10 #pragma implementation
23 #include "OutputDev.h"
28 //------------------------------------------------------------------------
30 //------------------------------------------------------------------------
32 PDFDoc::PDFDoc(Stream *str1, GString *fileName1) {
43 if (!(str && str->isOk()))
48 /* str = new FileStream(file, 0, -1, &obj); */
51 /* str->checkHeader(); FIXME */
57 error(-1, "Couldn't read xref table");
62 catalog = new Catalog(xref->getCatalog(&catObj));
64 if (!catalog->isOk()) {
65 error(-1, "Couldn't read page catalog");
89 void PDFDoc::displayPage(OutputDev *out, int page, int zoom, int rotate,
92 double x1, y1, x2, y2;
97 printf("***** page %d *****\n", page);
98 catalog->getPage(page)->display(out, zoom, rotate);
103 for (i = 0; i < links->getNumLinks(); ++i) {
104 link = links->getLink(i);
105 link->getBorder(&x1, &y1, &x2, &y2, &w);
107 out->drawLinkBorder(x1, y1, x2, y2, w);
113 void PDFDoc::displayPages(OutputDev *out, int firstPage, int lastPage,
114 int zoom, int rotate) {
118 for (page = firstPage; page <= lastPage; ++page) {
120 printf("***** page %d *****\n", page);
121 p = catalog->getPage(page);
122 p->display(out, zoom, rotate);
126 GBool PDFDoc::saveAs(GString *name) {
131 if (!(f = fopen(name->getCString(), "wb"))) {
132 error(-1, "Couldn't open file '%s'", name->getCString());
136 while (str->getLine (buf, 4096))
142 void PDFDoc::getLinks(int page) {
145 links = new Links(catalog->getPage(page)->getAnnots(&obj),
146 catalog->getBaseURI());