protected void ProcessChunkItems(IList<IElement> chunks, HtmlCell cell) { Paragraph p = new Paragraph(); p.MultipliedLeading = 1.2f; p.AddAll(chunks); p.Alignment = cell.HorizontalAlignment; if (p.Trim()) { cell.AddElement(p); } chunks.Clear(); }
/** * Adds currentContent list to a paragraph element. If addNewLines is true a * Paragraph object is returned, else a NoNewLineParagraph object is * returned. * * @param currentContent IList<IElement> of the current elements to be added. * @param addNewLines bool to declare which paragraph element should be * returned, true if new line should be added or not. * @param applyCSS true if CSS should be applied on the paragraph * @param tag the relevant tag * @return a List with paragraphs */ public virtual IList<IElement> CurrentContentToParagraph(IList<IElement> currentContent, bool addNewLines, bool applyCSS, Tag tag, IWorkerContext ctx) { try { IList<IElement> list = new List<IElement>(); if (currentContent.Count > 0) { if (addNewLines) { Paragraph p = new Paragraph(float.NaN); p.MultipliedLeading = 1.2f; foreach (IElement e in currentContent) { if (e is LineSeparator) { try { HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx); Chunk newLine = (Chunk)GetCssAppliers().Apply(new Chunk(Chunk.NEWLINE), tag, htmlPipelineContext); p.Add(newLine); } catch (NoCustomContextException exc) { throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), exc); } } p.Add(e); } if (p.Trim()) { if (applyCSS) { p = (Paragraph) GetCssAppliers().Apply(p, tag, GetHtmlPipelineContext(ctx)); } list.Add(p); } } else { NoNewLineParagraph p = new NoNewLineParagraph(float.NaN); p.MultipliedLeading = 1.2f; foreach (IElement e in currentContent) { p.Add(e); } p = (NoNewLineParagraph) GetCssAppliers().Apply(p, tag, GetHtmlPipelineContext(ctx)); list.Add(p); } } return list; } catch (NoCustomContextException e) { throw new RuntimeWorkerException( LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e); } }