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

Free Support Forum - aspose.com

Convert from Pdf bytearray to Excel

Hi,

Could you please help me in converting the Pdf bytearray to Excel bytearray

Hi Ashok,


Thanks for your inquiry. You may use Document() and Save() method overloads using stream parameter for your need. Please check following code sample, you may change it to as per your requirements.

//create file stream to read pdf file<o:p></o:p>

FileStream fs1 = new FileStream(myDir + "Job+Listing.pdf", FileMode.Open, FileAccess.Read);

//create byte array to keep the contents of PDF file

byte[] buffer1 = new byte[Convert.ToInt32(fs1.Length)];

fs1.Read(buffer1, 0, Convert.ToInt32(fs1.Length));

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 memory stream

doc.Save(outputStream, excelsave);

//convert MemoryStream back to byte array

byte[] data = outputStream.ToArray();

//create a FileStream to save the output xls file

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

FileAccess.Write);

//write byte array contents in the output file stream

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

//close output file

output.Close();

}

}


Please feel free to contact us for any further assistance.

Best Regards,