Skip to content

IGR_Get_Page_Attribute

IGR_Get_Page_Attribute returns style or properties of an open page; see <page> under Structured XML for a full list of options.

Prototype

IGR_LONG IGR_Get_Page_Attribute(
    HPAGE Page,
    const IGR_UCS2* Name,
    IGR_UCS2* Buffer,
    IGR_LONG* BufferSize,
    Error_Control_Block* ISYSError);

Parameters

Page: Handle to Page

The handle to a page that was opened using IGR_Open_Page.

Name: Unicode string (UCS2)

The name of the attribute to be extracted, see <page> under Structured XML for a full list of options, and Machine Learning Attributes below.

Buffer: Unicode string (UCS2)

Application allocated memory block that will be filled with the next portion of text.

BufferSize: Pointer to IGR_LONG

Prior to the call: The size in Unicode (UCS2) characters of the buffer.

After the call: The actual number of Unicode (UCS2) characters extracted.

ISYSError: Pointer to Error_Control_Block

Returns error details if the call fails.

Return value

Success: IGR_LONG

Returns IGR_OK.

Failure: IGR_LONG

Returns one of the possible IGR_E error codes.

Machine Learning Attributes

The following attributes run a machine learning model on the page the first time one of them is read. The result is kept with the page, so reading the label and then the confidence runs the model once. These attributes need ONNX Runtime and the models; see Image Layout Detection. When the model cannot run, the label and the description are empty and the confidence is 0.

Attribute Description
ML_PAGE_CLASSIFICATION The type of the page, chosen by the model that ML_CLASSIFICATION_MODEL names. One of: document, screenshot, photographed_document, receipt, id_or_card, form_with_handwriting, whiteboard_or_notes, book_or_magazine_page, chart_or_infographic, presentation_slide, map, artwork_or_illustration, natural_photo, blank_or_low_quality, spreadsheet, cover_page_or_title_page, code_or_technical_listing, email_printout, business_card_or_label, engineering_drawing_or_blueprint.
ML_PAGE_CLASSIFICATION.LABEL The same value as ML_PAGE_CLASSIFICATION.
ML_PAGE_CLASSIFICATION.CONFIDENCE The model's confidence in the type, from 0 to 1.
ML_PAGE_DESCRIPTION An English description of the page, written by the model that ML_DESCRIPTION_MODEL names.

Note

ML_PAGE_DESCRIPTION is separate from Image Description, which calls back into your application to describe the images in a document.

Sample code

Error_Control_Block ISYSError;
IGR_LONG Capabilities, DocType, DocHandle, PageHandle;

IGR_LONG RC = IGR_Open_File(_UCS2("TEST.DOC"), IGR_FORMAT_IMAGE, &Capabilities, &DocType, &DocHandle, &ISYSError);

if (RC == IGR_OK)
{
    IGR_LONG PageCount;
    if (IGR_Get_Page_Count(DocHandle, &PageCount, &ISYSError) == IGR_OK)
    {
        for (IGR_LONG I = i; i <= PageCount; i++)
        {
            if (IGR_Open_Page(DocHandle, i, &PageHandle, &ISYSError) == IGR_OK)
            {
                IGR_UCS2 Buffer[255];
                IGR_LONG BufferSize = 254;

                if (IGR_Get_Page_Attribute(PageHandle, _UCS2("SourceDpiX"), Buffer,
                    BufferSize, &ISYSError) == IGR_OK)
                {
                    // - Buffer contains the value for SourceDpiX
                }
                IGR_Close_Page(PageHandle, &ISYSError);
            }
        }
    }
}

See also