How can I split and merge PDF using PDFNet?

Q: How can i split one large PDF file into small files?
How can i merge many small PDF files into one large file?
A: All of the page splitting and merging operations can be implemented
using pdfdoc.ImportPages(pages) and pdfdoc.PagePushBack(page) methods.

To merge many small PDF documents into a single PDF document open each
input PDFDoc, then import the pages (using target_doc.ImportPages()),
then insert the imported pages in the page sequence of the target PDF

There are couple of ways you could implement PDF splitting using

- Create a new PDFDoc and import a page or a subset of pages in the
new document (using pdfdoc.ImportPages()/PagePushBack()), then save
and close the new document.

- Remove all unnecessary pages, then save and close the PDFDoc. This
approach may be better if you only need to remove a small number of
pages (such as a cover page) or you need to preserve custom metadata
located on the document level.

For sample code showing how to implement split and merge operations,
please take a look at the last code snippet in PDFPage sample project: This code snippet
is using pdfdoc.ImportPages() to preserve shared resources between
pages (e.g. images, fonts, color spaces, etc). ImportPages also allows
an optional boolean parameter that can be used to specify whether
active bookmarks pointing to a given set of pages should be preserved
during the import operation.

For more information about implementing PDF split and merge you may
want to take a look at the following link
( Please keep in
mind that the article is referring to PDFNet v3.x API which had some
differences related to the way pages were accessed (please see for specific API changes).

In case you are looking for a more easy to use API to split and merge
PDF, you may want to take a look at PDF PageMaster (
pagemaster) which is a available as a SDK and a command-line
application. PageMaster itself is built using the above PDFNet API.