Save Memory Stream to PDF


I am using Aspose.PDF.

Is there a way to save memory stream to PDF file ? I tried using “Aspose.Pdf.Generator.Pdf”, but it looks like it is obsolete.


Hi Imran,

Thanks for contacting support.

Aspose.Pdf.Generator was a legacy approach for PDF files creation from scratch. However in new Document Object Model, Aspose.Pdf.Document class offers the feature to create as well as manipulate existing PDF files. In case you need to convert the contents of MemoryStream to PDF format, please instantiate Aspose.Pdf.Document instance while passing Stream object as an argument.

However please note that input MemoryStream need to have PDF file or one of the support input file formats.


// load MemoryStream contents to Document object
Document doc = new Document(stream);
// Save resultant document