Разделить 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‑документ на отдельные страницы, выполните следующие шаги:

  1. Создайте экземпляр SplitOptions для настройки параметров разделения.
  2. Добавьте входной PDF‑файл с помощью метода AddInput.
  3. Добавьте выходные файлы для каждой разбитой страницы с помощью метода AddOutput.
  4. Вызовите метод 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‑документ с помощью потоков, выполните следующие шаги:

  1. Подготовьте входные и выходные потоки.
  2. Создайте экземпляр SplitOptions для настройки процесса разделения.
  3. Добавьте входной PDF‑поток с помощью метода AddInput.
  4. Укажите выходные PDF‑потоки с помощью метода AddOutput.
  5. Установите свойство CloseOutputStreams в false, если выходные потоки должны оставаться открытыми после операции.
  6. Вызовите метод 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.
 Русский