/// <summary>
/// 合并PDF文件
/// </summary>
/// <param name="inFiles">待合并文件列表</param>
/// <param name="outFile">合并生成的文件名称</param>
static
void
iTextSharpPdfMerge(List<String> inFiles, String outFile)
{
using
(var stream =
new
FileStream(outFile, FileMode.Create))
{
using
(var doc =
new
Document())
{
using
(var pdf =
new
PdfCopy(doc, stream))
{
doc.Open();
inFiles.ForEach(file =>
{
var reader =
new
PdfReader(file);
for
(
int
i = 0; i < reader.NumberOfPages; i++)
{
var page = pdf.GetImportedPage(reader, i + 1);
pdf.AddPage(page);
}
pdf.FreeReader(reader);
reader.Close();
});
}
}
}
}
本文出自:https://blog.csdn.net/u011108093/article/details/81916139