Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 or else give me some examples

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();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
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);

GridView1.RenderControl(hw);

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);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Add(img);
pdfDoc.Close();
fs.Close();
GridView1.Visible = false;
iframepdf.Attributes.Add("src", "~report.pdf");

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900