How to Split PDF to Multiple Documents
PDF is recognized as the most secure and dependable format around the world. Most of us keep many of our files in the PDF format especially those that we need to send over the internet. Once a file saved as PDF format, it can not be edited. Layout, formatting, images and everything else are protected. However sometimes we have to face a problem that we may just want to share a part of a PDF to others. So people who use PDF frequently may often meet questions like how to split a PDF file into multiple documents.
Adobe Acrobat supports splitting PDF document into multiple documents. But here we will introduce another solution to split PDF document - C# split PDF.
How to Use C# to Split PDF into Multiple Documents
Spire.PDF can help us easily merge multiple PDF documents into one. Vice versa it can help us split PDF into multiple documents effortlessly either.
Download Spire.PDF Here
Make sure Spire.PDF and Visual Studio are correctly installed on system. Follow the simple guide below to split PDF into multiple documents.
Step 1 Create Project
Create a C# project in Visual Studio and Add Spire.Pdf.dll as reference. The default setting of Spire.Pdf.dll is placed under "C:\Program Files\e-iceblue\Spire.Pdf\Bin”. Select assembly Spire.Pdf.dll and click OK to add it to the project.
using System;
using Spire.Pdf;
namespace SplitPDF
{
class Program
{
static void Main(string[] args)
{
}
}
}
Step 2 Open PDF Document
Open the PDF document which we need spilt to multiple PDF documents
//open pdf document
PdfDocument doc = new PdfDocument(@"..\..\Sample.pdf");
Step 3 Split PDF Document
We can split PDF document according to PDF pages. If a PDF document has 7 pages, we can split the PDF into 7 PDF documents.
String pattern = "SplitDocument-{0}.pdf";
doc.Split(pattern);
String lastPageFileName
= String.Format(pattern, doc.Pages.Count - 1);
doc.Close();
Step 4 Preview
The code below can help us preview the last PDF document which was split out from the original PDF file.
//Launching the Pdf file.
System.Diagnostics.Process.Start(lastPageFileName);
After start the project we will find out the split PDF documents in the project bin-> debug folder.
Adobe Acrobat supports splitting PDF document into multiple documents. But here we will introduce another solution to split PDF document - C# split PDF.
How to Use C# to Split PDF into Multiple Documents
Spire.PDF can help us easily merge multiple PDF documents into one. Vice versa it can help us split PDF into multiple documents effortlessly either.
Download Spire.PDF Here
Make sure Spire.PDF and Visual Studio are correctly installed on system. Follow the simple guide below to split PDF into multiple documents.
Step 1 Create Project
Create a C# project in Visual Studio and Add Spire.Pdf.dll as reference. The default setting of Spire.Pdf.dll is placed under "C:\Program Files\e-iceblue\Spire.Pdf\Bin”. Select assembly Spire.Pdf.dll and click OK to add it to the project.
using System;
using Spire.Pdf;
namespace SplitPDF
{
class Program
{
static void Main(string[] args)
{
}
}
}
Step 2 Open PDF Document
Open the PDF document which we need spilt to multiple PDF documents
//open pdf document
PdfDocument doc = new PdfDocument(@"..\..\Sample.pdf");
Step 3 Split PDF Document
We can split PDF document according to PDF pages. If a PDF document has 7 pages, we can split the PDF into 7 PDF documents.
String pattern = "SplitDocument-{0}.pdf";
doc.Split(pattern);
String lastPageFileName
= String.Format(pattern, doc.Pages.Count - 1);
doc.Close();
Step 4 Preview
The code below can help us preview the last PDF document which was split out from the original PDF file.
//Launching the Pdf file.
System.Diagnostics.Process.Start(lastPageFileName);
After start the project we will find out the split PDF documents in the project bin-> debug folder.
More about Spire.PDF:
Spire.PDF can be used on the server-side (ASP.NET or any other environment) or with Windows Forms applications. Click to learn more…
Spire.PDF can be used on the server-side (ASP.NET or any other environment) or with Windows Forms applications. Click to learn more…