Split a Multi-Page Document into a Single PDF
Splitting a multi-page PDF document into separate PDFs, each containing one page, can be done with just a couple of lines of code. See our example to implement it in your project.
With IronPDF, it is very easy to split a single PDF document into multiple documents, each containing only one page.
Get started with IronPDF
Start using IronPDF in your project today with a free trial.
Split a PDF Document
Split a Multipage PDF
Now that you have IronPDF, you can take a multipage document and split it into single-page document files. The idea of splitting a multipage PDF involves copying a single or multiple pages using the CopyPage
or CopyPages
method.
:path=/static-assets/pdf/content-code-examples/how-to/split-multipage-pdf-split-pdf.cs
using IronPdf;
// Load a PDF document from a file
PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");
// Iterate through each page in the document
for (int idx = 0; idx < pdf.PageCount; idx++)
{
// Create a new document containing only the current page
PdfDocument outputDocument = pdf.CopyPage(idx);
// Define the file name for the single-page PDF
string fileName = $"multiPage - Page {idx + 1}_tempfile.pdf";
// Save the single-page document to a new file
outputDocument.SaveAs(fileName);
}
Imports IronPdf
' Load a PDF document from a file
Private pdf As PdfDocument = PdfDocument.FromFile("multiPage.pdf")
' Iterate through each page in the document
For idx As Integer = 0 To pdf.PageCount - 1
' Create a new document containing only the current page
Dim outputDocument As PdfDocument = pdf.CopyPage(idx)
' Define the file name for the single-page PDF
Dim fileName As String = $"multiPage - Page {idx + 1}_tempfile.pdf"
' Save the single-page document to a new file
outputDocument.SaveAs(fileName)
Next idx
Looking at the code above, you can see that it uses a for
loop to iterate through the current PDF document's pages, then uses the CopyPage
method to copy each page into a new PdfDocument object. Finally, each page is exported as a new document named sequentially.
Frequently Asked Questions
How can I split a multipage PDF into single-page documents?
You can split a multipage PDF into single-page documents using IronPDF by using the CopyPage method. Load the original PDF, iterate through each page, and save each page as a separate PDF.
What is the first step to split a PDF in a C# project?
The first step is to install the IronPDF library in your C# project.
What methods are used to copy pages for splitting PDFs?
The methods used to copy pages in IronPDF are CopyPage and CopyPages.
Can I split a PDF into multiple single-page PDFs using a for loop?
Yes, you can use a for loop to iterate through the pages of the original PDF and copy each page into a new PdfDocument object.
What is an example of saving a single page as a new PDF document?
After copying a page, you can save it as a new document using singlePagePdf.Save($"single-page-{pageIndex + 1}.pdf").
Do I need to write a lot of code to split a PDF?
No, splitting a PDF with IronPDF can be done with just a couple of lines of code.
Is it necessary to have a separate PDF for each page when splitting?
Yes, each page from the original multipage PDF is saved as a separate single-page PDF document.
What programming language is used for splitting PDFs in the example?
The example provided uses C# to split PDFs with IronPDF.