public string Execute(IBlockElement block)
    {
        var template   = TemplateTagCollection.GetTagForType(TagType.Header1);
        var inlineText = InlineConverter.Process(((Header)block).Inlines).ToList();

        return(TemplateFiller.Fill(template, String.Join(Environment.NewLine, inlineText)));
    }
Exemple #2
0
        public void Build(ITemplate template, string outputpath)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(outputpath));
            Document    document = new Document(pdf);
            var         elements = template.GetElements();

            foreach (var element in elements)
            {
                if (element is AreaBreak)
                {
                    AreaBreak areaBreak = (AreaBreak)element;
                    document.Add(areaBreak);
                }
                else if (element is IBlockElement)
                {
                    IBlockElement blockElement = (IBlockElement)element;
                    document.Add(blockElement);
                }
                else if (element is Image)
                {
                    Image image = (Image)element;
                    document.Add(image);
                }
            }
            document.Flush();
            document.Close();
        }
Exemple #3
0
        /// <summary>Adds an unlabeled list item.</summary>
        /// <param name="item">the item</param>
        private void AddUnlabeledListItem(IBlockElement item)
        {
            ListItem li = new ListItem();

            li.Add(item);
            li.SetProperty(Property.LIST_SYMBOL, null);
            list.Add(li);
        }
Exemple #4
0
 /// <summary>Adds an element to the root.</summary>
 /// <remarks>Adds an element to the root. The element is immediately placed in the contents.</remarks>
 /// <param name="element">an element with spacial margins, tabbing, and alignment</param>
 /// <returns>this element</returns>
 /// <seealso cref="iText.Layout.Element.BlockElement{T}"/>
 public virtual T Add(IBlockElement element)
 {
     childElements.Add(element);
     CreateAndAddRendererSubTree(element);
     if (immediateFlush)
     {
         childElements.JRemoveAt(childElements.Count - 1);
     }
     return((T)(Object)this);
 }
Exemple #5
0
 public override iText.Layout.Document Add(IBlockElement element)
 {
     CheckClosingStatus();
     base.Add(element);
     if (element is ILargeElement)
     {
         ((ILargeElement)element).SetDocument(this);
         ((ILargeElement)element).FlushContent();
     }
     return(this);
 }
Exemple #6
0
 private static float ToEffectiveWidth(IBlockElement b, float fullWidth)
 {
     if (b is Table)
     {
         return(fullWidth + ((Table)b).GetNumberOfColumns() * MinMaxWidthUtils.GetEps());
     }
     else
     {
         return(fullWidth - MinMaxWidthUtils.GetBorderWidth(b) - MinMaxWidthUtils.GetMarginsWidth(b) - MinMaxWidthUtils
                .GetPaddingWidth(b) + MinMaxWidthUtils.GetEps());
     }
 }
    public string Execute(IBlockElement block)
    {
        var b          = (Paragraph)block;
        var inlineText = String.Empty;

        if (b.Inlines != null)
        {
            inlineText = string.Join(Environment.NewLine, InlineConverter.Process(b.Inlines).ToList());
        }

        var template = TemplateTagCollection.GetTagForType(TagType.Paragraph);

        return(TemplateFiller.Fill(template, inlineText));
    }
        /* (non-JavadDioc)
         * @see com.itextpdf.html2pdf.attach.ITagWorker#processTagChild(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.html2pdf.attach.ProcessorContext)
         */
        public virtual bool ProcessTagChild(ITagWorker childTagWorker, ProcessorContext context)
        {
            bool displayTableCell = childTagWorker is IDisplayAware && CssConstants.TABLE_CELL.Equals(((IDisplayAware)
                                                                                                       childTagWorker).GetDisplay());

            if (childTagWorker.GetElementResult() is IBlockElement)
            {
                IBlockElement childResult = (IBlockElement)childTagWorker.GetElementResult();
                Cell          curCell     = childResult is Cell ? (Cell)childResult : CreateWrapperCell().Add(childResult);
                ProcessCell(curCell, displayTableCell);
                return(true);
            }
            else
            {
                if (childTagWorker.GetElementResult() is ILeafElement)
                {
                    inlineHelper.Add((ILeafElement)childTagWorker.GetElementResult());
                    return(true);
                }
                else
                {
                    if (childTagWorker is SpanTagWorker)
                    {
                        if (displayTableCell)
                        {
                            FlushWaitingCell();
                        }
                        bool allChildrenProcessed = true;
                        foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements())
                        {
                            if (propertyContainer is ILeafElement)
                            {
                                inlineHelper.Add((ILeafElement)propertyContainer);
                            }
                            else
                            {
                                allChildrenProcessed = false;
                            }
                        }
                        if (displayTableCell)
                        {
                            FlushWaitingCell();
                        }
                        return(allChildrenProcessed);
                    }
                }
            }
            return(false);
        }
 /// <summary>Adds a container with option(s).</summary>
 /// <remarks>Adds a container with option(s). This might be a container for options group.</remarks>
 /// <param name="optionElement">a container with option(s)</param>
 public virtual void AddOption(IBlockElement optionElement)
 {
     options.Add(optionElement);
 }
Exemple #10
0
 /// <summary>Adds any block element to the div's contents.</summary>
 /// <param name="element">
 /// a
 /// <see cref="BlockElement{T}"/>
 /// </param>
 /// <returns>this Element</returns>
 public virtual Div Add(IBlockElement element)
 {
     childElements.Add(element);
     return(this);
 }
Exemple #11
0
 public virtual iText.Layout.Element.Paragraph Add(IBlockElement element)
 {
     childElements.Add(element);
     return(this);
 }
Exemple #12
0
 /// <summary>Adds any block element to the div's contents.</summary>
 /// <param name="element">
 /// a
 /// <see cref="iText.Layout.Element.BlockElement{T}"/>
 /// </param>
 /// <returns>this Element</returns>
 public virtual iText.Html2pdf.Attach.Impl.Layout.Form.Element.ButtonContainer Add(IBlockElement element)
 {
     childElements.Add(element);
     return(this);
 }
Exemple #13
0
 /// <summary>Adds a child block element.</summary>
 /// <param name="block">the block element to add</param>
 public virtual void Add(IBlockElement block)
 {
     children.Add(block);
 }
Exemple #14
0
 public virtual void Add(IBlockElement element)
 {
     waitingLeaves.Add(element);
 }
Exemple #15
0
        /* (non-Javadoc)
         * @see com.itextpdf.html2pdf.attach.ITagWorker#processTagChild(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.html2pdf.attach.ProcessorContext)
         */
        public virtual bool ProcessTagChild(ITagWorker childTagWorker, ProcessorContext context)
        {
            bool displayTableCell = childTagWorker is IDisplayAware && CssConstants.TABLE_CELL.Equals(((IDisplayAware)
                                                                                                       childTagWorker).GetDisplay());

            if (currentRowIsFinished)
            {
                tableWrapper.NewRow();
            }
            if (childTagWorker is DisplayTableRowTagWorker)
            {
                FlushWaitingCell();
                if (!currentRowIsFinished)
                {
                    tableWrapper.NewRow();
                }
                TableRowWrapper wrapper = ((DisplayTableRowTagWorker)childTagWorker).GetTableRowWrapper();
                foreach (Cell cell in wrapper.GetCells())
                {
                    tableWrapper.AddCell(cell);
                }
                currentRowIsFinished = true;
                return(true);
            }
            else
            {
                if (childTagWorker.GetElementResult() is IBlockElement)
                {
                    IBlockElement childResult = (IBlockElement)childTagWorker.GetElementResult();
                    Cell          curCell     = childResult is Cell ? (Cell)childResult : CreateWrapperCell().Add(childResult);
                    ProcessCell(curCell, displayTableCell);
                    currentRowIsFinished = false;
                    return(true);
                }
                else
                {
                    if (childTagWorker.GetElementResult() is ILeafElement)
                    {
                        inlineHelper.Add((ILeafElement)childTagWorker.GetElementResult());
                        currentRowIsFinished = false;
                        return(true);
                    }
                    else
                    {
                        if (childTagWorker is SpanTagWorker)
                        {
                            // the previous one
                            if (displayTableCell)
                            {
                                FlushWaitingCell();
                            }
                            bool allChildrenProcessed = true;
                            foreach (IPropertyContainer propertyContainer in ((SpanTagWorker)childTagWorker).GetAllElements())
                            {
                                if (propertyContainer is ILeafElement)
                                {
                                    inlineHelper.Add((ILeafElement)propertyContainer);
                                }
                                else
                                {
                                    allChildrenProcessed = false;
                                }
                            }
                            // the current one
                            if (displayTableCell)
                            {
                                FlushWaitingCell();
                            }
                            currentRowIsFinished = false;
                            return(allChildrenProcessed);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #16
0
 public void Add(IBlockElement element)
 {
     elements.Add(element);
 }