public AddProcessor ( ITagProcessor processor, String tags ) : void | ||
processor | ITagProcessor | |
tags | String | |
Результат | void |
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); }
/** * Returns a new {@link DefaultTagProcessorFactory} * @return a default XHTML {@link TagProcessorFactory} */ public static ITagProcessorFactory GetHtmlTagProcessorFactory() { DefaultTagProcessorFactory factory = new DefaultTagProcessorFactory(); factory.AddProcessor(HTML.Tag.XML, dummyTagProcessor); factory.AddProcessor("!doctype", dummyTagProcessor); factory.AddProcessor(HTML.Tag.HTML, dummyTagProcessor); factory.AddProcessor(HTML.Tag.HEAD, dummyTagProcessor); factory.AddProcessor(HTML.Tag.META, dummyTagProcessor); factory.AddProcessor(HTML.Tag.OBJECT, dummyTagProcessor); factory.AddProcessor(HTML.Tag.TITLE, defaultpackage + "head.Title"); factory.AddProcessor(HTML.Tag.LINK, defaultpackage + "head.Link"); factory.AddProcessor(HTML.Tag.STYLE, defaultpackage + "head.Style"); factory.AddProcessor(HTML.Tag.BODY, defaultpackage + "Body"); factory.AddProcessor(HTML.Tag.DIV, defaultpackage + "Div"); factory.AddProcessor(HTML.Tag.A, defaultpackage + "Anchor"); factory.AddProcessor(HTML.Tag.TABLE, defaultpackage + "table.Table"); factory.AddProcessor(HTML.Tag.TR, defaultpackage + "table.TableRow"); factory.AddProcessor(HTML.Tag.TD, defaultpackage + "table.TableData"); factory.AddProcessor(HTML.Tag.TH, defaultpackage + "table.TableData"); factory.AddProcessor(HTML.Tag.CAPTION, paragraph); factory.AddProcessor(HTML.Tag.P, paragraph); factory.AddProcessor(HTML.Tag.DT, paragraph); factory.AddProcessor(HTML.Tag.DD, paragraph); factory.AddProcessor(HTML.Tag.BR, defaultpackage + "Break"); factory.AddProcessor(HTML.Tag.SPAN, span); factory.AddProcessor(HTML.Tag.SMALL, span); factory.AddProcessor(HTML.Tag.BIG, span); factory.AddProcessor(HTML.Tag.S, span); factory.AddProcessor(HTML.Tag.STRIKE, span); factory.AddProcessor(HTML.Tag.DEL, span); factory.AddProcessor(HTML.Tag.SUB, span); factory.AddProcessor(HTML.Tag.SUP, span); factory.AddProcessor(HTML.Tag.B, span); factory.AddProcessor(HTML.Tag.STRONG, span); factory.AddProcessor(HTML.Tag.I, span); factory.AddProcessor(HTML.Tag.CITE, span); factory.AddProcessor(HTML.Tag.EM, span); factory.AddProcessor(HTML.Tag.ADDRESS, span); factory.AddProcessor(HTML.Tag.DFN, span); factory.AddProcessor(HTML.Tag.VAR, span); factory.AddProcessor(HTML.Tag.PRE, nonSanitized); factory.AddProcessor(HTML.Tag.TT, nonSanitized); factory.AddProcessor(HTML.Tag.CODE, nonSanitized); factory.AddProcessor(HTML.Tag.KBD, nonSanitized); factory.AddProcessor(HTML.Tag.SAMP, nonSanitized); factory.AddProcessor(HTML.Tag.U, span); factory.AddProcessor(HTML.Tag.INS, span); factory.AddProcessor(HTML.Tag.IMG, defaultpackage + "Image"); factory.AddProcessor(HTML.Tag.UL, defaultpackage + "OrderedUnorderedList"); factory.AddProcessor(HTML.Tag.OL, defaultpackage + "OrderedUnorderedList"); factory.AddProcessor(HTML.Tag.LI, defaultpackage + "OrderedUnorderedListItem"); factory.AddProcessor(HTML.Tag.H1, headers); factory.AddProcessor(HTML.Tag.H2, headers); factory.AddProcessor(HTML.Tag.H3, headers); factory.AddProcessor(HTML.Tag.H4, headers); factory.AddProcessor(HTML.Tag.H5, headers); factory.AddProcessor(HTML.Tag.H6, headers); factory.AddProcessor(HTML.Tag.HR, defaultpackage + "HorizontalRule"); return(factory); }
/** * Returns a new {@link DefaultTagProcessorFactory} * @return a default XHTML {@link TagProcessorFactory} */ public static ITagProcessorFactory GetHtmlTagProcessorFactory() { DefaultTagProcessorFactory factory = new DefaultTagProcessorFactory(); factory.AddProcessor(HTML.Tag.XML, dummyTagProcessor); factory.AddProcessor("!doctype", dummyTagProcessor); factory.AddProcessor(HTML.Tag.HTML, dummyTagProcessor); factory.AddProcessor(HTML.Tag.HEAD, dummyTagProcessor); factory.AddProcessor(HTML.Tag.META, dummyTagProcessor); factory.AddProcessor(HTML.Tag.OBJECT, dummyTagProcessor); factory.AddProcessor(HTML.Tag.TITLE, defaultpackage + "head.Title"); factory.AddProcessor(HTML.Tag.LINK, defaultpackage + "head.Link"); factory.AddProcessor(HTML.Tag.STYLE, defaultpackage + "head.Style"); factory.AddProcessor(HTML.Tag.BODY, defaultpackage + "Body"); factory.AddProcessor(HTML.Tag.DIV, defaultpackage + "Div"); factory.AddProcessor(HTML.Tag.A, defaultpackage + "Anchor"); factory.AddProcessor(HTML.Tag.TABLE, defaultpackage + "table.Table"); factory.AddProcessor(HTML.Tag.TR, defaultpackage + "table.TableRow"); factory.AddProcessor(HTML.Tag.TD, defaultpackage + "table.TableData"); factory.AddProcessor(HTML.Tag.TH, defaultpackage + "table.TableData"); factory.AddProcessor(HTML.Tag.CAPTION, paragraph); factory.AddProcessor(HTML.Tag.P, paragraph); factory.AddProcessor(HTML.Tag.DT, paragraph); factory.AddProcessor(HTML.Tag.DD, paragraph); factory.AddProcessor(HTML.Tag.BLOCKQUOTE, paragraph); factory.AddProcessor(HTML.Tag.BR, defaultpackage + "Break"); factory.AddProcessor(HTML.Tag.SPAN, span); factory.AddProcessor(HTML.Tag.SMALL, span); factory.AddProcessor(HTML.Tag.BIG, span); factory.AddProcessor(HTML.Tag.S, span); factory.AddProcessor(HTML.Tag.STRIKE, span); factory.AddProcessor(HTML.Tag.DEL, span); factory.AddProcessor(HTML.Tag.SUB, span); factory.AddProcessor(HTML.Tag.SUP, span); factory.AddProcessor(HTML.Tag.B, span); factory.AddProcessor(HTML.Tag.STRONG, span); factory.AddProcessor(HTML.Tag.FONT, span); factory.AddProcessor(HTML.Tag.I, span); factory.AddProcessor(HTML.Tag.CITE, span); factory.AddProcessor(HTML.Tag.EM, span); factory.AddProcessor(HTML.Tag.ADDRESS, span); factory.AddProcessor(HTML.Tag.DFN, span); factory.AddProcessor(HTML.Tag.VAR, span); factory.AddProcessor(HTML.Tag.PRE, nonSanitized); factory.AddProcessor(HTML.Tag.TT, nonSanitized); factory.AddProcessor(HTML.Tag.CODE, nonSanitized); factory.AddProcessor(HTML.Tag.KBD, nonSanitized); factory.AddProcessor(HTML.Tag.SAMP, nonSanitized); factory.AddProcessor(HTML.Tag.U, span); factory.AddProcessor(HTML.Tag.INS, span); factory.AddProcessor(HTML.Tag.IMG, defaultpackage + "Image"); factory.AddProcessor(HTML.Tag.UL, defaultpackage + "OrderedUnorderedList"); factory.AddProcessor(HTML.Tag.OL, defaultpackage + "OrderedUnorderedList"); factory.AddProcessor(HTML.Tag.LI, defaultpackage + "OrderedUnorderedListItem"); factory.AddProcessor(HTML.Tag.H1, headers); factory.AddProcessor(HTML.Tag.H2, headers); factory.AddProcessor(HTML.Tag.H3, headers); factory.AddProcessor(HTML.Tag.H4, headers); factory.AddProcessor(HTML.Tag.H5, headers); factory.AddProcessor(HTML.Tag.H6, headers); factory.AddProcessor(HTML.Tag.HR, defaultpackage + "HorizontalRule"); //added by Jeroen Nouws factory.AddProcessor(HTML.Tag.LABEL, span); return factory; }
public static ITagProcessorFactory GetSvgTagProcessorFactory() { DefaultTagProcessorFactory factory = new DefaultTagProcessorFactory(); factory.AddProcessor(HTML.Tag.XML, dummyTagProcessor); factory.AddProcessor("!doctype", dummyTagProcessor); factory.AddProcessor(SvgTagNames.SVG, svgpackage + "SvgTag"); factory.AddProcessor(SvgTagNames.DEFS, svgpackage + "DefsTag"); factory.AddProcessor(SvgTagNames.CIRCLE, svgpackage + "CircleTag"); factory.AddProcessor(SvgTagNames.PATH, svgpackage + "PathTag"); factory.AddProcessor(SvgTagNames.GROUP, svgpackage + "GroupTag"); factory.AddProcessor(SvgTagNames.RECTANGLE, svgpackage + "RectangleTag"); factory.AddProcessor(SvgTagNames.ELLIPSE, svgpackage + "EllipseTag"); factory.AddProcessor(SvgTagNames.LINE, svgpackage + "LineTag"); factory.AddProcessor(SvgTagNames.POLYLINE, svgpackage + "PolyTag"); factory.AddProcessor(SvgTagNames.POLYGON, svgpackage + "PolyTag"); factory.AddProcessor(SvgTagNames.SYMBOL, svgpackage + "SymbolTag"); factory.AddProcessor(SvgTagNames.USE, svgpackage + "UseTag"); factory.AddProcessor(SvgTagNames.TEXT, svgpackage + "TextTag"); factory.AddProcessor(SvgTagNames.TSPAN, svgpackage + "TextSpanTag"); factory.AddProcessor(SvgTagNames.TEXTPATH, svgpackage + "TextPathTag"); factory.AddProcessor(HTML.Tag.STYLE, "com.itextpdf.tool.xml.html.head.Style"); return factory; }