Class AbstractTagProcessor

    • Field Detail

      • ignoreDirAttribute

        private java.util.Set<java.lang.String> ignoreDirAttribute
        For some tags, if they have their own not inherited DIR attribute, this attribute will definitely not be applied for itext layout. For the most common such tags we use this set to ignore DIR attribute, in order to avoid unnecessary adjustments in XmlWorker. However if parent of these tags have DIR attribute, it may be applied to these tags.
      • tree

        private java.util.List<Tag> tree
    • Constructor Detail

      • AbstractTagProcessor

        public AbstractTagProcessor()
    • Method Detail

      • content

        public java.util.List<Element> content​(WorkerContext ctx,
                                               Tag tag,
                                               java.lang.String content)
        Description copied from interface: TagProcessor
        This method is called if there is text content encountered between the opening and closing tags this TagProcessor is mapped to.
        Specified by:
        content in interface TagProcessor
        Parameters:
        ctx - the WorkerContext
        tag - the tag encountered
        content - the text content between the tags this TagProcessor is mapped to.
        Returns:
        the element to add to the currentContent list
      • getParentDirection

        private java.lang.String getParentDirection()
      • getRunDirection

        protected int getRunDirection​(Tag tag)
      • textContent

        protected java.util.List<Element> textContent​(WorkerContext ctx,
                                                      Tag tag,
                                                      java.lang.String content)
      • endElement

        public final java.util.List<Element> endElement​(WorkerContext ctx,
                                                        Tag tag,
                                                        java.util.List<Element> currentContent)
        Checks for CSS.Property.PAGE_BREAK_AFTER, if the value is always a Chunk.NEXTPAGE is added to the currentContentList after calling end(WorkerContext, Tag, List).
        Specified by:
        endElement in interface TagProcessor
        Parameters:
        ctx - the WorkerContext
        tag - the tag encountered
        currentContent - a list of content possibly created by TagProcessing of inner tags, and by startElement and content methods of this TagProcessor .
        Returns:
        the resulting element to add to the document or a content stack.
      • end

        public java.util.List<Element> end​(WorkerContext ctx,
                                           Tag tag,
                                           java.util.List<Element> currentContent)
        Classes extending AbstractTagProcessor should override this method for actions that should be done in TagProcessor.endElement(WorkerContext, Tag, List). The endElement(WorkerContext, Tag, List) calls this method after or before doing certain stuff, (see it's description).
        Parameters:
        ctx - the WorkerContext
        tag - the tag
        currentContent - the content created from e.g. inner tags, inner content and not yet added to document.
        Returns:
        a List containing iText Element objects
      • currentContentToParagraph

        public java.util.List<Element> currentContentToParagraph​(java.util.List<Element> currentContent,
                                                                 boolean addNewLines,
                                                                 boolean applyCSS,
                                                                 Tag tag,
                                                                 WorkerContext ctx)
        Adds currentContent list to a paragraph element. If addNewLines is true a Paragraph object is returned, else a NoNewLineParagraph object is returned.
        Parameters:
        currentContent - List of the current elements to be added.
        addNewLines - boolean to declare which paragraph element should be returned, true if new line should be added or not.
        applyCSS - true if CSS should be applied on the paragraph.
        tag - the relevant tag.
        ctx - the WorkerContext.
        Returns:
        a List of paragraphs.
      • currentContentToParagraph

        public final java.util.List<Element> currentContentToParagraph​(java.util.List<Element> currentContent,
                                                                       boolean addNewLines)
        Default apply CSS to false and tag to null.
        Parameters:
        currentContent - List of the current elements to be added.
        addNewLines - boolean to declare which paragraph element should be returned, true if new line should be added or not.
        Returns:
        a List with paragraphs
        See Also:
        currentContentToParagraph(List, boolean, boolean, Tag, WorkerContext)
      • createParagraph

        protected Paragraph createParagraph()
      • doRtlIndentCorrections

        protected void doRtlIndentCorrections​(Indentable p)
      • invertTextAlignForParagraph

        protected void invertTextAlignForParagraph​(Paragraph p)
      • invertTextAlignForParagraph

        protected void invertTextAlignForParagraph​(NoNewLineParagraph p)
      • updateParagraphFontIfNeeded

        protected void updateParagraphFontIfNeeded​(Phrase p,
                                                   Element child)
        In case child font is of bigger size than paragraph font, text overlapping may occur. This happens because leading of the lines in paragraph is set based on paragraph font.