Back to index

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

#include <Page.h>

Collaboration diagram for PageAttrs:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PageAttrs (PageAttrs *attrs, Dict *dict)
 ~PageAttrs ()
PDFRectanglegetBox ()
PDFRectanglegetMediaBox ()
PDFRectanglegetCropBox ()
GBool isCropped ()
PDFRectanglegetBleedBox ()
PDFRectanglegetTrimBox ()
PDFRectanglegetArtBox ()
int getRotate ()
GStringgetLastModified ()
DictgetBoxColorInfo ()
DictgetGroup ()
StreamgetMetadata ()
DictgetPieceInfo ()
DictgetSeparationInfo ()
DictgetResourceDict ()

Private Member Functions

GBool readBox (Dict *dict, char *key, PDFRectangle *box)

Private Attributes

PDFRectangle mediaBox
PDFRectangle cropBox
GBool haveCropBox
GBool limitToCropBox
PDFRectangle bleedBox
PDFRectangle trimBox
PDFRectangle artBox
int rotate
Object lastModified
Object boxColorInfo
Object group
Object metadata
Object pieceInfo
Object separationInfo
Object resources

Detailed Description

Definition at line 42 of file Page.h.


Constructor & Destructor Documentation

PageAttrs::PageAttrs ( PageAttrs attrs,
Dict dict 
)

Definition at line 34 of file Page.cc.

                                                 {
  Object obj1;
  double w, h;

  // get old/default values
  if (attrs) {
    mediaBox = attrs->mediaBox;
    cropBox = attrs->cropBox;
    haveCropBox = attrs->haveCropBox;
    rotate = attrs->rotate;
    attrs->resources.copy(&resources);
  } else {
    // set default MediaBox to 8.5" x 11" -- this shouldn't be necessary
    // but some (non-compliant) PDF files don't specify a MediaBox
    mediaBox.x1 = 0;
    mediaBox.y1 = 0;
    mediaBox.x2 = 612;
    mediaBox.y2 = 792;
    cropBox.x1 = cropBox.y1 = cropBox.x2 = cropBox.y2 = 0;
    haveCropBox = gFalse;
    rotate = 0;
    resources.initNull();
  }

  // media box
  readBox(dict, "MediaBox", &mediaBox);

  // crop box
  if (readBox(dict, "CropBox", &cropBox)) {
    haveCropBox = gTrue;
  }
  if (!haveCropBox) {
    cropBox = mediaBox;
  }

  // if the MediaBox is excessively larger than the CropBox,
  // just use the CropBox
  limitToCropBox = gFalse;
  if (haveCropBox) {
    w = 0.25 * (cropBox.x2 - cropBox.x1);
    h = 0.25 * (cropBox.y2 - cropBox.y1);
    if ((cropBox.x1 - mediaBox.x1) + (mediaBox.x2 - cropBox.x2) > w ||
       (cropBox.y1 - mediaBox.y1) + (mediaBox.y2 - cropBox.y2) > h) {
      limitToCropBox = gTrue;
    }
  }

  // other boxes
  bleedBox = cropBox;
  readBox(dict, "BleedBox", &bleedBox);
  trimBox = cropBox;
  readBox(dict, "TrimBox", &trimBox);
  artBox = cropBox;
  readBox(dict, "ArtBox", &artBox);

  // rotate
  dict->lookup("Rotate", &obj1);
  if (obj1.isInt()) {
    rotate = obj1.getInt();
  }
  obj1.free();
  while (rotate < 0) {
    rotate += 360;
  }
  while (rotate >= 360) {
    rotate -= 360;
  }

  // misc attributes
  dict->lookup("LastModified", &lastModified);
  dict->lookup("BoxColorInfo", &boxColorInfo);
  dict->lookup("Group", &group);
  dict->lookup("Metadata", &metadata);
  dict->lookup("PieceInfo", &pieceInfo);
  dict->lookup("SeparationInfo", &separationInfo);

  // resource dictionary
  dict->lookup("Resources", &obj1);
  if (obj1.isDict()) {
    resources.free();
    obj1.copy(&resources);
  }
  obj1.free();
}

Here is the call graph for this function:

Definition at line 119 of file Page.cc.

Here is the call graph for this function:


Member Function Documentation

Definition at line 60 of file Page.h.

{ return &artBox; }

Here is the caller graph for this function:

Definition at line 58 of file Page.h.

{ return &bleedBox; }

Here is the caller graph for this function:

Definition at line 54 of file Page.h.

{ return limitToCropBox ? &cropBox : &mediaBox; }

Here is the caller graph for this function:

Definition at line 65 of file Page.h.

    { return boxColorInfo.isDict() ? boxColorInfo.getDict() : (Dict *)NULL; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 56 of file Page.h.

{ return &cropBox; }

Here is the caller graph for this function:

Dict* PageAttrs::getGroup ( ) [inline]

Definition at line 67 of file Page.h.

    { return group.isDict() ? group.getDict() : (Dict *)NULL; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 62 of file Page.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file Page.h.

{ return &mediaBox; }

Here is the caller graph for this function:

Definition at line 69 of file Page.h.

    { return metadata.isStream() ? metadata.getStream() : (Stream *)NULL; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file Page.h.

    { return pieceInfo.isDict() ? pieceInfo.getDict() : (Dict *)NULL; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 76 of file Page.h.

    { return resources.isDict() ? resources.getDict() : (Dict *)NULL; }

Here is the call graph for this function:

Here is the caller graph for this function:

int PageAttrs::getRotate ( ) [inline]

Definition at line 61 of file Page.h.

{ return rotate; }

Here is the caller graph for this function:

Definition at line 73 of file Page.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 59 of file Page.h.

{ return &trimBox; }

Here is the caller graph for this function:

Definition at line 57 of file Page.h.

{ return haveCropBox; }

Here is the caller graph for this function:

GBool PageAttrs::readBox ( Dict dict,
char *  key,
PDFRectangle box 
) [private]

Definition at line 129 of file Page.cc.

                                                                 {
  PDFRectangle tmp;
  Object obj1, obj2;
  GBool ok;

  dict->lookup(key, &obj1);
  if (obj1.isArray() && obj1.arrayGetLength() == 4) {
    ok = gTrue;
    obj1.arrayGet(0, &obj2);
    if (obj2.isNum()) {
      tmp.x1 = obj2.getNum();
    } else {
      ok = gFalse;
    }
    obj2.free();
    obj1.arrayGet(1, &obj2);
    if (obj2.isNum()) {
      tmp.y1 = obj2.getNum();
    } else {
      ok = gFalse;
    }
    obj2.free();
    obj1.arrayGet(2, &obj2);
    if (obj2.isNum()) {
      tmp.x2 = obj2.getNum();
    } else {
      ok = gFalse;
    }
    obj2.free();
    obj1.arrayGet(3, &obj2);
    if (obj2.isNum()) {
      tmp.y2 = obj2.getNum();
    } else {
      ok = gFalse;
    }
    obj2.free();
    if (ok) {
      *box = tmp;
    }
  } else {
    ok = gFalse;
  }
  obj1.free();
  return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 89 of file Page.h.

Definition at line 87 of file Page.h.

Definition at line 92 of file Page.h.

Definition at line 84 of file Page.h.

Definition at line 93 of file Page.h.

Definition at line 85 of file Page.h.

Definition at line 91 of file Page.h.

Definition at line 86 of file Page.h.

Definition at line 83 of file Page.h.

Definition at line 94 of file Page.h.

Definition at line 95 of file Page.h.

Definition at line 97 of file Page.h.

Definition at line 90 of file Page.h.

Definition at line 96 of file Page.h.

Definition at line 88 of file Page.h.


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