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

Free Support Forum - aspose.com

Pdf preview

I need to show pdf out put as preview before save to a location. But not need to show things like print dialog, print setting etc. How can i show preview after converting excel file to PDF as stream?

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(inputExcelFilePath);
System.IO.MemoryStream stream=new System.IO.MemoryStream();
workbook.Save(stream, Aspose.Cells.SaveFormat.Pdf);
Here i convert excel to pdf and save to stream, From this stream i need to show preview.

Hi,


Well, Aspose.Cells is spreadsheet management component that has an extra utility to render Workbooks to PDF file format. It does not provide any such preview tool. I think if you are using web application and has Adobe acrobat installed, you may simply response the PDF stream to the browser/tool accordingly, see the sample lines of code that you may add at the end.
e.g
Sample code:

stream.Seek(0, SeekOrigin.Begin);

Response.Clear();

Response.ClearHeaders();

Response.ClearContent();

Response.Charset = “UTF-8”;

Response.Cache.SetCacheability(HttpCacheability.Private);

Response.CacheControl = “private”;

Response.AddHeader(“Content-Length”, stream.Length.ToString());

Response.ContentType = “application/pdf”;

Response.AddHeader(“content-disposition”, “attachment;filename=” + “mypdftest.pdf”);

Response.BinaryWrite(stream.ToArray());

stream.Flush();

stream.Close();

Response.Flush();

Response.End();

By the way, our sister company GroupDocs.com (http://www.aspose.com/corporate/ventures/groupdocs.aspx) provides means to preview PDF files, you may explore it.

Thank you.