I am using selectPdf to generate dynamic pdfs in my webapt. Select PDF download this pdf as attachment, I want that this PDF should show in browser tab instead of downloading. following is my code.
   [HttpGet]
    [Route("myapplication")]
    [AllowAnonymous]
private System.Net.Http.HttpResponseMessage GeneratePDF(string guid, bool isAr, out string fileName)
    {
        string htmlString = ApplicationService.GeneratePDFHTMLString(guid, isAr, out fileName);
        string pdf_page_size = "A4";
        PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize),
            pdf_page_size, true);
        string pdf_orientation = "Portrait";
        PdfPageOrientation pdfOrientation =
            (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation),
            pdf_orientation, true);
        int webPageWidth = 748;
        int webPageHeight = 0;
        // instantiate a html to pdf converter object
        HtmlToPdf converter = new HtmlToPdf();
        // set converter options
        converter.Options.PdfPageSize = pageSize;
        converter.Options.PdfPageOrientation = pdfOrientation;
        converter.Options.WebPageWidth = webPageWidth;
        converter.Options.MarginTop = 20;
        converter.Options.WebPageHeight = webPageHeight;
        converter.Options.ExternalLinksEnabled = true;
        converter.Options.EmbedFonts = true;
        converter.Options.KeepTextsTogether = true;
        try
        {
            // create a new pdf document converting an url
            PdfDocument doc = converter.ConvertHtmlString(htmlString);
            doc.CompressionLevel = PdfCompressionLevel.NoCompression;
            //var contents = doc.Save();
            //doc.Close();
            //return contents;
            MemoryStream pdfStream = new MemoryStream();
            // save pdf document into a MemoryStream
            doc.Save(pdfStream);
            // reset stream position
            pdfStream.Position = 0;
            System.Net.Http.HttpResponseMessage response = new System.Net.Http.HttpResponseMessage();
            response.StatusCode = System.Net.HttpStatusCode.OK;
            //response.Content = new System.Net.Http.StreamContent(pdfStream);
            response.Content = new System.Net.Http.ByteArrayContent(pdfStream.ToArray());
            response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = "foo.pdf"
            };
            response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
            doc.Close();
            return response;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 
    