Save Memory Stream to PDF

Hi,


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.

Thanks
Imran

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.

[C#]

// load MemoryStream contents to Document object
Document doc = new Document(stream);
// Save resultant document
doc.Save(“c:/pdftest/resultant.pdf”);