Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Displaying PDF created with HttpContext.Current.Response in a div in asp.net page

My requirement is generating a itextsharp pdf file in button_click event on the fly without saving it in Local disk and there should be no save dialogue . Once the PDF is created we have to display it inside a div tag within the same asp.net page in a small size. Below is the code in which I am able to generate the PDF:

protected void Button2_Click(object sender, EventArgs e)
    {
        string PDFfileName = Path.GetFileNameWithoutExtension(fileName);
        HttpContext.Current.Response.ContentType = "application/pdf";
        HttpContext.Current.Response.AddHeader("content-disposition", "inline;filename= " + 
        PDFfileName + ".pdf"); 
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Document pdfDoc = new Document(); PdfWriter.GetInstance(pdfDoc, 
        HttpContext.Current.Response.OutputStream); 
        pdfDoc.Open();
        pdfDoc.Close();
        HttpContext.Current.Response.Write(pdfDoc);
        HttpContext.Current.Response.End();
    }

Now the challenge which I am facing:

  1. The generated PDF is getting opened in entire page like redirection but the URL remains the same.(If we click back button of browser, it is going to the page where I clicked the button to generate pdf) 2)I am not able to display the generated PDF inside the div as a small part.

Solution which I want is the same pdf which is generated without saving it in disk should directly appear inside div tag in middle of the page and also it should not show any save dialogue message.

Please help me.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!