//
// PDFDoc.h
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef PDFDOC_H
#define PDFDOC_H
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#include <stdio.h>
-#include "Link.h"
+#include "XRef.h"
#include "Catalog.h"
#include "Page.h"
class GString;
class BaseStream;
-class XRef;
class OutputDev;
class Links;
class LinkAction;
class LinkDest;
+class Outline;
//------------------------------------------------------------------------
// PDFDoc
class PDFDoc {
public:
- PDFDoc(GString *fileName1, GString *userPassword = NULL);
- PDFDoc(BaseStream *str, GString *userPassword = NULL);
+ PDFDoc(GString *fileNameA, GString *ownerPassword = NULL,
+ GString *userPassword = NULL, void *guiDataA = NULL);
+#ifdef WIN32
+ PDFDoc(wchar_t *fileNameA, int fileNameLen, GString *ownerPassword = NULL,
+ GString *userPassword = NULL, void *guiDataA = NULL);
+#endif
+ PDFDoc(BaseStream *strA, GString *ownerPassword = NULL,
+ GString *userPassword = NULL, void *guiDataA = NULL);
~PDFDoc();
// Was PDF document successfully opened?
GBool isOk() { return ok; }
+ // Get the error code (if isOk() returns false).
+ int getErrorCode() { return errCode; }
+
// Get file name.
GString *getFileName() { return fileName; }
+ // Get the xref table.
+ XRef *getXRef() { return xref; }
+
// Get catalog.
Catalog *getCatalog() { return catalog; }
BaseStream *getBaseStream() { return str; }
// Get page parameters.
- double getPageWidth(int page)
- { return catalog->getPage(page)->getWidth(); }
- double getPageHeight(int page)
- { return catalog->getPage(page)->getHeight(); }
+ double getPageMediaWidth(int page)
+ { return catalog->getPage(page)->getMediaWidth(); }
+ double getPageMediaHeight(int page)
+ { return catalog->getPage(page)->getMediaHeight(); }
+ double getPageCropWidth(int page)
+ { return catalog->getPage(page)->getCropWidth(); }
+ double getPageCropHeight(int page)
+ { return catalog->getPage(page)->getCropHeight(); }
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, double zoom,
- int rotate, GBool doLinks);
+ void displayPage(OutputDev *out, int page, double hDPI, double vDPI,
+ int rotate, GBool useMediaBox, GBool crop,
+ GBool doLinks,
+ GBool (*abortCheckCbk)(void *data) = NULL,
+ void *abortCheckCbkData = NULL);
// Display a range of pages.
void displayPages(OutputDev *out, int firstPage, int lastPage,
- int zoom, int rotate, GBool doLinks);
+ double hDPI, double vDPI, int rotate,
+ GBool useMediaBox, GBool crop, GBool doLinks,
+ GBool (*abortCheckCbk)(void *data) = NULL,
+ void *abortCheckCbkData = NULL);
+
+ // Display part of a page.
+ void displayPageSlice(OutputDev *out, int page,
+ double hDPI, double vDPI, int rotate,
+ GBool useMediaBox, GBool crop, GBool doLinks,
+ int sliceX, int sliceY, int sliceW, int sliceH,
+ GBool (*abortCheckCbk)(void *data) = NULL,
+ void *abortCheckCbkData = NULL);
// 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 <x>,<y> is in a link, return the associated action;
- // else return NULL.
- LinkAction *findLink(double x, double y) { return links->find(x, y); }
-
- // Return true if <x>,<y> is in a link.
- GBool onLink(double x, double y) { return links->onLink(x, y); }
+ // Returns the links for the current page, transferring ownership to
+ // the caller.
+ Links *takeLinks();
// Find a named destination. Returns the link destination, or
// NULL if <name> is not a destination.
LinkDest *findDest(GString *name)
{ return catalog->findDest(name); }
+#ifndef DISABLE_OUTLINE
+ // Return the outline object.
+ Outline *getOutline() { return outline; }
+#endif
+
// Is the file encrypted?
GBool isEncrypted() { return xref->isEncrypted(); }
// Check various permissions.
- GBool okToPrint() { return xref->okToPrint(); }
- GBool okToChange() { return xref->okToChange(); }
- GBool okToCopy() { return xref->okToCopy(); }
- GBool okToAddNotes() { return xref->okToAddNotes(); }
+ 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); }
+ Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
// Return the PDF version specified by the file.
double getPDFVersion() { return pdfVersion; }
// Save this file with another name.
GBool saveAs(GString *name);
+ // Return a pointer to the GUI (XPDFCore or WinPDFCore object).
+ void *getGUIData() { return guiData; }
+
+
private:
- GBool setup(GString *userPassword);
+ GBool setup(GString *ownerPassword, GString *userPassword);
void checkHeader();
+ GBool checkEncryption(GString *ownerPassword, GString *userPassword);
void getLinks(Page *page);
GString *fileName;
FILE *file;
BaseStream *str;
+ void *guiData;
double pdfVersion;
XRef *xref;
Catalog *catalog;
Links *links;
+#ifndef DISABLE_OUTLINE
+ Outline *outline;
+#endif
+
GBool ok;
+ int errCode;
};
#endif