Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hai,

When I am trying to convert a HTML to Word, if my HTML contains only one image, it is displaying. But not, when my HTML contains more than one images. All the images are displayed as cross marks. Please help me to over come this issue.

My Code Snippet:
XML
string strImgCandidate = "";
string strImgWork1 = "";
string strImgWork2 = "";
string strImgWork3 = "";
strImgCandidate = Convert.ToString(imgCandidate.Src);
strImgWork1 = Convert.ToString(imgWork1.Src);
strImgWork2 = Convert.ToString(imgWork2.Src);
strImgWork3 = Convert.ToString(imgWork3.Src);
string strImageHeight = Convert.ToString(ConfigurationSettings.AppSettings["PreviewPDFImageHeight"]);
string strImageWidth = Convert.ToString(ConfigurationSettings.AppSettings["PreviewPDFImageWidth"]);
string candImg = "<img alt=\"candidate\" src=" + strImgCandidate + " width=\"" + strImageWidth + "\" height=\"" + strImageHeight + "\" />";
string wrkImg1 = "<img alt=\"test1\" id=\"imgtest1\" src=" + strImgWork1 + " width=\"" + strImageWidth + "\" height=\"" + strImageHeight + "\" />";
string wrkImg2 = "<img alt=\"test2\" id=\"imgtest2\" src=" + strImgWork2 + " width=\"" + strImageWidth + "\" height=\"" + strImageHeight + "\" />";
string wrkImg3 = "<img alt=\"test3\" id=\"imgtest3\" src=" + strImgWork3 + " width=\"" + strImageWidth + "\" height=\"" + strImageHeight + "\" />";
string candImg = "<img alt=\"candidate\" src=" + strImgCandidate + " style=\"height:250px; width:200px;\" />";
string wrkImg1 = "<img alt=\"test1\" id=\"imgtest1\" src=" + strImgWork1 + " style=\"height:350px; width:300px;\" />";
string wrkImg2 = "<img alt=\"test2\" id=\"imgtest2\" src=" + strImgWork2 + " style=\"height:350px; width:300px;\" />";
string wrkImg3 = "<img alt=\"test3\" id=\"imgtest3\" src=" + strImgWork3 + " style=\"height:350px; width:300px;\" />";
if (strImgCandidate != "")
lblimgCandidate.Text = candImg;
if (strImgWork1 != "")
lblimgWork1.Text = wrkImg1;
if (strImgWork2 != "")
lblimgWork2.Text = wrkImg2;
if (strImgWork3 != "")
lblimgWork3.Text = wrkImg3;
SaveToPdf();
string attachment = "attachment; filename=MyProfile.pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
lblimgCandidate.Visible = true;
lblimgWork1.Visible = true;
lblimgWork2.Visible = true;
lblimgWork3.Visible = true;
lblimgCandidate.Visible = false;
lblimgWork1.Visible = false;
lblimgWork2.Visible = false;
lblimgWork3.Visible = false;
tblPreview.RenderControl(htextw);
tblProfileDetails.RenderControl(htextw);
Document document = new Document();
PdfWriter.GetInstance(document, Response.OutputStream);
document.Open();
string tempPostContent = getImage(stw.ToString());
StringReader str = new StringReader(stw.ToString());
HTMLWorker htmlworker = new HTMLWorker(document);
htmlworker.Parse(str);
document.Close();
Response.Write(document);
Response.End();
lblimgCandidate.Visible = false;
lblimgWork1.Visible = false;
lblimgWork2.Visible = false;
lblimgWork3.Visible = false;



Thanks.
Posted
Updated 15-May-12 23:29pm
v2
Comments
Sandeep Mewara 15-May-12 5:44am    
Update the question with your code snippet related.

Use 'Improve Question' link for it and dont post it here as a comment.
Sergey Alexandrovich Kryukov 15-May-12 5:48am    
Do you think we can see your hard drive? No, not during this part of the year. :-)
--SA

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