With ItextSharp
public void MergePDFs(string[] PoArchivos, string PsOutFile, string PsClave)
{
PoArchivos = OrdenarArchivosSegunClave(PoArchivos, PsClave);
Document LoDocument = new Document();
if(File.Exists(PsOutFile))
{
File.Delete(PsOutFile);
}
PdfCopy LoWriter = new PdfCopy(LoDocument, new FileStream(PsOutFile, FileMode.Create));
if (LoWriter == null)
{
return;
}
LoDocument.Open();
foreach (string fileName in PoArchivos)
{
PdfReader LoReader = new PdfReader(fileName);
LoReader.ConsolidateNamedDestinations();
for (int i = 1; i <= LoReader.NumberOfPages; i++)
{
PdfImportedPage page = LoWriter.GetImportedPage(LoReader, i);
LoWriter.AddPage(page);
}
LoReader.Close();
}
LoWriter.Close();
LoDocument.Close();
}