Snehal Pawar

Snehal Pawar

  • NA
  • 25
  • 20k

expected closing tag img error in itext xmlworker

Nov 2 2017 1:08 AM
I am trying to convert webpage content into pdf using itextsharp
 
following is the code
  1. protected void btnExport_Click(object sender, EventArgs e)  
  2. {  
  3. StringReader sr = new StringReader(Request.Form[hfGridHtml.UniqueID]);  
  4. Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);  
  5. PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);  
  6. pdfDoc.Open();  
  7. XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);  
  8. pdfDoc.Close();  
  9. Response.ContentType = "application/pdf";  
  10. Response.AddHeader("content-disposition""attachment;filename=HTML.pdf");  
  11. Response.Cache.SetCacheability(HttpCacheability.NoCache);  
  12. Response.Write(pdfDoc);  
  13. Response.End();  
  14. }  
and below is my source code
  1. <div class="Container" >  
  2. <div>  
  3. <table style="width: 100%" >  
  4. <tr>  
  5. <td style="font-weight: bold;font-size: 12px" colspan="2">  
  6. </td>  
  7. </tr>  
  8. <tr>  
  9. <td colspan="2"></td>  
  10. </tr>  
  11. <tr >  
  12. <td style="font-size: 9px;height: 50px;width:50%">  
  13. </td>  
  14. <td align="right" style="font-weight: bold;font-size: 10px" > <div> <span>CENTRAL KYC REGISTRY</span>  
  15. <span></span></div></td>  
  16. </tr>  
  17. </table>  
  18. <table style="width: 100%; border-collapse:collapse" cellpadding="4" border="1">  
  19. <tr>  
  20. <td colspan="3" style="height: 25px;font-weight: bold;font-size: 12px">  
  21. <div >1. Personal Details </div>  
  22. </td>  
  23. </tr>  
  24. <tr>  
  25. <td colspan="2" style="font-size: 10px; height: 3%"><span style="font-weight:bold;font-size: 10px"> Name* </span>(Same as ID proof): <asp:Label ID="lbName" runat="server" Text=""></asp:Label></td>  
  26. <td rowspan="4" >  
  27. <img src="" height="100" alt="" width="100" id="imgs" runat="server" ></ img>  
  28. </td>  
  29. </tr>  
  30. <tr>  
  31. <td style="height: 3%;font-size: 10px" colspan="2" >  
  32. <div><span style="font-weight:bold" > Maiden name </span>(If any)* : <asp:Label ID="lbMaidenName" runat="server" Text=""></asp:Label></div> </td>  
  33. </tr>  
  34. <tr>  
  35. <td style="height: 3%;font-size: 10px" colspan="2"><div><span style="font-weight:bold"> Father's/Spouse Name* </span><asp:Label ID="lbFatherName" runat="server" Text=""></asp:Label></div></td>  
  36. </tr>  
  37. <tr>  
  38. <td style="height: 3%;font-size: 10px" colspan="2"><div><span style="font-weight:bold"> Mother name*</span> : <asp:Label ID="lbMotherName" runat="server" Text=""></asp:Label></div></td>  
  39. </tr>  
  40. </table>  
  41. </div>  
  42. </div>  
while exporting it gives me error like this
 
'Invalid nested tag td found, expected closing tag img' and 'br'
 
I tried <img src='...'></img>and <br/>
 
But it gives me same error while exporting,
 
help me to resolve this issue, Thank you

Answers (7)