Graphics state on iOS

To traverse the list of changes in the graphics state.

1PTGSChangesIterator *gs_itr = [reader GetChangesIterator];
2for (; [gs_itr HasNext]; [gs_itr Next])
3{
4 switch([gs_itr Current])
5 {
6 case e_pttransform :
7 // Get transform matrix for this element. Unlike path.GetCTM()
8 // that return full transformation matrix gs.GetTransform() return
9 // only the transformation matrix that was installed for this element.
10 //
11 // gs.GetTransform();
12 break;
13 case e_ptline_width :
14 // gs.GetLineWidth();
15 break;
16 case e_ptline_cap :
17 // gs.GetLineCap();
18 break;
19 case e_ptline_join :
20 // gs.GetLineJoin();
21 break;
22 case e_ptmiter_limit :
23 // gs.GetMiterLimit();
24 break;
25 case e_ptdash_pattern :
26 {
27 // std::vector<double> dashes;
28 // gs.GetDashes(dashes);
29 // gs.GetPhase()
30 }
31 break;
32 default:
33 break;
34 }
35}

PDF Data Extraction (Images, Text, Paths)
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:

1if ([reader IsChanged:e_ptline_width])
2{
3 // line width was changed.
4}

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.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales