ImageGear Professional v18 for Mac
IG_PDF_doc_insert_pages

This function inserts nPageCount pages from hDoc2 into hDoc.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_PDF_doc_insert_pages(
        HIG_PDF_DOC hDoc,
        LONG nAfterThisPage,
        HIG_PDF_DOC hDoc2,
        LONG nStartPage,
        LONG nPageCount,
        WORD nInsertFlags
);

Arguments:

Name Type Description
hDoc HIG_PDF_DOC The document into which pages are inserted.
nAfterThisPage LONG The page number in hDoc after which pages from hDoc2 are inserted. The first page is 0. If IG_PDF_BEFORE_FIRST_PAGE is used, the pages are inserted before the first page in hDoc . Use IG_PDF_LAST_PAGE to insert pages after the last page in hDoc.
hDoc2 HIG_PDF_DOC The document containing the pages that are inserted into hDoc.
nStartPage LONG The page number of the first page in hDoc2 to insert into hDoc. The first page is 0.
nPageCount LONG The number of pages in hDoc2 to insert into hDoc. Use IG_PDF_ALL_PAGES to insert all pages from hDoc2 into hDoc.
nInsertFlags WORD Flags that determine what additional information is copied from hDoc2 into hDoc. An OR of enumIGPDFInsertFlags constants:
  • IG_PDF_INSERT_BOOKMARKS - Inserts bookmarks as well as pages. The bookmark tree of hDoc2 is merged into the bookmark tree of hDoc by copying it as a new first-level sub-tree of hDoc's bookmark tree root of which it becomes the last child. If hDoc has no bookmark tree, it acquires one identical to the bookmark tree from hDoc2.
  • IG_PDF_INSERT_THREADS - Inserts threads as well as pages.
  • IG_PDF_INSERT_ALL - Inserts all pages, regardless of nStartPage and nPageCount, and document data.

Return Value:

Error count.

Supported Raster Image Formats:

This function does not process image pixels.

Example:

 
Copy Code

AT_CHAR*     first_filename      = "first.pdf" ;
UINT         first_page_count    = 0 ;
HMIGEAR      first_hmigear       = 0 ;
HIG_PDF_DOC  first_hig_pdf_doc   = 0 ;

AT_CHAR*     second_filename     = "second.pdf" ;
UINT         second_page_count   = 0 ;
HMIGEAR      second_hmigear      = 0 ;
HIG_PDF_DOC  second_hig_pdf_doc  = 0 ;

AT_CHAR*     combined_filename   = "combined.pdf" ;
UINT         combined_page_count = 0 ;

/* Open first PDF */
IG_mpi_create( &first_hmigear , 0 ) ;
IG_mpi_file_open( first_filename, first_hmigear, IG_FORMAT_UNKNOWN,
                    IG_MP_OPENMODE_READONLY ) ;
IG_PDF_doc_create( first_hmigear ) ;   
IG_mpi_info_get( first_hmigear, IG_MP_DOCUMENT, &first_hig_pdf_doc,
                    sizeof( first_hig_pdf_doc ) ) ;
IG_mpi_page_count_get( first_hmigear, &first_page_count ) ;

/* Open second PDF */
IG_mpi_create( &second_hmigear , 0 ) ;
IG_mpi_file_open( second_filename , second_hmigear, IG_FORMAT_UNKNOWN,
                    IG_MP_OPENMODE_READONLY) ;
IG_PDF_doc_create( second_hmigear ) ;
IG_mpi_info_get( second_hmigear, IG_MP_DOCUMENT, &second_hig_pdf_doc,
                    sizeof(second_hig_pdf_doc) ) ;
IG_mpi_page_count_get( second_hmigear, &second_page_count ) ;

/* Insert pages */
IG_PDF_doc_insert_pages( second_hig_pdf_doc , IG_PDF_LAST_PAGE,
                    first_hig_pdf_doc , 0 , first_page_count , IG_PDF_INSERT_ALL ) ;

/* Save combined PDF document */
combined_page_count = first_page_count + second_page_count ;   
IG_mpi_file_save( combined_filename , second_hmigear, 0 , 0, combined_page_count ,
                    IG_FORMAT_PDF , IG_MPI_SAVE_OVERWRITE ) ;

IG_mpi_close( first_hmigear ) ;
IG_mpi_delete( first_hmigear ) ;
IG_mpi_close( second_hmigear ) ;
IG_mpi_delete( second_hmigear ) ;

Remarks:

All annotations, and anything else associated with the page (such as a thumbnail image) are copied from the hDoc2 pages to the new pages in hDoc. This function does not insert pages, if hDoc is equal to hDoc2. The nInsertFlags controls whether bookmarks and threads are inserted along with the specified pages.

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback