string[] sourceFilesPath = new string[] {
@"C:\source\1.pdf",
@"C:\source\2.pdf",
@"C:\source\3.pdf"};
string mergedFilePath = @"C:\merge\merge123.pdf";
using (Document document = new Document(PageSize.A4, 0, 0, 0, 0)) {
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(mergedFilePath, FileMode.Create));
PdfReader.unethicalreading = true;
document.Open();
sourceFilesPath
.Select(file => new PdfReader(file))
.SelectMany(reader =>
Enumerable.Range(1, reader.NumberOfPages).Select(page => writer.GetImportedPage(reader, page)))
.ToList().ForEach(page => document.Add(iTextSharp.text.Image.GetInstance(page)));
}
@"C:\source\1.pdf",
@"C:\source\2.pdf",
@"C:\source\3.pdf"};
string mergedFilePath = @"C:\merge\merge123.pdf";
using (Document document = new Document(PageSize.A4, 0, 0, 0, 0)) {
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(mergedFilePath, FileMode.Create));
PdfReader.unethicalreading = true;
document.Open();
sourceFilesPath
.Select(file => new PdfReader(file))
.SelectMany(reader =>
Enumerable.Range(1, reader.NumberOfPages).Select(page => writer.GetImportedPage(reader, page)))
.ToList().ForEach(page => document.Add(iTextSharp.text.Image.GetInstance(page)));
}