ImageGear for C and C++ on Windows v19.6 - Updated
Reorder Pages in a Multi-Page Document
User Guide > How to Work with... > Common Operations > Manipulating Image Data > Work with Multi-Page Documents (HMIGEAR) > Reorder Pages in a Multi-Page Document

When an external file is opened in read-write mode, an operation such as page delete and page swap is possible. Not all filters support it. It is necessary to check with the function IG_fltr_info_get() for flags IG_FLTR_PAGEDELETESUPPORT and IG_FLTR_PAGESWAPSUPPORT in the lpdwInfoFlags parameter.

IG_mpf_page_swap() is used to reorder pages in the external file. The second and third arguments of this function are zero-based indexes of the pages to be swapped.

The IG_mpf_page_delete() function deletes the specified pages from the external file. The index of the first deleted page is passed through the second argument, and number of pages to be deleted is passed through the third argument.

Example:

This example shows how to reorder pages in a multi-page file.

 
Copy Code
AT_ERRCODE mpfPageReorder(
        HMIGEAR hMIGear
)
{
        UINT nPageCount;
        AT_MODE nFormatID;
        AT_ERRCOUNT nErrCnt;
        DWORD dwInfoFlags;
        UINT i;
IG_mpf_info_get( hMIGear, &nFormatID );
        if( nFormatID==IG_FORMAT_UNKNOWN )
        return  -1; /* file is not associated */
        IG_fltr_info_get( nFormatID, &dwInfoFlags, NULL, 0, NULL, 0, NULL, 0 );
        if( (dwInfoFlags&IG_FLTR_PAGESWAPSUPPORT)==0 )
        return  -1;/* format filter does not support the page swap operation */
        nErrCnt = IG_mpf_page_count_get( hMIGear, &nPageCount );
        for( i = 0; (i < nPageCount/2) && (nErrCnt==0); i++ )
nErrCnt = IG_mpf_page_swap( hMIGear, i, nPageCount - i - 1 );
        return -nErrCnt;
} 

Example:

This example demonstrates how to reorder pages in a multi-page file located in memory:

 
Copy Code
AT_ERRCODE mpiPageReorder(
HMIGEAR hMIGear
{
HIGEAR hPage1, hPage2;
UINT i, nPageCount;
AT_ERRCOUNT  nErrCnt = 0;
nErrCnt = IG_mpi_page_count_get( hMIGear, &nPageCount );
for( i = 0; (i<nPageCount/2) && (nErrCnt==0); i++ )
        {
        nErrCnt = IG_mpi_page_get( hMIGear, i, &hPage1 );
        nErrCnt += IG_mpi_page_get( hMIGear, nPageCount - i - 1, &hPage2 );
        nErrCnt += IG_mpi_page_set( hMIGear, i, hPage2 );
        nErrCnt += IG_mpi_page_set( hMIGear, nPageCount - i - 1, hPage1 );
}
return -nErrCnt;}

See Also:

IG_fltr_pageswap_file()

IG_fltr_pagedelete_file()

Loading and Saving