ImageGear for C and C++ on Windows v19.1 - Updated
IG_REC_PDF_page_populate
API Reference Guide > Recognition Component API Reference > Recognition Component Functions Reference > PDF Output Functions > IG_REC_PDF_page_populate

Populates an existing PDF page in a PDF document with recognized text and/or image.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_REC_PDF_page_populate(
   HIG_REC_IMAGE hImage,
   HMIGEAR hPDFDoc,
   HIG_PDF_PAGE hPDFPage,
   LPAT_REC_PDF_PAGE_OPTIONS lpOptions
);

Arguments:

Name Type Description
hImage HIG_REC_IMAGE Handle of the recognition image.
hPDFDoc HMIGEAR PDF document containing the page to populate.
hPDFPage HIG_PDF_PAGE PDF page to populate.
lpOptions LPAT_REC_PDF_PAGE_OPTIONS Page options. Pass NULL for lpOptions to use default options, which creates a PDF page containing the recognized image along with hidden text elements suitable for searching, highlighting, selection, copying and pasting, etc.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

See IG_REC_image_import.

Example:

 
Copy Code
AT_ERRCOUNT ErrCount = 0;
HIGEAR higImage = 0;
HIG_REC_IMAGE higRecImage = 0;
HMIGEAR hMPDoc = 0;
HIG_PDF_PAGE hPDFPage = 0;
AT_INT nPageCount = 0;
AT_REC_PDF_PAGE_OPTIONS Options;
AT_INT iPage = 0;
AT_DIB Dib;
AT_MODE pageComp;

memset(&Options, 0, sizeof(Options));
Options.VisibleImage = TRUE;

ErrCount += IG_PDF_initialize(NULL);
ErrCount += IG_mpi_create(&hMPDoc, 0);

ErrCount += IG_mpi_file_open("Test.pdf", hMPDoc,
        IG_FORMAT_PDF, IG_MP_OPENMODE_READWRITE);
ErrCount += IG_mpf_page_count_get(hMPDoc, &nPageCount);

ErrCount = IG_REC_primary_reduction_mode_set(IG_REC_IMG_CONVERSION_AUTO);

for (iPage=1; (iPage<=nPageCount) && (ErrCount == 0); iPage++)
{
    if(IG_image_is_valid(higImage))
        IG_image_delete(higImage);
    ErrCount += IG_mpf_page_get(hMPDoc, iPage-1, &higImage);

    if (higRecImage != NULL)
    {
        IG_REC_image_delete(higRecImage);
        higRecImage = NULL;
    }
    ErrCount += IG_REC_image_import(higImage, &higRecImage);
    ErrCount += IG_REC_image_recognize(higRecImage);
    ErrCount += IG_vector_data_get(higImage, (LPVOID*) &hPDFPage);

    ErrCount += IG_REC_PDF_page_populate(higRecImage, hMPDoc, hPDFPage, &Options);

    if(!ErrCount)
    {
        ErrCount += IG_mpf_page_info_get(hMPDoc, iPage-1, &pageComp, &Dib);
        ErrCount += IG_mpf_page_save(hMPDoc, iPage-1, 1, pageComp, IG_MPF_SAVE_REPLACE);
    }
}

ErrCount += IG_mpi_delete(hMPDoc);
ErrCount += IG_REC_image_delete(higRecImage);
ErrCount += IG_image_delete(higImage);
ErrCount += IG_PDF_terminate();

Remarks:

The content of the existing PDF page is preserved and supplemented.

See Also

HIG_REC_IMAGE