From 98a1e3f36567639344f12932b629e526a8783aa8 Mon Sep 17 00:00:00 2001 From: sandman Date: Sat, 13 Apr 2002 00:47:20 +0000 Subject: CVS import of QPdf --- (limited to 'noncore/unsupported/qpdf/xpdf/PDFDoc.h') diff --git a/noncore/unsupported/qpdf/xpdf/PDFDoc.h b/noncore/unsupported/qpdf/xpdf/PDFDoc.h new file mode 100644 index 0000000..592095e --- a/dev/null +++ b/noncore/unsupported/qpdf/xpdf/PDFDoc.h @@ -0,0 +1,142 @@ +//======================================================================== +// +// PDFDoc.h +// +// Copyright 1996 Derek B. Noonburg +// +//======================================================================== + +#ifndef PDFDOC_H +#define PDFDOC_H + +#ifdef __GNUC__ +#pragma interface +#endif + +#include +#include "XRef.h" +#include "Link.h" +#include "Catalog.h" +#include "Page.h" + +class GString; +class BaseStream; +class OutputDev; +class Links; +class LinkAction; +class LinkDest; + +//------------------------------------------------------------------------ +// PDFDoc +//------------------------------------------------------------------------ + +class PDFDoc { +public: + + PDFDoc(GString *fileNameA, GString *ownerPassword = NULL, + GString *userPassword = NULL, GBool printCommandsA = gFalse); + PDFDoc(BaseStream *strA, GString *ownerPassword = NULL, + GString *userPassword = NULL, GBool printCommandsA = gFalse); + ~PDFDoc(); + + // Was PDF document successfully opened? + GBool isOk() { return ok; } + + // Get file name. + GString *getFileName() { return fileName; } + + // Get the xref table. + XRef *getXRef() { return xref; } + + // Get catalog. + Catalog *getCatalog() { return catalog; } + + // Get base stream. + BaseStream *getBaseStream() { return str; } + + // Get page parameters. + fouble getPageWidth(int page) + { return catalog->getPage(page)->getWidth(); } + fouble getPageHeight(int page) + { return catalog->getPage(page)->getHeight(); } + int getPageRotate(int page) + { return catalog->getPage(page)->getRotate(); } + + // Get number of pages. + int getNumPages() { return catalog->getNumPages(); } + + // Return the contents of the metadata stream, or NULL if there is + // no metadata. + GString *readMetadata() { return catalog->readMetadata(); } + + // Return the structure tree root object. + Object *getStructTreeRoot() { return catalog->getStructTreeRoot(); } + + // Display a page. + void displayPage(OutputDev *out, int page, fouble zoom, + int rotate, GBool doLinks); + + // Display a range of pages. + void displayPages(OutputDev *out, int firstPage, int lastPage, + int zoom, int rotate, GBool doLinks); + + // Find a page, given its object ID. Returns page number, or 0 if + // not found. + int findPage(int num, int gen) { return catalog->findPage(num, gen); } + + // If point , is in a link, return the associated action; + // else return NULL. + LinkAction *findLink(fouble x, fouble y) { return links->find(x, y); } + + // Return true if , is in a link. + GBool onLink(fouble x, fouble y) { return links->onLink(x, y); } + + // Find a named destination. Returns the link destination, or + // NULL if is not a destination. + LinkDest *findDest(GString *name) + { return catalog->findDest(name); } + + // Is the file encrypted? + GBool isEncrypted() { return xref->isEncrypted(); } + + // Check various permissions. + GBool okToPrint(GBool ignoreOwnerPW = gFalse) + { return xref->okToPrint(ignoreOwnerPW); } + GBool okToChange(GBool ignoreOwnerPW = gFalse) + { return xref->okToChange(ignoreOwnerPW); } + GBool okToCopy(GBool ignoreOwnerPW = gFalse) + { return xref->okToCopy(ignoreOwnerPW); } + GBool okToAddNotes(GBool ignoreOwnerPW = gFalse) + { return xref->okToAddNotes(ignoreOwnerPW); } + + // Is this document linearized? + GBool isLinearized(); + + // Return the document's Info dictionary (if any). + Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); } + + // Return the PDF version specified by the file. + fouble getPDFVersion() { return pdfVersion; } + + // Save this file with another name. + GBool saveAs(GString *name); + +private: + + GBool setup(GString *ownerPassword, GString *userPassword); + void checkHeader(); + void getLinks(Page *page); + + GString *fileName; + FILE *file; + BaseStream *str; + fouble pdfVersion; + XRef *xref; + Catalog *catalog; + Links *links; + GBool printCommands; + + GBool ok; +}; + +#endif -- cgit v0.9.0.2