Class HtmlPipelineContext
java.lang.Object
com.itextpdf.tool.xml.pipeline.html.HtmlPipelineContext
- All Implemented Interfaces:
MarginMemory
,PageSizeContainable
,CustomContext
,CssAppliersAware
,Cloneable
public class HtmlPipelineContext
extends Object
implements CustomContext, Cloneable, MarginMemory, PageSizeContainable, CssAppliersAware
The CustomContext object for the HtmlPipeline.
Use this to configure your
Use this to configure your
HtmlPipeline
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
static final String
Key for the memory, used to store bookmark nodesprivate Charset
private CssAppliers
private ImageProvider
static final String
Key for the memory, used in Html TagProcessingprivate LinkProvider
private Rectangle
private final LinkedList
<StackKeeper> private String
private TagProcessorFactory
-
Constructor Summary
ConstructorsConstructorDescriptionHtmlPipelineContext
(CssAppliers cssAppliers) Construct a new HtmlPipelineContext object -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected void
addFirst
(StackKeeper stackKeeper) Add aStackKeeper
to the top of the stack list.boolean
autoBookmark
(boolean autoBookmark) Set to true to enable the automatic creation of bookmarks on <h1> to <h6> tags.charSet()
Set aCharset
to use.clone()
Create a clone of this HtmlPipelineContext, the clone only contains the initial values, not the internal values.Returns the LinkProvider, used to prepend e.g.Returns aRectangle
protected boolean
isEmpty()
protected StackKeeper
peek()
Retrieves, but does not remove, the head (first element) of this list.protected StackKeeper
poll()
Retrieves and removes the top of the stack.protected TagProcessor
resolveProcessor
(String tag, String nameSpace) setAcceptUnknown
(boolean acceptUnknown) Set to true to allow the HtmlPipeline to accept tags it does not find in the givenTagProcessorFactory
setCssApplier
(CssAppliers cssAppliers) Fluent variant ofsetCssAppliers(CssAppliers)
void
setCssAppliers
(CssAppliers cssAppliers) setImageProvider
(ImageProvider imageProvider) An ImageProvider can be provided and works in conjunction withImage
andListStyleTypeCssApplier
for List Images.void
setLastMarginBottom
(Float lmb) Set the last margin bottom.setLinkProvider
(LinkProvider linkprovider) Set the LinkProvider to use if any.setPageSize
(Rectangle pageSize) If no pageSize is set, the default value A4 is used.void
setResourcesRootPath
(String resourcesRootPath) setRootTags
(List<String> roottags) Set the root-tags, this matters for margins.setTagFactory
(TagProcessorFactory tagFactory) Set theTagProcessorFactory
to be used.
-
Field Details
-
BOOKMARK_TREE
Key for the memory, used to store bookmark nodes- See Also:
-
LAST_MARGIN_BOTTOM
Key for the memory, used in Html TagProcessing- See Also:
-
queue
-
acceptUnknown
private boolean acceptUnknown -
tagFactory
-
ctn
-
imageProvider
-
resourcesRootPath
-
pageSize
-
charset
-
roottags
-
linkprovider
-
autoBookmark
private boolean autoBookmark -
memory
-
cssAppliers
-
-
Constructor Details
-
HtmlPipelineContext
Construct a new HtmlPipelineContext object
-
-
Method Details
-
resolveProcessor
- Parameters:
tag
- the tag to find a TagProcessor fornameSpace
- the namespace.- Returns:
- a TagProcessor
-
addFirst
Add aStackKeeper
to the top of the stack list.- Parameters:
stackKeeper
- theStackKeeper
-
peek
Retrieves, but does not remove, the head (first element) of this list.- Returns:
- a StackKeeper or null if there are no elements on the stack
-
currentContent
- Returns:
- the current content of elements.
-
acceptUnknown
public boolean acceptUnknown()- Returns:
- if this pipelines tag processing accept unknown tags: true. False otherwise
-
isEmpty
protected boolean isEmpty()- Returns:
- returns true if the stack is empty
-
poll
Retrieves and removes the top of the stack.- Returns:
- a StackKeeper
- Throws:
NoStackException
- if there are no elements on the stack
-
autoBookmark
public boolean autoBookmark()- Returns:
- true if auto-bookmarks should be enabled. False otherwise.
-
getMemory
- Returns:
- the memory
-
getImageProvider
- Returns:
- the image provider or null if there is no
ImageProvider
.
-
charSet
Set aCharset
to use.- Parameters:
cSet
- the charset.- Returns:
- this
HtmlPipelineContext
-
charSet
- Returns:
- the
Charset
to use, or null if none configured.
-
getPageSize
Returns aRectangle
- Specified by:
getPageSize
in interfacePageSizeContainable
- Returns:
- the pagesize.
-
getRootTags
- Specified by:
getRootTags
in interfaceMarginMemory
- Returns:
- a list of tags to be taken as root-tags. This matters for margins. By default the root-tags are <body> and <div>
-
getLinkProvider
Returns the LinkProvider, used to prepend e.g. http://www.example.org/ to found <a> tags that have no absolute url.- Returns:
- the LinkProvider if any.
-
setPageSize
If no pageSize is set, the default value A4 is used.- Parameters:
pageSize
- the pageSize to set- Returns:
- this
HtmlPipelineContext
-
clone
Create a clone of this HtmlPipelineContext, the clone only contains the initial values, not the internal values. Beware, the state of the current Context is not copied to the clone. Only the configurational important stuff like the LinkProvider (same object), ImageProvider (newAbstractImageProvider
with same ImageRootPath) , TagProcessorFactory (same object), acceptUnknown (primitive), charset (Charset.forName to get a new charset), autobookmark (primitive) are copied.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
setAcceptUnknown
Set to true to allow the HtmlPipeline to accept tags it does not find in the givenTagProcessorFactory
- Parameters:
acceptUnknown
- true or false- Returns:
- this
HtmlPipelineContext
-
setTagFactory
Set theTagProcessorFactory
to be used. For HTML useTags.getHtmlTagProcessorFactory()
- Parameters:
tagFactory
- theTagProcessorFactory
that should be used- Returns:
- this
HtmlPipelineContext
-
autoBookmark
Set to true to enable the automatic creation of bookmarks on <h1> to <h6> tags. Works in conjunction withHeader
.- Parameters:
autoBookmark
- true or false- Returns:
- this
HtmlPipelineContext
-
setRootTags
Set the root-tags, this matters for margins. By default these are set to <body> and <div>.- Parameters:
roottags
- the root tags- Returns:
- this
HtmlPipelineContext
-
setImageProvider
An ImageProvider can be provided and works in conjunction withImage
andListStyleTypeCssApplier
for List Images.- Parameters:
imageProvider
- theImageProvider
to use.- Returns:
- this
HtmlPipelineContext
-
setLinkProvider
Set the LinkProvider to use if any.- Parameters:
linkprovider
- the LinkProvider (@seegetLinkProvider()
- Returns:
- this
HtmlPipelineContext
-
getLastMarginBottom
- Specified by:
getLastMarginBottom
in interfaceMarginMemory
- Returns:
- a Float
- Throws:
NoDataException
- if there is no LastMarginBottom set
-
setLastMarginBottom
Description copied from interface:MarginMemory
Set the last margin bottom.- Specified by:
setLastMarginBottom
in interfaceMarginMemory
- Parameters:
lmb
- set the float for lmb
-
setCssAppliers
- Specified by:
setCssAppliers
in interfaceCssAppliersAware
- Parameters:
cssAppliers
- the CssAppliers
-
getCssAppliers
- Specified by:
getCssAppliers
in interfaceCssAppliersAware
- Returns:
- the CssAppliers
-
setCssApplier
Fluent variant ofsetCssAppliers(CssAppliers)
- Parameters:
cssAppliers
- the cssAppliers- Returns:
- this
-
getResourcesRootPath
-
setResourcesRootPath
-