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

Free Support Forum - aspose.com

Need help in document conversion

Hi Team,

We are planning to buy Apsose pdf for .net and we are in the process of evaluating the same.We have a problem while converting the PDF file to different formats.

The issue is we have to read and save the converted file using stream as we are not allowed to store the saved or uploaded file in the server.As i have checked your website it has code only to read from a physical PDF file and save the other formats physically.Can you please help us out by providing the code for reading and saving using stream.

Looking forward for your reply.

Navaneethan V

Hi Navaneethan,

Thanks for your interest in Aspose. Aspose.Pdf supports loading/saving documents both from file paths and streams. Please check following sample code snippet and also check different constructors of Document class for details. It will help you to accomplish the task.


// Summary:

// Initialize new Document instance from the input stream.


// Parameters:

// input:

// Stream with pdf document.

public Document(Stream input);


// Summary:

// Just init Document using filename. The same as Aspose.Pdf.Document.#ctor(System.IO.Stream).


// Parameters:

// filename:

// The name of the pdf document file.

public Document(string filename);

Sample code snippet:

//create byte arrays to keep the contents of PDF files

byte[] buffer1 = File.ReadAllBytes("E:/data/HelloWorld.pdf");

using (MemoryStream outputStream = new MemoryStream())


using (MemoryStream inputStream = new MemoryStream(buffer1))


// load PDF document

Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputStream);

// instantiate ExcelSave Option object

Aspose.Pdf.ExcelSaveOptions excelsave = new ExcelSaveOptions();

excelsave.UniformWorksheets = false;

// save the output in XLS format

//doc.Save(myDir + "PDFtoExcel2007.xml", excelsave);

doc.Save(outputStream, excelsave);

//convert MemoryStream back to byte array

byte[] data = outputStream.ToArray();

//create a FileStream to save the output PDF file

FileStream output = new FileStream(myDir + "PDFtoExcel.xls", FileMode.Create,


//write byte array contents in the output file stream

output.Write(data, 0, data.Length);

//close output file




Please feel free to contact us for any further assistance.

Best Regards,