-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDFMerge.cs
More file actions
29 lines (24 loc) · 724 Bytes
/
PDFMerge.cs
File metadata and controls
29 lines (24 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using File = Dotcore.FileSystem.File;
namespace ESCLScan;
public static class PDFMerge
{
public static void Merge(IEnumerable<File.Info> pdfs, File.Info destination)
{
using var destinationDocument = new PdfDocument();
foreach (var pdf in pdfs)
{
using var source = PdfReader.Open(pdf.Path, PdfDocumentOpenMode.Import);
CopyPages(source, destinationDocument);
}
destinationDocument.Save(destination.Path);
}
private static void CopyPages(PdfDocument from, PdfDocument to)
{
for (int i = 0; i < from.PageCount; i++)
{
to.AddPage(from.Pages[i]);
}
}
}