> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/ios/editing-page-content/graphics-state.md).

# Graphics state on iOS

Learn how to extract data from PDF files, including images, text, and paths. Explore a full code sample for PDF data extraction and processing changes in the graphics state efficiently with Apryse SDK

To traverse the list of changes in the graphics state.

{% tabs %}
{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
PTGSChangesIterator *gs_itr = [reader GetChangesIterator];
for (; [gs_itr HasNext]; [gs_itr Next]) 
{
  switch([gs_itr Current])
  {
    case e_pttransform :
      // Get transform matrix for this element. Unlike path.GetCTM() 
      // that return full transformation matrix gs.GetTransform() return 
      // only the transformation matrix that was installed for this element.
      //
      // gs.GetTransform();
      break;
    case e_ptline_width :
      // gs.GetLineWidth();
      break;
    case e_ptline_cap :
      // gs.GetLineCap();
      break;
    case e_ptline_join :
      // gs.GetLineJoin();
      break;
    case e_ptmiter_limit :
      // gs.GetMiterLimit();
      break;
    case e_ptdash_pattern :
      {
        // std::vector<double> dashes;
        // gs.GetDashes(dashes);
        // gs.GetPhase()
      }
      break;
    default:
      break;
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
let gs_itr: PTGSChangesIterator = reader.getChangesIterator()
while gs_itr.hasNext() {
  switch PTGStateAttribute(rawValue: UInt32(gs_itr.current())) {
    case e_pttransform:
      // Get transform matrix for this element. Unlike path.GetCTM()
      // that return full transformation matrix gs.GetTransform() return
      // only the transformation matrix that was installed for this element.
      //
      // gs.getTransform()
      break
    case e_ptline_width:
      // gs.getLineWidth()
      break
    case e_ptline_cap:
      // gs.getLineCap()
      break
    case e_ptline_join:
      // gs.getLineJoin()
      break
    case e_ptmiter_limit:
      // gs.GetmiterLimit()
      break
    case e_ptdash_pattern:
      // let dashes: NSMutableArray = gs.getDashes()
      // gs.getPhase()
      break
    default:
        break
  }
    gs_itr.next()
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

[PDF Data Extraction (Images, Text, Paths)](/ios/get-started/samples.md#elementreaderadv) Full code sample which illustrates how to extract data, do color conversion, image normalization, and how to process changes in the graphics state.

## About 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, Apryse SDK offers an API to enumerate the list of changes between subsequent Elements.

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

{% tabs %}
{% tab title="Obj-C" %}
{% code lineNumbers="true" %}

```objc
if ([reader IsChanged:e_ptline_width])
{
   // line width was changed.
}
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
if (reader.isChanged(e_ptline_width))
{
   // line width was changed.
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/ios/editing-page-content/graphics-state.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
