Free Support Forum - aspose.com

Is there a way to save the filestream in to a memory

Hi,

Using Aspose i am converting doc,ppt and excel file to pdf file which i saved in to the disk. Now i would like to save the file stream in to memory instead saving it on to the disk,so that i can pass this stream in to some other method. Please help me if there is any way which can help me to get this done.

@pradeepdone,

Thanks for your query.

Each Aspose API (Aspose.Words, Aspose.Cells and Aspose.Slides) provides relevant overloads which you can use to save the Pdf file stream into memory, see the sample code segments for your reference:
e.g
Sample code:

  1. Doc/Docx

     Document doc = new Document(dataDir + fileName);
     // Convert the document to a different format and save to stream.
     MemoryStream dstStream = new MemoryStream();  
     doc.Save(dstStream, SaveFormat.Pdf);
     //......
     //Your code goes here.
     //.......
    
  2. XLS/XLSX

     Workbook workbook = new Workbook(@"e:\test2\Excelprintbug.xlsx");
    
                 using (var stream = new MemoryStream())
                 {
                     workbook.Save(stream, SaveFormat.Pdf);
                     //Write the streams/byte arrays into the file if you want.
                     //File.WriteAllBytes(@"e:\test2\outExcelprintbug121.pdf", stream.ToArray());
                 }
    

Similarly you will find relevant method/overloads in Aspose.Slides API to save the Powerpoint presentation to PDF streams.

Hope, this helps a bit.

Thanks for the response.