-1

Does iTextSharp HTML to PDF conversion support controls like Textboxes, Buttons etc.? Or we need to use iTextSharp class like TextField to implement controls during PDF conversion.

Sam
  • 13
  • 1
  • 3

1 Answers1

1

iTextSharp doesn't support convertion of text boxes, buttons, etc. Most likely, you need to implement your own logic if you want to covert the html page (with text boxes, buttons, etc.) to a pdf document. You can find all supported tags and styles here. You can also check whether an element is supported using this simple example:

byte[] bytes;
using (var stream = new MemoryStream())
{
     using (var document = new Document())
     {
          using (var writer = PdfWriter.GetInstance(document, stream))
          {
               document.Open();
               var html = @"<p>Before the button</p><br/><input type=""submit"" value=""Click me""/><br/><p>After the button</p>";
               using (var reader = new StringReader(html))
               {
                    XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader);
               }                   
               document.Close();
          }
     }
     bytes = stream.ToArray();
}
File.WriteAllBytes("test.pdf", bytes);

If you run this example, you'll see that the input element is not a part of the final document:

enter image description here

Sergii Zhevzhyk
  • 4,074
  • 22
  • 28