virtual public void VerifyBreakChunk() { Break br = new Break(); WorkerContextImpl workerContextImpl = new WorkerContextImpl(); CssAppliersImpl cssAppliers = new CssAppliersImpl(); workerContextImpl.Put(typeof (HtmlPipeline).FullName, new HtmlPipelineContext(cssAppliers)); br.SetCssAppliers(cssAppliers); IList<IElement> end = br.End(workerContextImpl, new Tag("span"), null); Assert.AreEqual(Chunk.NEWLINE.Content, end[0].Chunks[0].Content); }
public CssAppliers Clone() { CssAppliersImpl clone = new CssAppliersImpl(); clone.chunk = chunk; clone.paragraph = paragraph; clone.nonewlineparagraph = nonewlineparagraph; clone.htmlcell = htmlcell; clone.list = list; clone.lineseparator = lineseparator; clone.image = image; return(clone); }
virtual public CssAppliers Clone() { CssAppliersImpl clone = GetClonedObject(); clone.chunk = chunk; clone.paragraph = paragraph; clone.nonewlineparagraph = nonewlineparagraph; clone.htmlcell = htmlcell; clone.list = list; clone.lineseparator = lineseparator; clone.image = image; clone.div = div; return(clone); }
virtual public void SetUp() { LoggerFactory.GetInstance().SetLogger(new SysoLogger(3)); root = new Tag("body"); p = new Tag("p"); ul = new Tag("ul"); first = new Tag("li"); last = new Tag("li"); single = new ListItem("Single"); start = new ListItem("Start"); end = new ListItem("End"); listWithOne = new List<IElement>(); listWithTwo = new List<IElement>(); orderedUnorderedList = new OrderedUnorderedList(); CssAppliersImpl cssAppliers = new CssAppliersImpl(); orderedUnorderedList.SetCssAppliers(cssAppliers); workerContextImpl = new WorkerContextImpl(); HtmlPipelineContext context2 = new HtmlPipelineContext(cssAppliers); workerContextImpl.Put(typeof (HtmlPipeline).FullName, context2); root.AddChild(p); root.AddChild(ul); ul.AddChild(first); ul.AddChild(last); p.CSS["font-size"] = "12pt"; p.CSS["margin-top"] = "12pt"; p.CSS["margin-bottom"] = "12pt"; new ParagraphCssApplier(cssAppliers).Apply(new Paragraph("paragraph"), p, context2); first.CSS["margin-top"] = "50pt"; first.CSS["padding-top"] = "25pt"; first.CSS["margin-bottom"] = "50pt"; first.CSS["padding-bottom"] = "25pt"; last.CSS["margin-bottom"] = "50pt"; last.CSS["padding-bottom"] = "25pt"; listWithOne.Add(single); listWithTwo.Add(start); listWithTwo.Add(end); }
/** * Parses an HTML string and a string containing CSS into a list of Element objects. * The FontProvider will be obtained from iText's FontFactory object. * * @param html a String containing an XHTML snippet * @param css a String containing CSS * @return an ElementList instance */ public static ElementList ParseToElementList(String html, String css) { // CSS ICSSResolver cssResolver = new StyleAttrCSSResolver(); if (css != null) { ICssFile cssFile = XMLWorkerHelper.GetCSS(new MemoryStream(Encoding.Default.GetBytes(css))); cssResolver.AddCss(cssFile); } // HTML CssAppliers cssAppliers = new CssAppliersImpl(FontFactory.FontImp); HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers); htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory()); htmlContext.AutoBookmark(false); // Pipelines ElementList elements = new ElementList(); ElementHandlerPipeline end = new ElementHandlerPipeline(elements, null); HtmlPipeline htmlPipeline = new HtmlPipeline(htmlContext, end); CssResolverPipeline cssPipeline = new CssResolverPipeline(cssResolver, htmlPipeline); // XML Worker XMLWorker worker = new XMLWorker(cssPipeline, true); XMLParser p = new XMLParser(worker); p.Parse(new MemoryStream(Encoding.Default.GetBytes(html))); return elements; }
virtual public CssAppliers Clone() { CssAppliersImpl clone = new CssAppliersImpl(); clone.chunk = chunk; clone.paragraph = paragraph; clone.nonewlineparagraph = nonewlineparagraph; clone.htmlcell = htmlcell; clone.list = list; clone.lineseparator = lineseparator; clone.image = image; clone.div = div; return clone; }