Skip to main content
Edited
Source Link
er-sho
  • 9.8k
  • 2
  • 17
  • 26
  1. Make you changes like below while building your html via StringBuilder like

    StringBuilder sb = new StringBuilder();

    //Open table sb.Append("");

    //Open first tr for all of th sb.Append("");

    foreach foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(column.ColumnName); sb.Append(""); }

    //Close first tr for all of th sb.Append(""); foreach

    foreach (DataRow row in dt.Rows) {
    //Open tr for all of rows sb.Append(""); foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(row[column]); sb.Append(""); } sb.Append("");

     //Close tr for all of rows sb.Append("</tr>"); 

    }

    //Close table sb.Append("");

  2. Use XMLWorkerHelper instead of HTMLWorker because now HTMLWorker is deprecated. ansand not more support by iTextSharp. like

    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close();

See this link

Try once may it help you.

  1. Make you changes like below while building your html via StringBuilder like

    StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append("");

    foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(column.ColumnName); sb.Append(""); } sb.Append(""); foreach (DataRow row in dt.Rows) { sb.Append(""); foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(row[column]); sb.Append(""); } sb.Append(""); } sb.Append("");

  2. Use XMLWorkerHelper instead of HTMLWorker because now HTMLWorker is deprecated. ans not more support by iTextSharp. like

    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close();

See this link

Try once may it help you.

  1. Make you changes like below while building your html via StringBuilder like

    StringBuilder sb = new StringBuilder();

    //Open table sb.Append("");

    //Open first tr for all of th sb.Append(""); foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(column.ColumnName); sb.Append(""); }

    //Close first tr for all of th sb.Append("");

    foreach (DataRow row in dt.Rows) {
    //Open tr for all of rows sb.Append(""); foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(row[column]); sb.Append(""); }

     //Close tr for all of rows sb.Append("</tr>"); 

    }

    //Close table sb.Append("");

  2. Use XMLWorkerHelper instead of HTMLWorker because now HTMLWorker is deprecated. and not more support by iTextSharp. like

    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close();

See this link

Try once may it help you.

Source Link
er-sho
  • 9.8k
  • 2
  • 17
  • 26

  1. Make you changes like below while building your html via StringBuilder like

    StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append("");

    foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(column.ColumnName); sb.Append(""); } sb.Append(""); foreach (DataRow row in dt.Rows) { sb.Append(""); foreach (DataColumn column in dt.Columns) { sb.Append(""); sb.Append(row[column]); sb.Append(""); } sb.Append(""); } sb.Append("");

  2. Use XMLWorkerHelper instead of HTMLWorker because now HTMLWorker is deprecated. ans not more support by iTextSharp. like

    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close();

See this link

Try once may it help you.