Cómo agregar, copiar y eliminar páginas en PDFs usando C#

How to Add, Copy, and Delete Pages in PDFs

This article was translated from English: Does it need improvement?
Translated
View the article in English

Adding pages to a PDF involves the insertion of new content, like text, images, or existing PDF pages, into the document. Copying pages in a PDF means duplicating one or more pages within the same document or from one PDF file to another. Deleting pages from a PDF involves the removal of unwanted pages from the document.

Quickstart: Add, Copy, and Delete PDF Pages Instantly

Get started with IronPDF to seamlessly add, copy, and delete pages in your PDFs. This quick example shows how you can merge additional content into an existing PDF with ease. By leveraging IronPDF's efficient methods, developers can manage PDF pages with minimal effort, ensuring a smooth integration into any C# project.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    IronPdf.PdfDocument.FromFile("/input/path.pdf")
        .AppendPdf(IronPdf.PdfDocument.FromFile("/additional/path.pdf"))
        .SaveAs("/output/path.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

Add Pages to a PDF

Adding a page to a PDF can be done in one line of code. In this example, a PDF of a report is generated and a cover page will be added to the start of it. To combine both PDFs, the Merge method is used. Let's take these two PDF documents for our example: download coverPage.pdf and download contentPage.pdf.

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-add.cs
using IronPdf;

// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");

// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");

// Merge the two documents
PdfDocument finalPdf = PdfDocument.Merge(coverPage, contentPage);

finalPdf.SaveAs("pdfWithCover.pdf");
Imports IronPdf

' Import cover page
Private coverPage As PdfDocument = PdfDocument.FromFile("coverPage.pdf")

' Import content document
Private contentPage As PdfDocument = PdfDocument.FromFile("contentPage.pdf")

' Merge the two documents
Private finalPdf As PdfDocument = PdfDocument.Merge(coverPage, contentPage)

finalPdf.SaveAs("pdfWithCover.pdf")
$vbLabelText   $csharpLabel

When we run the code above, we get a single PDF file as output, which has the cover page at the front:

We can also add a page at any index of the PDF using the InsertPdf method. In this example, I achieve the above effect by inserting 'coverPage.pdf' at the beginning of 'contentPage.pdf'.

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-insert.cs
using IronPdf;

// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");

// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");

// Insert PDF
contentPage.InsertPdf(coverPage, 0);
Imports IronPdf

' Import cover page
Private coverPage As PdfDocument = PdfDocument.FromFile("coverPage.pdf")

' Import content document
Private contentPage As PdfDocument = PdfDocument.FromFile("contentPage.pdf")

' Insert PDF
contentPage.InsertPdf(coverPage, 0)
$vbLabelText   $csharpLabel

Copy Pages from a PDF

To copy pages from a PDF, simply call either the CopyPage or CopyPages methods. These are used to copy single and multiple pages, respectively. The methods return the PdfDocument object containing the specified pages.

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-copy.cs
using IronPdf;
using System.Collections.Generic;

// Copy a single page into a new PDF object
PdfDocument myReport = PdfDocument.FromFile("report_final.pdf");
PdfDocument copyOfPageOne = myReport.CopyPage(0);

// Copy multiple pages into a new PDF object
PdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
Imports IronPdf
Imports System.Collections.Generic

' Copy a single page into a new PDF object
Private myReport As PdfDocument = PdfDocument.FromFile("report_final.pdf")
Private copyOfPageOne As PdfDocument = myReport.CopyPage(0)

' Copy multiple pages into a new PDF object
Private copyOfFirstThreePages As PdfDocument = myReport.CopyPages(New List(Of Integer) From {0, 1, 2})
$vbLabelText   $csharpLabel

Delete Pages in a PDF

To delete pages from a PDF, you can call either the RemovePage or RemovePages methods. These are used to delete single and multiple pages, respectively.

:path=/static-assets/pdf/content-code-examples/how-to/add-copy-delete-pages-pdf-delete.cs
using IronPdf;
using System.Collections.Generic;

PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");

// Remove a single page
pdf.RemovePage(0);

// Remove multiple pages
pdf.RemovePages(new List<int> { 2, 3 });
Imports IronPdf
Imports System.Collections.Generic

Private pdf As PdfDocument = PdfDocument.FromFile("full_report.pdf")

' Remove a single page
pdf.RemovePage(0)

' Remove multiple pages
pdf.RemovePages(New List(Of Integer) From {2, 3})
$vbLabelText   $csharpLabel

Ready to see what else you can do? Check out our tutorial page here: Organize PDFs

Preguntas Frecuentes

¿Cómo puedo agregar una portada a un informe PDF en C#?

Puedes agregar una portada a un informe PDF usando el método Merge para combinar el PDF de la portada con tu informe existente en C#.

¿Cuál es el método para insertar páginas en un índice específico en un PDF?

Para insertar páginas en un índice específico en un PDF, usa el método InsertPdf, que te permite especificar la posición exacta donde se debe insertar la nueva página.

¿Cómo duplico páginas dentro de un PDF usando C#?

Para duplicar páginas dentro de un PDF usando C#, utiliza el método CopyPage para páginas individuales o el método CopyPages para múltiples páginas para crear copias de las páginas deseadas.

¿Qué pasos debo seguir para eliminar páginas no deseadas de un PDF en C#?

Para eliminar páginas no deseadas de un PDF en C#, utiliza el método RemovePage para páginas individuales o el método RemovePages para múltiples páginas para eliminarlas del documento.

¿Puedo guardar un PDF modificado después de realizar cambios como agregar o eliminar páginas?

Sí, después de realizar cambios como agregar o eliminar páginas, puedes guardar el PDF modificado usando el método SaveAs para almacenar el documento actualizado.

¿Cuáles son los requisitos previos para manipular páginas de PDF en un proyecto C#?

Para manipular páginas de PDF en un proyecto C#, primero descarga la biblioteca IronPDF desde NuGet e intégrala en tu proyecto para acceder a la funcionalidad necesaria.

¿Es posible fusionar dos documentos PDF en uno usando C#?

Sí, puedes fusionar dos documentos PDF en uno usando el método Merge, que combina múltiples archivos PDF en un único documento.

¿Cómo puedo agregar rápidamente páginas a un PDF en C#?

Para agregar rápidamente páginas a un PDF en C#, utiliza el método Merge para añadir nuevos documentos PDF o el método InsertPdf para insertar páginas en índices específicos.

¿Qué lenguaje de programación se utiliza para el tutorial de manipulación de PDF?

El tutorial para manipular páginas de PDF utiliza C# para demostrar cómo agregar, copiar y eliminar páginas de PDF programáticamente.

¿IronPDF admite .NET 10 al agregar, copiar o eliminar páginas en archivos PDF?

Sí — IronPDF es totalmente compatible con .NET 10 para todas las tareas de manipulación de páginas (añadir, copiar, eliminar). Es compatible de fábrica con proyectos .NET 10, lo que garantiza que pueda usar los mismos métodos de página sin necesidad de soluciones alternativas.

Jordi Bardia
Ingeniero de Software
Jordi es más competente en Python, C# y C++. Cuando no está aprovechando sus habilidades en Iron Software, está programando juegos. Compartiendo responsabilidades para pruebas de productos, desarrollo de productos e investigación, Jordi agrega un valor inmenso a la mejora continua del producto. La experiencia variada lo mantiene ...
Leer más
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado