ImageGear Professional DLL v17.1 for Windows Accusoft
Loading and Saving Pages
Send Feedback  
ImageGear Professional DLL v17.1 for Windows > User Guide > Using ImageGear > Loading and Saving Images > Working with Multi-Page Documents > Loading and Saving Pages

Glossary Item Box

After the multi-page image is associated with an external file, it is possible to perform operations such as page loads, saves, swaps, and deletes. If open mode is read-only, then only the page load is allowed. All others will trigger an error.

Use the function IG_mpf_page_load() to load pages from an external file into a multi-page image. The second argument of the function is a zero-based index of the first page for loading. The third argument specifies the number of pages to load starting from this index. The order and location of the loaded pages in the page array is the same as in the external file. Therefore, if the file pages start from nFirstIndex, then it loads into the page array starting with nFirstIndex. If necessary, the page arrays are expanded to fit all of the requested number of pages. If, while loading, some elements of the page array contains a valid HIGEAR image, then it is not deleted. It is then assigned a new value of the image loaded from the file.

Use the function IG_mpf_page_save() to save pages from a multi-page image into an external file. The second and third arguments are the same and have the same meaning as the second and third arguments for the load function. The fourth argument specifies the compression method (for example, IG_COMPRESSION_JPEG or IG_COMPRESSION_LZW for a TIFF image) and applies to all pages from the given range. The last parameter of this function specifies how to save the pages into a file. There are two modes are possible:

The first mode inserts pages into the file at the location specified by the second parameter, which is demonstrated in the following picture:

IG_MPF_SAVE_INSERT:

The second mode replaces pages starting from the index specified by the second parameter:

IG_MPF_SAVE_REPLACE:

Example:

To load pages 2 through 5 from the file "image1.tif" and insert them into file "image2.tif," the program is:

  Copy Code
/*...*/
HMIGEAR         hMIGear;
AT_ERRCOUNT        nErrCount;
UINT        nStartPage;
UINT        nCount;
nErrCount = IG_mpi_create(&hMIGear, 0);
if (!nErrCount)
{
nErrCount = IG_mpi_file_open( "picture1.tif", hMIGear, IG_FORMAT_UNKNOWN, 
IG_MP_OPEN_READ );
        nStartPage = 2;
        nCount = 4;
        nErrCount = IG_mpf_page_load( hMIGear, nStartPage, nCount );
}
if (!nErrCount)
{
        nErrCount = IG_mpi_close( hMIGear );
        if (!nErrCount)
            nErrCount = IG_mpi_file_open( "picture2.tif", hMIGear, IG_FORMAT_UNKNOWN,
IG_MP_OPEN_READWRITE );
    if (!nErrCount)
    nErrCount = IG_mpf_page_save( hMIGear, nStartPage, nCount,      
IG_COMPRESSION_JPEG, IG_MPF_SAVE_INSERT );
}
if (nErrCount)
{
        /* error handling */
#include "accucnst.h"
}

If a page from the pages to save is not a valid HIGEAR image, then this page is ignored during the save operation.

IG_MPF_SAVE_REPLACE mode is acceptable for filters that support the page deletion operation. This information can be obtained using the function IG_fltr_info_get(), and it should return the IG_FLTR_PAGEDELETESUPPORT flag, which is set in the dwInfoFlags parameters.

©2012. Accusoft Corporation. All Rights Reserved.