Graphics state on Server/Desktop

To traverse the list of changes in the graphics state.

1gs_itr = reader.GetChangesIterator
2while gs_itr.HasNext do
3 case gs_itr.Current
4 when GState::E_transform
5 # Get transform matrix for this element. Unlike path.GetCTM
6 # that return full transformation matrix gs.GetTransform return
7 # only the transformation matrix that was installed for this element.
8 #
9 # gs.GetTransform
10 when GState::E_line_width
11 # gs.GetLineWidth
12 when GState::E_line_cap
13 # gs.GetLineCap
14 when GState::E_line_join
15 # gs.GetLineJoin
16 when GState::E_miter_limit
17 # gs.GetMiterLimit
18 when GState::E_dash_pattern
19 # dashes = gs.GetDashes
20 # gs.GetPhase
21 end
22 gs_itr.Next
23end

PDF Data Extraction (Images, Text, Paths) - Full Sample
Full code sample which illustrates how to extract data, do color conversion, image normalization, and how to process changes in the graphics state. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB. To use this code, you'll need to download and get started with Server SDK.

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(GState::E_line_width))
2 # line width was changed.
3end

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