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

Free Support Forum - aspose.com

Open pdf file in IE browser

I have a pdf file.

I need to open this file in IE browser.

string sFile = "c:\\result.pdf";

Aspose.Pdf.Pdf pf = new Aspose.Pdf.Pdf() ;

//what goes here?

pf.Save("output.pdf", Aspose.Pdf.SaveType.OpenInBrowser, this.Response);

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

Aspose.Pdf is a component which is used to create Pdf file from scratch. As you have stated, you have a Pdf file and you need to display it in browser, let me share some thing regarding such scenarios. We have a component named Aspose.Pdf.Kit which is used to manipulate existing Pdf files, and it contains a class named PdfViewer which is used for Viewing Pdf file in visual mode, Zooming Pdf pages and Printing Pdf files. Currently The PdfViewer is Beta Version. Some functions may not work well.

For more related information please visit, http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/pdfviewer.html

You can also refer to our online demo for viewing the Pdf file. Please visit http://www.aspose.com/demos/aspose.pdf.kit/viewpdf.aspx


I want to add more comment.

If you want to display your PDF with Adobe Reader, you need not Aspose products. You can open the PDF file and write the stream to Web browser directly.

Hello There,

I think you can render a pdf document on the browser using response object as well, if you use PDFFileEditor class in Aspose.Pdf.Kit namespace (by the way, Aspose.Pdf.Kit is another component, different than Aspose.Pdf). You can extract all the pages from the existing PDF file as byte array and then write that byte array to the response object. Here is the sample code for that:

string sFile = "c:\\result.pdf";

FileStream inStream;

//create a new PdfFileEditor object

PdfFileEditor objPdfFileEditor = new PdfFileEditor();

//read input Pdf documents

inStream = File.Open(sPath, FileMode.Open, FileAccess.Read, FileShare.Read);

MemoryStream memoryStream = new MemoryStream();

//Set total number of pages in the pdf document to be extracted

int iPages = NumberOfPages;

//extract given number of pages from input stream into the memory stream

objPdfFileEditor .Extract(inStream, iPages, memoryStream);

byte[] outBuf = memoryStream.GetBuffer();

//show response (pdf file output) to user on the web page

HttpResponse response = Response;

response.Expires = 0;

response.Buffer = true;


response.AddHeader("content-disposition", "inline; filename=" + "output.pdf");

response.ContentType = "application/pdf";




objPdfFileEditor = null;


Nevertheless, I believe you can use

Pdf.Save("output.pdf", Aspose.Pdf.SaveType.OpenInBrowser, this.Response);

method to open a pdf file in browser if you create a new pdf document from BindXML method, or using Aspose.Pdf API.

I hope this helps.


Great sample. Is there a way to open response.BinaryWrite(outBuf) in a new window? Thanks



Thanks for considering Aspose.

For your requirement, you can refer to the following link, I hope it would be helpful, and in case of any further query, please feel free to contact.


It looks like this is not doable. I cannot create a link to open a stream…


How about if you open a browser window first and then execute the pdf rendering code in that new page, instead of rendering the pdf first and opening a new browser window? Just a suggestion!