ImageGear for C and C++ on Linux v20.0 - Updated
IG_mpi_file_save
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Multi Page Image Functions > IG_mpi_file_save

Use this function to save a multi-page vector document to a file.

Declaration:

 
Copy Code
AT_ERRCOUNT LACCUAPI IG_mpi_file_save(
        [IN] const LPCHAR lpFileName,
        [IN] HMIGEAR hMIGear,
        [IN] UINT nStartPageFile,
        [IN] UINT nStartIndexDoc,
        [IN] UINT nPageCount,
        [IN] AT_MODE nFormat,
        [IN] AT_MODE nSaveMode
);

Arguments:

Name Type Description
lpFileName const LPCHAR Output file name.
hMIGear HMIGEAR Multi-page vector document.
nStartPageFile UINT When nSaveMode is IG_MPI_SAVE_APPEND, specifies the page number in the output file after which pages from hMIGear are inserted. The first page is 0. Set nStartPageFile to -1 to append pages after the last page of the existing document.
nStartIndexDoc UINT The page number of the first page in hMIGear to save. The first page is 0.
nPageCount UINT Total number of pages to save.
nFormat AT_MODE IG_FORMAT_PDF or IG_FORMAT_POSTSCRIPT.
nSaveMode AT_MODE IG_MPI_SAVE_OVERWRITE or IG_MPI_SAVE_APPEND.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Example:

 
Copy Code
HMIGEAR hMIGear; /* handle to multi-page image */
AT_ERRCOUNT nErrCount = IGE_SUCCESS; /* will hold returned error count */
UINT pageCount;
nErrCount = IG_mpi_create( &hMIGear, 0 );

if (!nErrCount)
nErrCount = IG_mpi_file_open( "input.pdf", hMIGear, 0, IG_MP_OPENMODE_READWRITE );

nErrCount = IG_mpi_page_count_get(hMIGear, &pageCount);

if (!nErrCount)
nErrCount = IG_mpi_file_save("output.pdf", hMIGear, -1, 0, pageCount, IG_FORMAT_PDF, IG_MPI_SAVE_OVERWRITE);

nErrCount = IG_mpi_delete( hMIGear );

Remarks:

This function is only used for multi-page vector documents. The following formats are currently supported by this API: PDF, PostScript.

Two saving modes are currently supported: IG_MPI_SAVE_OVERWRITE and IG_MPI_SAVE_APPEND. These modes define how to process pages if lpFileName points to an existing file of the same type. If no file exists with a given file name, then nStartPageFile and nSaveMode are ignored, and the function saves pages to a new file.

IG_MPI_SAVE_OVERWRITE means that all pages in existing file should be removed, and pages from hMIGear should be placed instead. In this mode nStartPageFile parameter is ignored, because no original pages are left in the file.

IG_MPI_SAVE_APPEND means that pages from hMIGear should be either appended or inserted into the document, depending on nStartPageFile parameter.

In both save modes, if nStartIndexDoc is out of hMIGear pages range, or nStartIndexDoc + nPageCount is out of hMIGear pages range, a "Bad Parameter" error is thrown.

Is this page helpful?
Yes No
Thanks for your feedback.