You must Sign In to post a response.
  • Category: .NET

    How to show pdfdoc andany image combined and show in iframe when button is clicked

    below is my code
    its executing but not showing result showing only pdfdoc in iframe, but not image linked with pdfdoc in iframe so any body plz helpme where iam going wrong

    protected void bt11_Click(object sender, EventArgs e)

    string cs = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
    SqlConnection con = new SqlConnection(cs);
    SqlCommand cmd = new SqlCommand("select * from employeep where Salary" + DropDownList1.SelectedValue + "", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    GridView1.DataSource = ds;
    string Filepath = Server.MapPath("~report.pdf");
    string imageURL = Server.MapPath("images.jpg");
    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imageURL);
    img.ScaleToFit(80f, 80f);
    //Align image to the left
    img.Alignment = Element.ALIGN_LEFT;

    FileStream fs = new FileStream(Filepath, System.IO.FileMode.Create);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);


    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, fs);
    GridView1.Visible = false;
    iframepdf.Attributes.Add("src", "~report.pdf");

  • #761987

    You are adding the image and closing the file. You did not save the files right?

    Try to save that. I hope that will solve the issue

    By Nathan
    Direction is important than speed

Sign In to post your comments