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 booleanprivate booleanstatic final StringKey for the memory, used to store bookmark nodesprivate Charsetprivate CssAppliersprivate ImageProviderstatic final StringKey for the memory, used in Html TagProcessingprivate LinkProviderprivate Rectangleprivate final LinkedList<StackKeeper> private Stringprivate TagProcessorFactory -
Constructor Summary
ConstructorsConstructorDescriptionHtmlPipelineContext(CssAppliers cssAppliers) Construct a new HtmlPipelineContext object -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected voidaddFirst(StackKeeper stackKeeper) Add aStackKeeperto the top of the stack list.booleanautoBookmark(boolean autoBookmark) Set to true to enable the automatic creation of bookmarks on <h1> to <h6> tags.charSet()Set aCharsetto 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 aRectangleprotected booleanisEmpty()protected StackKeeperpeek()Retrieves, but does not remove, the head (first element) of this list.protected StackKeeperpoll()Retrieves and removes the top of the stack.protected TagProcessorresolveProcessor(String tag, String nameSpace) setAcceptUnknown(boolean acceptUnknown) Set to true to allow the HtmlPipeline to accept tags it does not find in the givenTagProcessorFactorysetCssApplier(CssAppliers cssAppliers) Fluent variant ofsetCssAppliers(CssAppliers)voidsetCssAppliers(CssAppliers cssAppliers) setImageProvider(ImageProvider imageProvider) An ImageProvider can be provided and works in conjunction withImageandListStyleTypeCssApplierfor List Images.voidsetLastMarginBottom(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.voidsetResourcesRootPath(String resourcesRootPath) setRootTags(List<String> roottags) Set the root-tags, this matters for margins.setTagFactory(TagProcessorFactory tagFactory) Set theTagProcessorFactoryto be used.
-
Field Details
-
BOOKMARK_TREE
-
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 aStackKeeperto 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
-
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
-
getImageProvider
- Returns:
- the image provider or null if there is no
ImageProvider.
-
charSet
Set aCharsetto use.- Parameters:
cSet- the charset.- Returns:
- this
HtmlPipelineContext
-
charSet
-
getPageSize
Returns aRectangle- Specified by:
getPageSizein interfacePageSizeContainable- Returns:
- the pagesize.
-
getRootTags
- Specified by:
getRootTagsin 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 (newAbstractImageProviderwith same ImageRootPath) , TagProcessorFactory (same object), acceptUnknown (primitive), charset (Charset.forName to get a new charset), autobookmark (primitive) are copied.- Overrides:
clonein 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 theTagProcessorFactoryto be used. For HTML useTags.getHtmlTagProcessorFactory()- Parameters:
tagFactory- theTagProcessorFactorythat 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 withImageandListStyleTypeCssApplierfor List Images.- Parameters:
imageProvider- theImageProviderto use.- Returns:
- this
HtmlPipelineContext
-
setLinkProvider
Set the LinkProvider to use if any.- Parameters:
linkprovider- the LinkProvider (@seegetLinkProvider()- Returns:
- this
HtmlPipelineContext
-
getLastMarginBottom
- Specified by:
getLastMarginBottomin interfaceMarginMemory- Returns:
- a Float
- Throws:
NoDataException- if there is no LastMarginBottom set
-
setLastMarginBottom
Description copied from interface:MarginMemorySet the last margin bottom.- Specified by:
setLastMarginBottomin interfaceMarginMemory- Parameters:
lmb- set the float for lmb
-
setCssAppliers
- Specified by:
setCssAppliersin interfaceCssAppliersAware- Parameters:
cssAppliers- the CssAppliers
-
getCssAppliers
- Specified by:
getCssAppliersin interfaceCssAppliersAware- Returns:
- the CssAppliers
-
setCssApplier
Fluent variant ofsetCssAppliers(CssAppliers)- Parameters:
cssAppliers- the cssAppliers- Returns:
- this
-
getResourcesRootPath
-
setResourcesRootPath
-