|0||Use HTML as input data source. HtmlAgilityPack will be used to make the input XHTML-compliant XML.|
|1||Use XHTML wrapped in XML (XMLized XHTML) as input data source. HtmlAgilityPack won't be used as the input is already expected to be XML-compliant XHTML.|
|2||Use plain text as input data source. Will wrap plain-text into XMLized XHTML as shown in the second example above.|
This can be useful in case if you want to use OnConvertXmlNodeToPdf delegate to precisely control how some nodes of the input data are converted from XML to PDF. In this case, providing HTML input may not be sufficient as you may not know which nodes will exist in the document after HTML-to-XML conversion. Providing the input which can be consumed by the PDF producer without any additional conversion of HTML into XML solves this problem - OnConvertXmlNodeToPdf delegate will fire on the same nodes your document contains.
|PDF functionality resides in a separate MailBee.NET.PDF.dll. It's available for .NET Framework only (not available for .NET Core or UWP). It also depends on iTextSharp.dllHtmlAgilityPack.dll. In case of Nuget, you need to install a separate MailBee.NET.PDF package (includes all the required DLLs).|
HtmlDocument html = new HtmlDocument(); html.OptionSupportOptionalEndTags = true; html.LoadHtml(source); html.OptionOutputAsXml = true; StringWriter sw = new StringWriter(); html.Save(sw); xml = sw.ToString();
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><span><html><body><pre>"); sb.Append(HttpUtility.HtmlEncode(source)); sb.Append("</pre></body></html></span>"); xml = sb.ToString();