Skip to content

IGR_Extract_Image

IGR_Extract_Image extracts an image to disk from a document opened with HTML or Image conversion in affect.

The image ID is obtained previously by IGR_Get_Image_Entry from the document.

Prototype

IGR_LONG IGR_Extract_Image(
    IGR_LONG DocHandle,
    const IGR_UCS2* ID,
    const IGR_UCS2* Destination,
    Error_Control_Block* ISYSError);

Parameters

DocHandle: IGR_LONG

Is a handle to a file, opened by a call to IGR_Open_File.

ID: Unicode string (UCS2)

Unique ID of the sub-document to be extracted, obtained by a call to IGR_Get_Image_Entry.

Destination: Unicode string (UCS2)

Path to a file on disk, where the binary the sub-document will be written.

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.

Sample code

Error_Control_Block ISYSError;
IGR_LONG Capabilities, DocType, DocHandle;
IGR_UCS2 ID[4096], Name[1024];
INT64 FileDate, FileSize;

IGR_LONG RC = IGR_Open_File_Ex(_UCS2("TEST.DOC"), IGR_BODY_AND_META | IGR_FORMAT_HTML, _UCS2(""), &Capabilities, &DocType, &DocHandle, &ISYSError);
if (RC == IGR_OK)
{
    // Extract document HTML via IGR_Get_Text first, then...
    while (true)
    {
        rc = IGR_Get_Image_Entry(DocHandle, ID, Name, &FileDate, &FileSize, &ISYSError);
        if (rc != IGR_OK)
        {
            if (rc != IGR_NO_MORE)
                // ReportError(rc);
            break;
        }
        rc = IGR_Extract_Image(DocHandle, ID, ID, &ISYSError);
        if (rc != IGR_OK)
            // ReportError(rc);
    }
    IGR_Close_File(DocHandle, &ISYSError);
}

See also