Разделить 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.
Как разделить PDF
Чтобы разделить PDF‑документ на отдельные страницы, выполните следующие шаги:
- Создайте экземпляр
SplitOptionsдля настройки параметров разделения. - Добавьте входной PDF‑файл с помощью метода
AddInput. - Добавьте выходные файлы для каждой разбитой страницы с помощью метода
AddOutput. - Вызовите метод
SplitклассаPdfManagerдля выполнения разделения PDF‑документа.
1```csharp
2// Create SplitOptions object to configure the operation
3var options = new SplitOptions();
4// Add input file path
5options.AddInput(new FileDataSource("path_to_your_pdf_file.pdf"));
6// Specify output PDF file paths
7options.AddOutput(new FileData("path_to_result_pdf_file_1.pdf"));
8options.AddOutput(new FileData("path_to_result_pdf_file_2.pdf"));
9// Perform the process
10PdfManager.Split(options);
11```Как разделить PDF с использованием потоков
Чтобы разделить PDF‑документ с помощью потоков, выполните следующие шаги:
- Подготовьте входные и выходные потоки.
- Создайте экземпляр
SplitOptionsдля настройки процесса разделения. - Добавьте входной PDF‑поток с помощью метода
AddInput. - Укажите выходные PDF‑потоки с помощью метода
AddOutput. - Установите свойство
CloseOutputStreamsвfalse, если выходные потоки должны оставаться открытыми после операции. - Вызовите метод
SplitклассаPdfManagerдля выполнения операции разделения.
1```csharp
2// Prepare input and output streams
3using var inputStream = File.OpenRead("path_to_your_pdf_file.pdf");
4using var outputStream1 = new MemoryStream();
5using var outputStream2 = new MemoryStream();
6
7// Create SplitOptions object to configure the operation
8var options = new SplitOptions();
9// Add input stream
10options.AddInput(inputStream);
11// Specify output PDF streams
12options.AddOutput(outputStream1);
13options.AddOutput(outputStream2);
14// Prevent the closing of output streams
15options.CloseOutputStreams = false;
16// Perform the process
17PdfManager.Split(options);
18```Ключевые особенности:
- 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.