CssAppliersAware
, TagProcessor
Anchor
, Body
, Break
, Div
, Header
, HorizontalRule
, Image
, Link
, Meta
, NonSanitizedTag
, OrderedUnorderedList
, OrderedUnorderedListItem
, ParaGraph
, Span
, Style
, Table
, TableData
, TableRow
, Title
, XML
public abstract class AbstractTagProcessor extends java.lang.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 | Description |
---|---|
AbstractTagProcessor() |
Modifier and Type | Method | Description |
---|---|---|
java.util.List<Element> |
content(WorkerContext ctx,
Tag tag,
java.lang.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() |
|
java.util.List<Element> |
currentContentToParagraph(java.util.List<Element> currentContent,
boolean addNewLines) |
Default apply CSS to false and tag to null.
|
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.
|
protected void |
doRtlIndentCorrections(Indentable p) |
|
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) . |
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) . |
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(Paragraph p) |
|
protected void |
invertTextAlignForParagraph(NoNewLineParagraph p) |
|
boolean |
isStackOwner() |
Defaults to false.
|
void |
setCssAppliers(CssAppliers cssAppliers) |
|
java.util.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) . |
java.util.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 java.util.List<Element> |
textContent(WorkerContext ctx,
Tag tag,
java.lang.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 WorkerContextNoCustomContextException
- if the context of the
CssResolverPipeline
could not be found.public HtmlPipelineContext getHtmlPipelineContext(WorkerContext context) throws NoCustomContextException
context
- the WorkerContextNoCustomContextException
- if the context of the
HtmlPipelineContext
could not be found.public final java.util.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 WorkerContexttag
- the tag encounteredpublic java.util.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 WorkerContexttag
- the tagpublic java.util.List<Element> content(WorkerContext ctx, Tag tag, java.lang.String content)
TagProcessor
content
in interface TagProcessor
ctx
- the WorkerContexttag
- the tag encounteredcontent
- the text content between the tags this TagProcessor is
mapped to.protected int getRunDirection(Tag tag)
protected java.util.List<Element> textContent(WorkerContext ctx, Tag tag, java.lang.String content)
public final java.util.List<Element> endElement(WorkerContext ctx, Tag tag, java.util.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 WorkerContexttag
- the tag encounteredcurrentContent
- a list of content possibly created by TagProcessing
of inner tags, and by startElement
and
content
methods of this TagProcessor
.public java.util.List<Element> end(WorkerContext ctx, Tag tag, java.util.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 WorkerContexttag
- the tagcurrentContent
- 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 java.util.List<Element> currentContentToParagraph(java.util.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 java.util.List<Element> currentContentToParagraph(java.util.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 CssApplierspublic 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–2018. All rights reserved.