Open Pdf in new browser window (separate tab)

Hi ,
I am using Aspose pdf 8.5 and created a pdf . We want to open this pdf in new browser window (in IE : new Tab).

I have referred to this link , but I am getting Error "No overload for method “Save” takes three arguments ".

Could you please help me in provding the code snippet to achieve this functionality.

Thanks in advance.

Hi Preeti,

Thanks for your inquiry. You can use the Window.open() method to open a document in a new browser window. Please check the following code snippet for the purpose. You can create a new aspx page and add the desired code in the Page_Load method of that page, later pass that page to Window.open().

<input id="Button1" type="button" onclick="window.open('NewWindow.aspx', 'pmgw', 'toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no,width=750,height=700,top=0')" Value="Button" />
protected void Page_Load(object sender, EventArgs e)
{
    Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
    Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
    string documentTitle = "testPDF";
    string htmlString = "<style type=text/css> .wrapper { font-size:11pt; line-height:115% } .wrapper p { margin:0pt 0pt 10pt } </style> <div class=wrapper> <div> <p style=font-size:28pt; line-height:115%><span style=font-family:'Vladimir Script'; font-size:28pt>It is a test PDF document<br><br><br> </span></p> </div> </div>";
    Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, htmlString);
    text.IsHtmlTagSupported = true;
    section.Paragraphs.Add(text);

    System.IO.MemoryStream finalStream = new System.IO.MemoryStream();
    text.TextInfo.IsFontEmbedded = true;
    pdf.Save(finalStream);
    byte[] downloadBytes = finalStream.ToArray();
    HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
    HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + documentTitle + ".pdf");
    HttpContext.Current.Response.BinaryWrite(downloadBytes);
    HttpContext.Current.Response.End();
}

Please feel free to contact us for any further assistance.

Best Regards,

Thanks Aspose team. This solution worked for us.

Hi Preeti,


Thanks for sharing the feedback. We are glad to hear that your requirement is accomplished. Please continue using our API and in the event of any further query, please feel free to contact.