title: iTextSharp upgrade to iText7 .NET
body: <p>This is my iText5 code that does what I have previously required done with HTML snippets;</p>
  
  <pre><code>//GetFieldPositions returns an array of field positions if you are using 5.0 or greater
  rectangle = pdfStamper.AcroFields.GetFieldPositions(field.Key)[0].position;
  
  //tell itextSharp to overlay this content 
  PdfContentByte contentBtye = pdfStamper.GetOverContent(1);
  
  var elements = XMLWorkerHelper.ParseToElementList(pdfPlaceHolderData[key].ToString(), null);
  
  ColumnText ct = new ColumnText(contentBtye);
  
  ct.SetSimpleColumn(rectangle.Left, rectangle.Bottom, rectangle.Right, rectangle.Top);
  
  ct.Add(elements);
  
  ct.Go(false);
  
  pdfFormFields.SetField(field.Key, string.Empty);
  </code></pre>
  
  <p>I am struggling to see how to convert this to work in iText7 .NET.</p>
  
  <p>XMLWorkerHelper.ParseToElementList returns 'ElementList' which inherits 'List'. 'IElement' is structured as follows;</p>
  
  <p><img src="https://i.stack.imgur.com/olFGa.png" alt="iTextSharp IElement"></p>
  
  <p>The iText7 Html2Pdf call to HtmlConverter.ConvertToElements(html) returns an 'IList'. However 'IElement' is now structured as follows;</p>
  
  <p><img src="https://i.stack.imgur.com/HZKmG.png" alt="iText7 IElement"></p>
  
  <p>I was hoping that I could of just used this result but obviously my call to 'ct.Add(elements);' in the above code chokes because of the different IElement structure.</p>
  
  <p>I know I am trying to cut corners here (I have no choice at the moment); is there a relatively easy way to convert the iText7 IElement to the iTextSharp IElement that will retain my nicely parsed HTML with images?</p>
  
  <p>How can I replace an acro form field content with parsed HTML instead? This would preferably be in iTextSharp 5, but I suppose would be even better using the latest version?</p>
  
  <p>I currently have a solution working happily with iTextSharp 5 that allows PDF templates to populated dynamically. I have hit a problem using the <code>XMLWorkerHelper.ParseToElementList</code> as it does not seem to support parsing inline images.</p>
  
  <p>I have found that iText7 for .net has an extension called <code>html2pdf</code> that has a method called <code>HtmlConverter.ConvertToElements</code> that does perfectly parse HTML with inline images however the result is not compatible with my iTextSharp 5 implementation and I am struggling in trying to convert it. </p>