Some test text!

Hamburger Icon

Web / Guides / Graphics state

Graphics state using JavaScript

Only available with the Full API

To traverse the list of changes in the graphics state.

WebViewer({ fullAPI: true })
  .then(instance => {
    const { PDFNet } = instance.Core;
    await PDFNet.initialize();
    const reader = await PDFNet.ElementReader.create();
    const gs_itr = await reader.getChangesIterator();
    for ( ; gs_itr.hasNext();
        case GState.Attribute.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.
          // await gs.getTransform();
        case GState.Attribute.e_line_width :
          // await gs.getLineWidth();
        case GState.Attribute.e_line_cap :
          // await gs.getLineCap();
        case GState.Attribute.e_line_join :
          // await gs.getLineJoin();
        case GState.Attribute.e_miter_limit :
          // await gs.getMiterLimit();
        case GState.Attribute.e_dash_pattern :
          // await gs.GetDashPattern();
          // await gs.GetPhase();
        // Etc.

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.

Get the answers you need: Chat with us