Thank you for your hints. It's obvious that an approach with MemoryStream objects could lead to higher memory consumption. But even if you keep 1 or 2 PDF files and the resulting file in memory we could live with that.
Maybe you can provide a merge method like Merge(string fileName1, MemoryStream file2) as well?
Why should the binary approach be faster? I found out, that the fastest way is to have all files to be merged in an array of type PdfDocument and use the method Merge(params PdfDocument[] docs). But in this case the memory consumption is highest as well.
So far we used the same method but each time with two PdfDocuments only.
Simplified like this:
Code: C#
var pdfFile = new PdfDocument(stream);
pdfFile = PdfDocument.Merge(pdfFile, new PdfDocument(fileName1));
pdfFile = PdfDocument.Merge(pdfFile, new PdfDocument(fileName2));
...
As I wrote this old code can (luckily) be rewritten to use the incremental merge. I just need to save the first file (here as a stream) to disk.