I am using iTextsharp library with XmlWorker version 5.5.12.0, and facing problems with list is enclosed with DIV.
<body>
<span>
<ul>
<ul>
<li>Project Management
<ul>
<li>
<a class="jwiki-small" data-containerid="2544" data-containertype="14" data-objectid="14695" data-objecttype="102" href="https://SampleUrl.com/DOC-146">Sample Text</a>
</li>
</ul>
</li>
</ul>
</ul>
</span>
</body>
and the pdf looks correct like the image below.
But Formatting problems start once List is enclosed in a Div at any level. List in pdf becomes inline.
<body>
<div>
<span>
<ul>
<ul>
<li>Project Management
<ul>
<li>
<a class="jwiki-small" data-containerid="2544" data-containertype="14" data-objectid="14695" data-objecttype="102" href="https://SampleUrl.com/DOC-146">Sample Text</a>
</li>
</ul>
</li>
</ul>
</ul>
</span>
</div>
</body>
FYI, Here is CreatePDF method I am using.
private void CreatePDF(string html)
{
var document = new Document(iTextSharp.text.PageSize.A4,20,20,20,20);
var memoryStream = new MemoryStream();
using (var pdfWriter = PdfWriter.GetInstance(document, memoryStream))
{
document.Open();
var htmlContext = new HtmlPipelineContext(null);
htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
htmlContext.SetImageProvider(new CustomItextImageProvider());
htmlContext.CharSet(Encoding.UTF8);
var cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(true);
var pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, pdfWriter)));
var xmlWorker = new XMLWorker(pipeline, true);
var xmlParser = new XMLParser(true,xmlWorker);
StringReader rdr = new StringReader((html));
xmlParser.Parse(rdr);
pdfWriter.CloseStream = false;
document.AddCreator("iTextSharp");
document.AddAuthor("ThreeWill");
document.Close();
string fileName = @"c:\temp\" + "test" + DateTime.Now.ToString("yyyy-mm-dd hh.mm.ss") + ".pdf";
var outputFileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write);
memoryStream.Position = 0;
memoryStream.WriteTo(outputFileStream);
outputFileStream.Close();
}
}