# Operators

Every page has its content stream which contains the description of every object on a page. Content stream consists of operators and their operands specifying how to alter graphical state of a page. These operators specify what and how it is displayed. They are processed sequentially. If no content stream is avaliable (or is empty) the approperiate page is empty.

## PdfOperators

Content stream consists of operators and their operands. Operators can be either simple or composite objects. The requirement for processing operators sequentially and representing operators in human readable form resulted in storing each operator in two queues.

Operator overview

Operator overview

## Changing pdf operators

Changing the visible object properties means wrap those objects into other objects. Object can depend on previous objects. We need to be able to iterate backwards. Summarizing these requirements with human readable representation of operators leads to these decisions:

- sequentially processing the list, the order has to be the same as in the file we edit -

- grouping and wrapping operators - and specific

The first requirement is needed when simulating the display process of an pdf viewer (e.g. when finding out the absolute position of an operator). used in representation of pdf operators is very useful, when changing objects (e.g. changing an existing text object to composite is very easy allowing us to add some special formatting). This becomes very useful with the which allows us to change this object in conjuction with previous changes.

Example of changed pdf operator

Example of changed pdf operator

# Pdfoperator iterator

allows us to iterate over items. When designed correctly specific iterator can be added easily.

## PdfOperatorIterator

Pdf operator iterator is a bidirectional iterator over PdfOperator objects. This iterator is special. The information about next and previous object is stored in the object itself. This iterator works with smart pointers which brings us the problem of dependency cycle and objects would not get deallocated. This was solved by introducing another type of smart pointer which can handle this.

It is very similar to a normal bidirectional linked list. The iterator class holds the information whether it is before the beginning, after the end or at a valid item.

## Extending iterator

Basic iterator class implements one Template method. Specific iterators are created by overloading this method. It decides whether an item is valid or not. There are two important children of the base iterator class.

- AcceptingPdfOperatorIterator class

- RejectingPdfOperatorIterator class

These two classes either accept a set or operators or accept everything except those iterators. Extending these classes requires only defining the set of operators.

Pdf operator iterators overview

Pdf operator iterators overview