# CPage

Pdf dictionaries referenced from are called page objects. These dictionaries must contain a "Type" entry and the value must be a name object equal to "Page". Page objects are basic building blocks of pdf files. Each page can be independent with all required information stored in its dictionary. Some of its properties can be inherited from parent pages. Page object describes the appereance of the page (witdth, length, fonts used, rotation etc.).

The core of a page is one or more content streams which specify what is on a page (text, pictures, graphics ...).

## Observing cpage

Generally, changing an object can result in many other changes. Objects often depend on other objects. Changing a page property can result in

- redraw of the page

- redraw of other pages

This is the reason why cpage implements observer subject interface (see . An object can be notified if cpage changes.

## Changing cpage

Page dictionary can be changed in two ways. Either by cpage methods or by requesting raw dictionary by its reference number. If we do not want to parse the whole pdf file, we do not have the information whether an object is a page or just an object with page type. This problem is solved by . We observe the underlying dictionary which implements the observer subject interface. This way, we know every time the dictionary is changed either by cpage or by cobject.

## Changing page contents

Any change to a visible part of a page are delegated to content stream object ().

## Displaying page

Xpdf has the best displaying engine of all tested viewers. All calls to display methods are delegated to this engine. When displaying a page CPage creates xpdf Page object from its actual state. Then it uses Page object method displaySlice() to display a rectangle of a page. Xpdf creates the graphical environment for drawing into an output device. Finally it draws the page into supplied device.

## Objects on a page

Everything on a page is in its content stream(s). Every operation in a content stream means altering the actual position by moving the drawing pen from one position to another position creating a rectangle which can be used to constrain each object. The rectangle can be used to order all objects into a structure which can be easily searched. This enables effective selection of only some objects.

### Text on a page

Pdf specification does not force pdf converters to keep text structure of converted document. This means that no text element needs to correspond to an element in the original file e.g. paragraphs, lines, words. Even the order of single letters can be arbitrary. Xpdf (or any other sophisticated) viewer only guesses which letter form a word or which words form a line. We use xpdf text engine to extract, search text.

### Fonts on a page

Pdf file can refer either to extern system fonts which are specified by pdf specification and each viewer should have these fonts avaliable or it can inline font metrics into the pdf file. The latter option is very tricky because it allows the font to contain only those letters which are actually used. CPage object supports adding fonts which can be used on a page. Fonts must be present in the pdf file or they must refer to system fonts.