Back to index

tetex-bin  3.0
Public Member Functions | Private Attributes
Page Class Reference

#include <Page.h>

Collaboration diagram for Page:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Page (XRef *xrefA, int numA, Dict *pageDict, PageAttrs *attrsA)
 ~Page ()
GBool isOk ()
PDFRectanglegetBox ()
PDFRectanglegetMediaBox ()
PDFRectanglegetCropBox ()
GBool isCropped ()
double getWidth ()
double getHeight ()
PDFRectanglegetBleedBox ()
PDFRectanglegetTrimBox ()
PDFRectanglegetArtBox ()
int getRotate ()
GStringgetLastModified ()
DictgetBoxColorInfo ()
DictgetGroup ()
StreamgetMetadata ()
DictgetPieceInfo ()
DictgetSeparationInfo ()
DictgetResourceDict ()
ObjectgetAnnots (Object *obj)
ObjectgetContents (Object *obj)
void display (OutputDev *out, double hDPI, double vDPI, int rotate, GBool crop, Links *links, Catalog *catalog, GBool(*abortCheckCbk)(void *data)=NULL, void *abortCheckCbkData=NULL)
void displaySlice (OutputDev *out, double hDPI, double vDPI, int rotate, GBool crop, int sliceX, int sliceY, int sliceW, int sliceH, Links *links, Catalog *catalog, GBool(*abortCheckCbk)(void *data)=NULL, void *abortCheckCbkData=NULL)

Private Attributes

XRefxref
int num
PageAttrsattrs
Object annots
Object contents
GBool ok

Detailed Description

Definition at line 104 of file Page.h.


Constructor & Destructor Documentation

Page::Page ( XRef xrefA,
int  numA,
Dict pageDict,
PageAttrs attrsA 
)

Definition at line 179 of file Page.cc.

                                                                   {
  ok = gTrue;
  xref = xrefA;
  num = numA;

  // get attributes
  attrs = attrsA;

  // annotations
  pageDict->lookupNF("Annots", &annots);
  if (!(annots.isRef() || annots.isArray() || annots.isNull())) {
    error(-1, "Page annotations object (page %d) is wrong type (%s)",
         num, annots.getTypeName());
    annots.free();
    goto err2;
  }

  // contents
  pageDict->lookupNF("Contents", &contents);
  if (!(contents.isRef() || contents.isArray() ||
       contents.isNull())) {
    error(-1, "Page contents object (page %d) is wrong type (%s)",
         num, contents.getTypeName());
    contents.free();
    goto err1;
  }

  return;

 err2:
  annots.initNull();
 err1:
  contents.initNull();
  ok = gFalse;
}

Here is the call graph for this function:

Definition at line 215 of file Page.cc.

            {
  delete attrs;
  annots.free();
  contents.free();
}

Here is the call graph for this function:


Member Function Documentation

void Page::display ( OutputDev out,
double  hDPI,
double  vDPI,
int  rotate,
GBool  crop,
Links links,
Catalog catalog,
GBool(*)(void *data abortCheckCbk = NULL,
void abortCheckCbkData = NULL 
)

Definition at line 221 of file Page.cc.

                                          {
  displaySlice(out, hDPI, vDPI, rotate, crop, -1, -1, -1, -1, links, catalog,
              abortCheckCbk, abortCheckCbkData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Page::displaySlice ( OutputDev out,
double  hDPI,
double  vDPI,
int  rotate,
GBool  crop,
int  sliceX,
int  sliceY,
int  sliceW,
int  sliceH,
Links links,
Catalog catalog,
GBool(*)(void *data abortCheckCbk = NULL,
void abortCheckCbkData = NULL 
)

Definition at line 230 of file Page.cc.

                                              {
#ifndef PDF_PARSER_ONLY
  PDFRectangle *mediaBox, *cropBox;
  PDFRectangle box;
  Gfx *gfx;
  Object obj;
  Link *link;
  Annots *annotList;
  double kx, ky;
  int i;

  rotate += getRotate();
  if (rotate >= 360) {
    rotate -= 360;
  } else if (rotate < 0) {
    rotate += 360;
  }

  mediaBox = getBox();
  if (sliceW >= 0 && sliceH >= 0) {
    kx = 72.0 / hDPI;
    ky = 72.0 / vDPI;
    if (rotate == 90) {
      if (out->upsideDown()) {
       box.x1 = mediaBox->x1 + ky * sliceY;
       box.x2 = mediaBox->x1 + ky * (sliceY + sliceH);
      } else {
       box.x1 = mediaBox->x2 - ky * (sliceY + sliceH);
       box.x2 = mediaBox->x2 - ky * sliceY;
      }
      box.y1 = mediaBox->y1 + kx * sliceX;
      box.y2 = mediaBox->y1 + kx * (sliceX + sliceW);
    } else if (rotate == 180) {
      box.x1 = mediaBox->x2 - kx * (sliceX + sliceW);
      box.x2 = mediaBox->x2 - kx * sliceX;
      if (out->upsideDown()) {
       box.y1 = mediaBox->y1 + ky * sliceY;
       box.y2 = mediaBox->y1 + ky * (sliceY + sliceH);
      } else {
       box.y1 = mediaBox->y2 - ky * (sliceY + sliceH);
       box.y2 = mediaBox->y2 - ky * sliceY;
      }
    } else if (rotate == 270) {
      if (out->upsideDown()) {
       box.x1 = mediaBox->x2 - ky * (sliceY + sliceH);
       box.x2 = mediaBox->x2 - ky * sliceY;
      } else {
       box.x1 = mediaBox->x1 + ky * sliceY;
       box.x2 = mediaBox->x1 + ky * (sliceY + sliceH);
      }
      box.y1 = mediaBox->y2 - kx * (sliceX + sliceW);
      box.y2 = mediaBox->y2 - kx * sliceX;
    } else {
      box.x1 = mediaBox->x1 + kx * sliceX;
      box.x2 = mediaBox->x1 + kx * (sliceX + sliceW);
      if (out->upsideDown()) {
       box.y1 = mediaBox->y2 - ky * (sliceY + sliceH);
       box.y2 = mediaBox->y2 - ky * sliceY;
      } else {
       box.y1 = mediaBox->y1 + ky * sliceY;
       box.y2 = mediaBox->y1 + ky * (sliceY + sliceH);
      }
    }
  } else {
    box = *mediaBox;
  }
  cropBox = getCropBox();

  if (globalParams->getPrintCommands()) {
    printf("***** MediaBox = ll:%g,%g ur:%g,%g\n",
          box.x1, box.y1, box.x2, box.y2);
    if (isCropped()) {
      printf("***** CropBox = ll:%g,%g ur:%g,%g\n",
            cropBox->x1, cropBox->y1, cropBox->x2, cropBox->y2);
    }
    printf("***** Rotate = %d\n", attrs->getRotate());
  }

  gfx = new Gfx(xref, out, num, attrs->getResourceDict(),
              hDPI, vDPI, &box, crop && isCropped(), cropBox, rotate,
              abortCheckCbk, abortCheckCbkData);
  contents.fetch(xref, &obj);
  if (!obj.isNull()) {
    gfx->saveState();
    gfx->display(&obj);
    gfx->restoreState();
  }
  obj.free();

  // draw links
  if (links) {
    gfx->saveState();
    for (i = 0; i < links->getNumLinks(); ++i) {
      link = links->getLink(i);
      out->drawLink(link, catalog);
    }
    gfx->restoreState();
    out->dump();
  }

  // draw non-link annotations
  annotList = new Annots(xref, annots.fetch(xref, &obj));
  obj.free();
  if (annotList->getNumAnnots() > 0) {
    if (globalParams->getPrintCommands()) {
      printf("***** Annotations\n");
    }
    for (i = 0; i < annotList->getNumAnnots(); ++i) {
      annotList->getAnnot(i)->draw(gfx);
    }
    out->dump();
  }
  delete annotList;

  delete gfx;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

Object* Page::getAnnots ( Object obj) [inline]

Definition at line 138 of file Page.h.

{ return annots.fetch(xref, obj); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file Page.h.

{ return attrs->getArtBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 123 of file Page.h.

{ return attrs->getBleedBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

PDFRectangle* Page::getBox ( ) [inline]

Definition at line 117 of file Page.h.

{ return attrs->getBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Dict* Page::getBoxColorInfo ( ) [inline]

Definition at line 128 of file Page.h.

{ return attrs->getBoxColorInfo(); }

Here is the call graph for this function:

Object* Page::getContents ( Object obj) [inline]

Definition at line 141 of file Page.h.

{ return contents.fetch(xref, obj); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 119 of file Page.h.

{ return attrs->getCropBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Dict* Page::getGroup ( ) [inline]

Definition at line 129 of file Page.h.

{ return attrs->getGroup(); }

Here is the call graph for this function:

Here is the caller graph for this function:

double Page::getHeight ( ) [inline]

Definition at line 122 of file Page.h.

{ return attrs->getBox()->y2 - attrs->getBox()->y1; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file Page.h.

{ return attrs->getLastModified(); }

Here is the call graph for this function:

Definition at line 118 of file Page.h.

{ return attrs->getMediaBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Stream* Page::getMetadata ( ) [inline]

Definition at line 130 of file Page.h.

{ return attrs->getMetadata(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Dict* Page::getPieceInfo ( ) [inline]

Definition at line 131 of file Page.h.

{ return attrs->getPieceInfo(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Dict* Page::getResourceDict ( ) [inline]

Definition at line 135 of file Page.h.

{ return attrs->getResourceDict(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int Page::getRotate ( ) [inline]

Definition at line 126 of file Page.h.

{ return attrs->getRotate(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file Page.h.

{ return attrs->getSeparationInfo(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 124 of file Page.h.

{ return attrs->getTrimBox(); }

Here is the call graph for this function:

Here is the caller graph for this function:

double Page::getWidth ( ) [inline]

Definition at line 121 of file Page.h.

{ return attrs->getBox()->x2 - attrs->getBox()->x1; }

Here is the call graph for this function:

Here is the caller graph for this function:

GBool Page::isCropped ( ) [inline]

Definition at line 120 of file Page.h.

{ return attrs->isCropped(); }

Here is the call graph for this function:

Here is the caller graph for this function:

GBool Page::isOk ( ) [inline]

Definition at line 114 of file Page.h.

{ return ok; }

Member Data Documentation

Object Page::annots [private]

Definition at line 163 of file Page.h.

PageAttrs* Page::attrs [private]

Definition at line 162 of file Page.h.

Definition at line 164 of file Page.h.

int Page::num [private]

Definition at line 161 of file Page.h.

GBool Page::ok [private]

Definition at line 165 of file Page.h.

XRef* Page::xref [private]

Definition at line 160 of file Page.h.


The documentation for this class was generated from the following files: