Some test text!

menu
search
Graphics statekeyboard_arrow_down

Graphics state

To traverse the list of changes in the graphics state.

GSChangesIterator gs_itr = reader.getChangesIterator();
while (gs_itr.hasNext()) {
  switch (gs_itr.next().intValue()) {
    case GState.e_transform:
      // 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 GState.e_line_width:
      //gs.getLineWidth();
      break;
    case GState.e_line_cap:
      //gs.getLineCap();
      break;
    case GState.e_line_join:
      //gs.getLineJoin();
      break;
    case GState.e_miter_limit:
      //gs.getMiterLimit();
      break;
    case GState.e_dash_pattern: {
      //double[] dashes;
      //dashes=gs.getDashes();
      //gs.getPhase();
    }
    break;
  }
}

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.

linkAbout 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.

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

if (reader.isChanged(GState.e_line_width))
{
   // 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

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close