Split PDF
The Documentize PDF Manager for .NET is a powerful tool that simplifies the process of splitting large PDF documents into smaller, more manageable files. Whether you need to extract individual pages or divide a document into specific sections, this component allows you to achieve it efficiently and with minimal effort.
How to Split PDF
To split a PDF document into individual pages, follow these steps:
- Create an instance of
SplitOptionsto configure the splitting options. - Add the input PDF file using the
AddInputmethod. - Add output files for each split page using the
AddOutputmethod. - Call the
Splitmethod of the PdfManager class to split the PDF document.
1// Create SplitOptions object to configure the operation
2var options = new SplitOptions();
3// Add input file path
4options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
5// Specify output PDF file paths
6options.AddOutput(new FileData("path_to_result_pdf_file_1.pdf"));
7options.AddOutput(new FileData("path_to_result_pdf_file_2.pdf"));
8// Perform the process
9PdfManager.Split(options);How to Split PDF using Streams
To split a PDF document using streams, follow these steps:
- Prepare input and output streams.
- Create an instance of
SplitOptionsto configure the splitting process. - Add the input PDF stream using the
AddInputmethod. - Specify output PDF streams using the
AddOutputmethod. - Set the
CloseOutputStreamsproperty tofalseif the output streams need to remain open after the operation. - Call the
Splitmethod of thePdfManagerclass to perform the split operation.
1// Prepare input and output streams
2using var inputStream = File.OpenRead("path_to_your_pdf_file.pdf");
3using var outputStream1 = new MemoryStream();
4using var outputStream2 = new MemoryStream();
5
6// Create SplitOptions object to configure the operation
7var options = new SplitOptions();
8// Add input stream
9options.AddInput(inputStream);
10// Specify output PDF streams
11options.AddOutput(outputStream1);
12options.AddOutput(outputStream2);
13// Prevent the closing of output streams
14options.CloseOutputStreams = false;
15// Perform the process
16PdfManager.Split(options);Key Features:
- Split PDF by Page: Break down a PDF document into individual pages.
- Custom Split Options: Configure the splitting process based on your requirements.
- Organized Output: Easily manage the output files for each split page or section.