private static void _add_to_table(Guid applicationId, HttpContext context, PdfPTable mainTable,
StyleAttrCSSResolver cssResolver, WikiPDFText text, Font font, PdfPCell cell = null)
{
if (cell == null)
{
cell = new PdfPCell();
}
cell.Border = 0;
cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
cell.RunDirection = text.IsRTL ? PdfWriter.RUN_DIRECTION_RTL : PdfWriter.RUN_DIRECTION_LTR;
cell.SetLeading(0, 2);
itsXmlHtml.DefaultTagProcessorFactory tagProcessors =
(itsXmlHtml.DefaultTagProcessorFactory)itsXmlHtml.Tags.GetHtmlTagProcessorFactory();
tagProcessors.RemoveProcessor(itsXmlHtml.HTML.Tag.IMG); // remove the default processor
tagProcessors.AddProcessor(itsXmlHtml.HTML.Tag.IMG, new CustomImageTagProcessor(applicationId)); // use our new processor
//tagProcessors.AddProcessor(itsXmlHtml.HTML.Tag.TABLE, new TableTagProcessor());
HtmlPipelineContext htmlContext =
new HtmlPipelineContext(new itsXmlHtml.CssAppliersImpl(new IranSansFontProvider(font)));
htmlContext.SetImageProvider(new ImageProvider());
htmlContext.CharSet(Encoding.UTF8);
htmlContext.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(tagProcessors);
ElementsCollector elementsHandler = new ElementsCollector();
CssResolverPipeline pipeline = new CssResolverPipeline(cssResolver,
new HtmlPipeline(htmlContext, new ElementHandlerPipeline(elementsHandler, null)));
itsXml.XMLWorker worker = new itsXml.XMLWorker(pipeline, parseHtml: true);
XMLParser parser = new XMLParser(true, worker, Encoding.UTF8);
parser.Parse(new StringReader(text.Text));
cell.AddElement(elementsHandler.Paragraph);
mainTable.AddCell(cell);
}