I have a excel file stream which needs to be saved in a pdf format. I am getting an error trying to do that...If you could help, I would really appreciate it.
SPSite/SpWeb ==> objects are SharePoint objects which helps to open an excel file from a url location and put it in a stream.
using (SPSite spSite = new SPSite(documentUrl))
using (SPWeb spWeb = spSite.OpenWeb())
SPFile spFile = spWeb.GetFile(documentUrl);
using (Stream stream = spFile.OpenBinaryStream())
Workbook workBook = new Workbook();
Pdf pdf = new Pdf();
/// Upload the file
spWeb.GetFile(destinationUrl).Delete(); //Delete file if incase exists
byte contents = pdf.GetBuffer();
catch (Exception ex)
string error = ex.Message;