Splitting PDF files into separate pages or groups of pages is a common task in software development. This may be necessary for processing large documents, organizing content, or optimizing data management. In this article, we will look at how you can split PDF files into separate pages or groups of pages using C# and .NET.
To complete the task of splitting PDF files, we will need to perform the following steps:
Полный код
using System;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;
using System.Linq;
using SautinSoft.Pdf.Facades;
namespace Sample
{
class Sample
{
/// <summary>
/// Split PDF files in C# and .NET.
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/split-pdf-files.php
/// </remarks>
static void Main(string[] args)
{
// Before starting this example, please get a free 100-day trial key:
// https://sautinsoft.com/start-for-free/
// Apply the key here:
// PdfDocument.SetLicense("...");
// Split PDF document by pages.
// The each page will be saves as a separate PDF file: "Page 0.pdf", "Page 1.pdf" ...
// Can work with relative and absolute paths.
PdfSplitter.Split(@"..\..\..\005.pdf", PdfLoadOptions.Default, 0,
int.MaxValue, (pageInd) => $"Page {pageInd}.pdf");
// The last parameter is "Func" to generate the output file name.
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"Page 0.pdf") { UseShellExecute = true });
}
}
}
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу [email protected] или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: