public abstract class AbstractTagProcessor extends Object implements TagProcessor, CssAppliersAware
TagProcessor.startElement(WorkerContext, Tag)
and TagProcessor.endElement(WorkerContext, Tag, List)
to calculate font sizes and add new pages if needed.
TagProcessor
to benefit from auto fontsize metric conversion to pt and page-break-before/after insertion. Override start(WorkerContext, Tag)
and end(WorkerContext, Tag, List)
in your extension.
Constructor and Description |
---|
AbstractTagProcessor() |
Modifier and Type | Method and Description |
---|---|
List<Element> |
content(WorkerContext ctx, Tag tag, String content)
This method is called if there is text content encountered between the opening and closing tags this TagProcessor is mapped to.
|
protected Paragraph |
createParagraph() |
List<Element> |
currentContentToParagraph(List<Element> currentContent, boolean addNewLines)
Default apply CSS to false and tag to null.
|
List<Element> |
currentContentToParagraph(List<Element> currentContent, boolean addNewLines, boolean applyCSS, Tag tag, WorkerContext ctx)
Adds currentContent list to a paragraph element.
|
protected void |
doRtlIndentCorrections(Indentable p) |
List<Element> |
end(WorkerContext ctx, Tag tag, List<Element> currentContent)
Classes extending AbstractTagProcessor should override this method for actions that should be done in TagProcessor.endElement(WorkerContext, Tag, List) .
|
List<Element> |
endElement(WorkerContext ctx, Tag tag, 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) .
|
CssAppliers |
getCssAppliers() |
CSSResolver |
getCSSResolver(WorkerContext context)
Utility method that fetches the CSSResolver from the if any and if it uses the default key.
|
HtmlPipelineContext |
getHtmlPipelineContext(WorkerContext context)
Utility method that fetches the HtmlPipelineContext used if any and if it uses the default key.
|
protected int |
getRunDirection(Tag tag) |
protected void |
invertTextAlignForParagraph(NoNewLineParagraph p) |
protected void |
invertTextAlignForParagraph(Paragraph p) |
boolean |
isStackOwner()
Defaults to false.
|
void |
setCssAppliers(CssAppliers cssAppliers) |
List<Element> |
start(WorkerContext ctx, Tag tag)
Classes extending AbstractTagProcessor should override this method for actions that should be done in TagProcessor.startElement(WorkerContext, Tag) .
|
List<Element> |
startElement(WorkerContext ctx, Tag tag)
Calculates any found font size to pt values and set it in the CSS before calling start(WorkerContext, Tag) .
Checks for CSS.Property.PAGE_BREAK_BEFORE , if the value is always a Chunk.NEXTPAGE added before the implementors start(WorkerContext, Tag) method.
|
protected List<Element> |
textContent(WorkerContext ctx, Tag tag, String content) |
protected void |
updateParagraphFontIfNeeded(Phrase p, Element child)
In case child font is of bigger size than paragraph font, text overlapping may occur.
|
public CSSResolver getCSSResolver(WorkerContext context) throws NoCustomContextException
context
- the WorkerContext
NoCustomContextException
- if the context of the CssResolverPipeline
could not be found.
public HtmlPipelineContext getHtmlPipelineContext(WorkerContext context) throws NoCustomContextException
context
- the WorkerContext
NoCustomContextException
- if the context of the HtmlPipelineContext
could not be found.
public final List<Element> startElement(WorkerContext ctx, Tag tag)
start(WorkerContext, Tag)
.
CSS.Property.PAGE_BREAK_BEFORE
, if the value is always a Chunk.NEXTPAGE
added before the implementors start(WorkerContext, Tag)
method.
startElement
in interface TagProcessor
ctx
- the WorkerContext
tag
- the tag encountered
public List<Element> start(WorkerContext ctx, Tag tag)
TagProcessor.startElement(WorkerContext, Tag)
. The startElement(WorkerContext, Tag)
calls this method after or before doing certain stuff, (see it's description).
ctx
- the WorkerContext
tag
- the tag
public List<Element> content(WorkerContext ctx, Tag tag, String content)
TagProcessor
content
in interface TagProcessor
ctx
- the WorkerContext
tag
- the tag encountered
content
- the text content between the tags this TagProcessor is mapped to.
protected int getRunDirection(Tag tag)
protected List<Element> textContent(WorkerContext ctx, Tag tag, String content)
public final List<Element> endElement(WorkerContext ctx, Tag tag, List<Element> currentContent)
CSS.Property.PAGE_BREAK_AFTER
, if the value is always a Chunk.NEXTPAGE
is added to the currentContentList after calling end(WorkerContext, Tag, List)
.
endElement
in interface TagProcessor
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
.
public List<Element> end(WorkerContext ctx, Tag tag, List<Element> currentContent)
TagProcessor.endElement(WorkerContext, Tag, List)
. The endElement(WorkerContext, Tag, List)
calls this method after or before doing certain stuff, (see it's description).
ctx
- the WorkerContext
tag
- the tag
currentContent
- the content created from e.g. inner tags, inner content and not yet added to document.
public boolean isStackOwner()
isStackOwner
in interface TagProcessor
TagProcessor.isStackOwner()
public List<Element> currentContentToParagraph(List<Element> currentContent, boolean addNewLines, boolean applyCSS, Tag tag, WorkerContext ctx)
currentContent
- ListaddNewLines
- 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.
public final List<Element> currentContentToParagraph(List<Element> currentContent, boolean addNewLines)
currentContent
- ListaddNewLines
- boolean to declare which paragraph element should be returned, true if new line should be added or not.
currentContentToParagraph(List, boolean, boolean, Tag, WorkerContext)
public void setCssAppliers(CssAppliers cssAppliers)
setCssAppliers
in interface CssAppliersAware
cssAppliers
- the CssAppliers
public CssAppliers getCssAppliers()
getCssAppliers
in interface CssAppliersAware
protected Paragraph createParagraph()
protected void doRtlIndentCorrections(Indentable p)
protected void invertTextAlignForParagraph(Paragraph p)
protected void invertTextAlignForParagraph(NoNewLineParagraph p)
Copyright © 1998–2017. All rights reserved.