We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Attach Pdf from MEmoryStream

I have 2 MemoryStreams (ms1 and ms2), how to create a Pdf from those MemoryStream?

MemoryStream ms1 = new MemoryStream();
myReport1.ExportPdfToMemoryStream(ms1); // --> Pdf memorystream

MemoryStream ms2 = new MemoryStream();
myReport2.ExportPdfToMemoryStream(ms2); // --> Pdf memorystream

I need to attach ms2 to ms1 then create a .Pdf from it.

Please help


You are importing a PDF document to MemoryStream object. Please note, Document class object in the Aspose.Pdf for .NET API presents a PDF document and you can import an existing PDF document with the local PDF file path string or MemoryStream object. The Save method of the Document class allows to export a Document class object in the PDF format. Please try the following code:


Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
doc.Pages.Add().Paragraphs.Add(new Aspose.Pdf.Text.TextFragment("Hello World"));
MemoryStream ms1 = new MemoryStream();

Kindly let us know in case of any confusion or questions.


Thanks for your reply…

I export 2 reports to specified stream in PDF (ms1 and ms2)
can I create a new Pdf by attaching ms2 to ms1 using Aspose .Pdf?

please help


Yes, you can attach/embed a PDF (ms2) to another PDF (ms1). Please refer to this help topic: Add Attachment to PDF. The constructor of FileSpecification and Document classes takes the file stream as parameter. Kindly let us know in case of any further assistance.

Best Regards,
Imran Rafique