PdfSourceType Enumeration
Defines the available values for HtmlToPdf.SourceType property to specify the type of source data for conversion to PDF document.

Namespace: MailBee.Pdf
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public enum PdfSourceType
  Member nameValueDescription
Html0 Use HTML as input data source. HtmlAgilityPack will be used to make the input XHTML-compliant XML.
Xhtml1 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.
Text2 Use plain text as input data source. Will wrap plain-text into XMLized XHTML as shown in the second example above.

Internally, the component always takes XML on input in order to produce PDF content. This XML is much like XHTML with <xml> element and some restrictions like the necessity to encode styles and javascript in CDATA blocks. MailBee automatically does all the required conversion of any HTML into this XHTML-over-XML format. However, your application can provide this XHTML-over-XML on input to avoid such conversion in MailBee. In this case, use Xhtml value for SourceType property.

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.

This C# code shows the logic of HTML-to-XML conversion. To use HtmlDocument, you must import HtmlAgilityPack namespace and reference its .DLL (shipped with the component). You can use this snippet to prepare your data or get the idea which data MailBee expects when SourceType is Xhtml.
HtmlDocument html = new HtmlDocument();
html.OptionSupportOptionalEndTags = true;
html.OptionOutputAsXml = true;

StringWriter sw = new StringWriter();

xml = sw.ToString();
In case if the input is plain-text, text-to-XML transformation is as follows:
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><span><html><body><pre>");
xml = sb.ToString();
See Also