title: How do i insert Base 64 encoded image data as an image in table without saving the image?
body: <p>I have been trying to create Pdf file using ITextSharp. I am able to pass html content via ajax but pdf contains some images which are saved as base64 encoded data in database. </p>
  
  <p>How would i be able to get those data and convert them as an image and insert in my table rows.</p>
  
  <p>I would like to achieve something like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;{image 1} &lt;/td&gt;&lt;pre&gt;&lt;td&gt;{image 1} &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am able to create the pdf files but instead of image i am getting base64 data</p>
  
  <p>This is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> public ActionResult CreatePdf(string htmlData)
          {
              string mytblhtml = htmlData;
              mytblhtml += GetImage();
             
  
              string fileName = "MyPdf.pdf";
              using(var ms = new MemoryStream())
              {
                  using(var doc = new Document(PageSize.A4, 25, 25, 25, 25))
                  {
                      using(var writer = PdfWriter.GetInstance(doc, ms))
                      {
                          doc.Open();
  
                          using(var srHtml = new StringReader(mytblhtml))
                          {
                              iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, srHtml);
                          }
                          doc.Close();
                      }
                  }
                  // bPDF = ms.ToArray();
  
                  TempData[fileName] = ms;
  
  
                  return Json(new { success = true, fileName }, JsonRequestBehavior.AllowGet);
              }
          }
  
          private string GetImage()
          {
              string imgHtml = "&lt;table&gt;&lt;tr&gt;";
              using(EmpDb db = new EmpDb())
              {
                  var emps = db.Employees.ToList();
  
                  foreach(var e in emps)
                  {
                      if(!String.IsNullOrWhiteSpace(e.Image))
                      {
                           imgHtml += $@"&lt;td&gt;data:{e.Image}&lt;/td&gt;";
                         
                      }
                  }
                  imgHtml += "&lt;/tr&gt;&lt;/table&gt;";
                  
              }
  
              return imgHtml;
          }
  
          public ActionResult DownloadCertPdf(string fileName)
          {
              var ms = TempData[fileName] as MemoryStream;
              if(ms == null)
              {
                  return new EmptyResult();
              }
              TempData[fileName] = null;
              return File(ms.ToArray(), "application/pdf", fileName);
          }</code></pre>
  </div>
  </div>
  </p>