Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda