2025 AI Readiness Report: Survey Insights on Enterprise AI Maturity – Now Available!

Split, Merge, and Insert Pages in a PDF Using C++

By Garry Klooesterman | 2025 Apr 24

Sanity Image
Read time

5 min

Summary: PDFs are a great way to share information quickly and easily as they can be opened on practically any device and display the same as the original regardless of the hardware or software used to view them. Manipulating PDFs, on the other hand, can be challenging, especially for more complex tasks like merging PDFs or inserting pages. In this blog, we’ll look at automating these and other PDF manipulation tasks using a PDF SDK such as the Apryse SDK.

Introduction

Copied to clipboard

PDFs are a common and convenient way to share information. They’re easy to use, versatile, secure, compact, and the list goes on. Manipulating PDFs, on the other hand, isn’t always so convenient. For example, large PDFs can be taxing on system resources and difficult to handle, let alone trying to merge PDFs or insert pages.

You could use a PDF editor such as xodo.com or Xodo PDF Studio to handle these and other tasks. App based editors like Apryse WebViewer can also be used, but there would still be some manual element to the process.

If you’re looking for an automated solution, you can use a PDF Manipulation library like the one included with the Apryse SDK. In this blog, we’ll use C++ for the examples, but the SDK is available for other popular languages and frameworks as well including Go, Java, Python and Node.js.

How to Get Started

Copied to clipboard

Follow these instructions to get started.

  1. First, you’ll need to download the Apryse Server SDK. In this case, choose the C++ PDF library.
  2. Next, follow these steps to extract the folder from the .zip file.
  3. Now you’ll want to get a free trial key, if you don’t already have one.
  4. The last step for getting started is to see our documentation for the full code you’ll need to support the following example tasks. I’ve included a sample of the specific code for each task based on our demo.

Now that you’re ready to go, let’s look at some of the ways we can manipulate PDFs using the Apryse SDK. In this blog, we’ll look at how to:

  • Split a PDF into multiple pages
  • Merge several PDFs into one
  • Insert a page from one PDF to another PDF

Split a PDF into Multiple Pages

Copied to clipboard

Let’s look at an example of when you might want to split a PDF into separate pages. You’re working on this month’s stats reports for your team and due to a spacing issue, the system generated a report with a blank page after every employee section. You now have a report with extra blank pages that need to be removed. You can split the PDF report into separate pages using the following code.

Merge Several PDFs into One

Copied to clipboard

You now have the report split into separate pages and you’ve weeded out the blanks. After sorting the pages of employee stats, you’re ready to create the new report. You can use the following code to merge the pages into one report.

Insert a Page from One PDF to Another PDF

Copied to clipboard

You’ve got your report ready to go when you remember the latest memo about stat reports needing a bio page added for each employee. Since you already have the bio pages in another PDF, you can use the following code to insert those pages throughout the new report.

Other Examples

Copied to clipboard

If you’re looking for more examples of what you can do with the code in this SDK, check out the documentation. You’ll find sample code for removing a page, cropping a page, and more.

Conclusion

Copied to clipboard

As we’ve seen already, there’s many ways to manipulate a PDF using a PDF Manipulation Library like the Apryse PDF SDK. These examples show the basics of what can be done and how easy it is to get started. You can even use the code for inspiration and a base for creating more robust functions for complex PDF manipulation tasks.

Try it out for yourself with our free trial.

Get started now or contact our sales team for any questions. You can also check out our Discord community for support and discussions.

Sanity Image

Garry Klooesterman

Senior Technical Content Creator

Share this post

email
linkedIn
twitter