Some test text!

Graphics state

After reading an Element using ElementReader.Next(), it is possible to access all graphical attributes of the Element through its graphics state. Some applications are more interested in changes in the graphics state than attribute values. For example, a transition from one Element to another may not involve changes in the graphics state. Or, perhaps, there may be changes only to a couple of attributes. In these cases, it isn't efficient to make memberwise comparisons between the old and current graphics states.

To make this easier and more efficient, PDFTron SDK offers an API to enumerate the list of changes between subsequent Elements.

The list of changes in a graphics state can be traversed using the ElementReader.ChangesBegin/End() methods, as illustrated by the following example:

GSChangesIterator itr = reader.ChangesBegin();
GSChangesIterator end = reader.ChangesEnd();
for (; itr != end; itr.Next())
    case GState.GStateAttribute.e_transform:
      // Get transform matrix for this element.
      // Unlike path.GetCTM() that returns full
      // transformation matrix gs.GetTransform()
      // returns only the transformation matrix
      // that was installed for this element (a
      // cm operator preceding this Element).
      // gs.GetTransform();
    case GState.GStateAttribute.e_line_width:
      // gs.GetLineWidth();
    case GState.GStateAttribute.e_line_cap:
      // gs.GetLineCap();
    case GState.GStateAttribute.e_line_join:
      // gs.GetLineJoin();
    case GState.GStateAttribute.e_miter_limit:
      // gs.GetMiterLimit();
    case GState.GStateAttribute.e_dash_pattern:

    // Etc.

It's also possible to query ElementReader for changes to a specific attribute:

if (reader.IsChanged(
   // line width was changed.

Note that the list of modified attributes is accumulated when calling ElementReader.Next(). To clear the list of modified attributes use ElementReader.ClearChangeList() method. A call to ClearChangeList() serves as a marker in the display list from which further changes in the graphics state are tracked.

Get the answers you need: Support