linkedinfacebooktwittermenuarrow-up

GemBox Support Forum

How to append multilple stream array with one PDF File Using Gembox.Document

Hi Team,

I am currently working on binding multiple stream array with one document pdf. How to append multilple stream array with one PDF File Using Gembox.Document. Please help me on this.

Hi,

Please check our Combining example.
The example shows how to merge files from a string array, but you can use the same to merge files from a stream array as well.

What does your stream array hold, are those streams from PDF files or from Word files?
If they are from PDF files, then you could use something like this:

Stream[] streams = ...
var destination = new DocumentModel();

foreach (var stream in streams)
{
    var source = DocumentModel.Load(stream, new PdfLoadOptions() { LoadType = PdfLoadType.HighFidelity });
    destination.Content.End.InsertRange(source.Content);
}

destination.Save("Merged Files.pdf");

However, for merging multiple PDF files into one we recommend using GemBox.Pdf instead of GemBox.Document.
Please check our Merge Files example.

I hope this helps.

Regards,
Mario