Free Support Forum -

I need help to open pdf on browser

Hi all ,

i'm .Net web developer, i'm using Aspose.pdf component version to save file as pdf format.

i'm trying to use the save type property like that :

pdf.Save(Server.MapPath("Report1.pdf"), Aspose.Pdf.SaveType.OpenInBrowser, Response)

but i can't open the generated pdf in browser.

please i need an urgent help

This message was posted using Aspose.Live 2 Forum

Hello Ali,

Thanks for considering Aspose.

I've tested the scenario while using Aspose.Pdf for .NET 4.1.1 with the following simple code snippet and I'm unable to notice the problem. The resultant PDF is being displayed in the web browser without any issue.

Can you please take a look over the following code snippet.


Pdf testPdf = new Pdf();
Aspose.Pdf.Section _section1= testPdf.Sections.Add();
_section1.Paragraphs.Add(new Text("Hello World"));

i need to use Aspose.pdf version to save my pdf and open it in browser as follows:

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()

pdf.BindXML(Server.MapPath("Report1.xml"), Nothing)

pdf.Save(Server.MapPath("Report1.pdf"), Aspose.Pdf.SaveType.OpenInBrowser, Response)

but it is not opened in browser after saving it.

Hi Ali,

Please try to use the latest version of the Aspose.Pdf, as shared by my colleague in this post. You can also use the following .NET code to render a PDF file to the browser:

// create a byte array that will hold the output pdf

byte[] outBuf = outStream.GetBuffer();

// specify the duration of time before a page,cached on a browser expires

Response.Expires = 0;

// Specify the property to buffer the output page

Response.Buffer = true;

// Erase any buffered HTML output


//Add a new HTML header and value to the response sent to the client

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

// Specify the HTTP content type for response as Pdf

Response.ContentType = “application/pdf”;

// Write specified information of current HTTP output to Byte array


// close the output stream


//end the processing of the current page to ensure that no other HTML content is sent


If it still doesn’t resolve your issue, then please share Report1.Xml file with us, so we could test the issue at our end. We’ll update you with the resolution accordingly.

We’re sorry for the inconvenience.


As per your request, I've also tested your shared code snippet with Aspose.Pdf for .NET and I'm unable to notice any problem. The resultant PDF is being displayed correctly in web browser.

According to the code snippet shared above, the file displays in web browser instead of getting saved over some location.

PS, Do you mean, you need to display the PDF document after its saved over some location or you simply need to display it in web browser ?

We always encourage our customers to use the latest versions of our products, as they include lots of new features and fixes for the issues noticed in previous versions.