Skip to content

Instantly share code, notes, and snippets.

@OlafD
Created March 6, 2019 11:10
Show Gist options
  • Save OlafD/3878052b0f5c8b6bc565cf5d37173523 to your computer and use it in GitHub Desktop.
Save OlafD/3878052b0f5c8b6bc565cf5d37173523 to your computer and use it in GitHub Desktop.
Merge to pdf files from their stream objects into a MemoryStream using Aspose.Pdf.
static MemoryStream MergePdfDocuments(Stream pdf1, Stream pdf2)
{
MemoryStream result = null;
Aspose.Pdf.Document pdf1Document = new Aspose.Pdf.Document(pdf1);
Aspose.Pdf.Document pdf2Document = new Aspose.Pdf.Document(pdf2);
Aspose.Pdf.Document pdfResult = new Aspose.Pdf.Document();
pdfResult.Pages.Add(pdf1Document.Pages);
pdfResult.Pages.Add(pdf2Document.Pages);
result = new MemoryStream();
pdfResult.Save(result);
result.Position = 0;
pdf1Document.Dispose();
pdf2Document.Dispose();
pdfResult.Dispose();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment