IRONSOFTWAREHOME
Copying Pages between PDF Files
from ironpdf import *
 
html_a = """<p> [PDF_A] </p>
        <p> [PDF_A] 1st Page </p>
        <div style='page-break-after: always;'></div>
        <p> [PDF_A] 2nd Page</p>"""

html_b = """<p> [PDF_B] </p>
        <p> [PDF_B] 1st Page </p>
        <div style='page-break-after: always;'></div>
        <p> [PDF_B] 2nd Page</p>"""

renderer = ChromePdfRenderer()

# Create our main document
pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)

# Create and select a page to copy
pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
page_to_insert = pdfdoc_b.CopyPage(1)

# 3 ways to insert:
pdfdoc_a.AppendPdf(page_to_insert)  # at the end
# or
pdfdoc_a.PrependPdf(page_to_insert)  # at the start
# or
pdfdoc_a.InsertPdf(page_to_insert, 1)  # in the middle

pdfdoc_a.SaveAs("CopiedPages.pdf")
pip install ironpdf
Copying Pages between PDF Files

Copying Pages between PDF Files

IronPDF for Python can copy pages from one PDF document and insert them into another at any position - at the end, the beginning, or a specific page index within the target document.

Getting Started

Create or load two PdfDocument objects. Use CopyPage to extract a specific page from the source document, then insert it into the target document using one of the three insertion methods.

Understanding the Code

  • CopyPage(index): Extracts a single page from a PdfDocument by its zero-based index. Returns a new single-page PdfDocument.
  • AppendPdf(page_to_insert): Adds the page to the end of the target document.
  • PrependPdf(page_to_insert): Adds the page to the beginning of the target document, before all existing pages.
  • InsertPdf(page_to_insert, index): Inserts the page at the specified zero-based position within the target document. In the example, index 1 inserts the page after the first page.

Inserting Multiple Pages

To copy and insert multiple pages at once, use CopyPages(start, end) instead of CopyPage, then insert the resulting multi-page document using the same AppendPdf, PrependPdf, or InsertPdf methods.

Learn to merge and edit PDF pages with IronPDF for Python!

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999