Esempio n. 1
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag,
         * java.util.List)
         */
        public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent)
        {
            IList <IElement> listElements = PopulateList(currentContent);
            int size = listElements.Count;
            IList <IElement> returnedList = new List <IElement>();

            if (size > 0)
            {
                HtmlPipelineContext htmlPipelineContext = null;
                try {
                    htmlPipelineContext = GetHtmlPipelineContext(ctx);
                } catch (NoCustomContextException e) {
                    if (LOG.IsLogging(Level.ERROR))
                    {
                        LOG.Error(String.Format(LocaleMessages.GetInstance().GetMessage("customcontext.404.continue"), typeof(HtmlPipeline).FullName), e);
                    }
                }
                List list = new ListStyleTypeCssApplier().Apply(new List(), tag, htmlPipelineContext);
                int  i    = 0;
                foreach (IElement li in listElements)
                {
                    if (li is ListItem)
                    {
                        Tag child = tag.Children[i];
                        if (size == 1)
                        {
                            child.CSS[CSS.Property.MARGIN_TOP] =
                                CalculateTopOrBottomSpacing(true, false, tag, child, ctx).ToString(CultureInfo.InvariantCulture) + "pt";
                            float marginBottom = CalculateTopOrBottomSpacing(false, false, tag, child, ctx);
                            child.CSS[CSS.Property.MARGIN_BOTTOM] = marginBottom.ToString(CultureInfo.InvariantCulture) + "pt";
                        }
                        else
                        {
                            if (i == 0)
                            {
                                child.CSS[CSS.Property.MARGIN_TOP] =
                                    CalculateTopOrBottomSpacing(true, false, tag, child, ctx).ToString(CultureInfo.InvariantCulture) + "pt";
                            }
                            if (i == size - 1)
                            {
                                float marginBottom = CalculateTopOrBottomSpacing(false, true, tag, child, ctx);
                                child.CSS[CSS.Property.MARGIN_BOTTOM] = marginBottom.ToString(CultureInfo.InvariantCulture) + "pt";
                            }
                        }
                        try {
                            list.Add(new ParagraphCssApplier(GetHtmlPipelineContext(ctx)).Apply((ListItem)li, child));
                        } catch (NoCustomContextException e1) {
                            throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e1);
                        }
                    }
                    else
                    {
                        list.Add(li);
                    }
                    i++;
                }
                returnedList.Add(list);
            }
            return(returnedList);
        }
Esempio n. 2
0
 /**
  *
  */
 public CssAppliers()
 {
     chunk              = new ChunkCssApplier();
     paragraph          = new ParagraphCssApplier();
     nonewlineparagraph = new NoNewLineParagraphCssApplier();
     htmlcell           = new HtmlCellCssApplier();
     list          = new ListStyleTypeCssApplier();
     lineseparator = new LineSeparatorCssApplier();
     image         = new ImageCssApplier();
 }
Esempio n. 3
0
        /**
         *
         */

        public CssAppliersImpl()
        {
            map = new Dictionary <Type, ICssApplier>();
            map[typeof(Chunk)]              = new ChunkCssApplier(null);
            map[typeof(Paragraph)]          = new ParagraphCssApplier(this);
            map[typeof(NoNewLineParagraph)] = new NoNewLineParagraphCssApplier();
            map[typeof(HtmlCell)]           = new HtmlCellCssApplier();
            map[typeof(List)]          = new ListStyleTypeCssApplier();
            map[typeof(LineSeparator)] = new LineSeparatorCssApplier();
            map[typeof(text.Image)]    = new ImageCssApplier();
            map[typeof(PdfDiv)]        = new DivCssApplier();
        }