com.itextpdf.tool.xml.pipeline.html
Class HtmlPipelineContext

java.lang.Object
  extended by 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 HtmlPipeline.

Author:
redlab_b

Field Summary
static String BOOKMARK_TREE
          Key for the memory, used to store bookmark nodes
static String LAST_MARGIN_BOTTOM
          Key for the memory, used in Html TagProcessing
 
Constructor Summary
HtmlPipelineContext(CssAppliers cssAppliers)
          Construct a new HtmlPipelineContext object
 
Method Summary
 boolean acceptUnknown()
           
protected  void addFirst(StackKeeper stackKeeper)
          Add a StackKeeper to the top of the stack list.
 boolean autoBookmark()
           
 HtmlPipelineContext autoBookmark(boolean autoBookmark)
          Set to true to enable the automatic creation of bookmarks on <h1> to <h6> tags.
 Charset charSet()
           
 HtmlPipelineContext charSet(Charset cSet)
          Set a Charset to use.
 HtmlPipelineContext clone()
          Create a clone of this HtmlPipelineContext, the clone only contains the initial values, not the internal values.
protected  List<Element> currentContent()
           
 CssAppliers getCssAppliers()
           
 ImageProvider getImageProvider()
           
 Float getLastMarginBottom()
           
 LinkProvider getLinkProvider()
          Returns the LinkProvider, used to prepend e.g. http://www.example.org/ to found <a> tags that have no absolute url.
 Map<String,Object> getMemory()
           
 Rectangle getPageSize()
          Returns a Rectangle
 List<String> getRootTags()
           
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)
           
 HtmlPipelineContext setAcceptUnknown(boolean acceptUnknown)
          Set to true to allow the HtmlPipeline to accept tags it does not find in the given TagProcessorFactory
 HtmlPipelineContext setCssApplier(CssAppliers cssAppliers)
          Fluent variant of setCssAppliers(CssAppliers)
 void setCssAppliers(CssAppliers cssAppliers)
           
 HtmlPipelineContext setImageProvider(ImageProvider imageProvider)
          An ImageProvider can be provided and works in conjunction with Image and ListStyleTypeCssApplier for List Images.
 void setLastMarginBottom(Float lmb)
          Set the last margin bottom.
 HtmlPipelineContext setLinkProvider(LinkProvider linkprovider)
          Set the LinkProvider to use if any.
 HtmlPipelineContext setPageSize(Rectangle pageSize)
          If no pageSize is set, the default value A4 is used.
 HtmlPipelineContext setRootTags(List<String> roottags)
          Set the root-tags, this matters for margins.
 HtmlPipelineContext setTagFactory(TagProcessorFactory tagFactory)
          Set the TagProcessorFactory to be used.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOKMARK_TREE

public static final String BOOKMARK_TREE
Key for the memory, used to store bookmark nodes

See Also:
Constant Field Values

LAST_MARGIN_BOTTOM

public static final String LAST_MARGIN_BOTTOM
Key for the memory, used in Html TagProcessing

See Also:
Constant Field Values
Constructor Detail

HtmlPipelineContext

public HtmlPipelineContext(CssAppliers cssAppliers)
Construct a new HtmlPipelineContext object

Method Detail

resolveProcessor

protected TagProcessor resolveProcessor(String tag,
                                        String nameSpace)
Parameters:
tag - the tag to find a TagProcessor for
nameSpace - the namespace.
Returns:
a TagProcessor

addFirst

protected void addFirst(StackKeeper stackKeeper)
Add a StackKeeper to the top of the stack list.

Parameters:
stackKeeper - the StackKeeper

peek

protected StackKeeper peek()
                    throws NoStackException
Retrieves, but does not remove, the head (first element) of this list.

Returns:
a StackKeeper
Throws:
NoStackException - if there are no elements on the stack

currentContent

protected List<Element> 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

protected StackKeeper poll()
                    throws NoStackException
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

public Map<String,Object> getMemory()
Returns:
the memory

getImageProvider

public ImageProvider getImageProvider()
Returns:
the image provider or null if there is no ImageProvider.

charSet

@Experimental
public HtmlPipelineContext charSet(Charset cSet)
Set a Charset to use.

Parameters:
cSet - the charset.
Returns:
this HtmlPipelineContext

charSet

public Charset charSet()
Returns:
the Charset to use, or null if none configured.

getPageSize

public Rectangle getPageSize()
Returns a Rectangle

Specified by:
getPageSize in interface PageSizeContainable
Returns:
the pagesize.

getRootTags

public List<String> getRootTags()
Specified by:
getRootTags in interface MarginMemory
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

public LinkProvider 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

public HtmlPipelineContext setPageSize(Rectangle pageSize)
If no pageSize is set, the default value A4 is used.

Parameters:
pageSize - the pageSize to set
Returns:
this HtmlPipelineContext

clone

public HtmlPipelineContext clone()
                          throws CloneNotSupportedException
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 (new AbstractImageProvider with same ImageRootPath) , TagProcessorFactory (same object), acceptUnknown (primitive), charset (Charset.forName to get a new charset), autobookmark (primitive) are copied.

Overrides:
clone in class Object
Throws:
CloneNotSupportedException

setAcceptUnknown

public HtmlPipelineContext setAcceptUnknown(boolean acceptUnknown)
Set to true to allow the HtmlPipeline to accept tags it does not find in the given TagProcessorFactory

Parameters:
acceptUnknown - true or false
Returns:
this HtmlPipelineContext

setTagFactory

public HtmlPipelineContext setTagFactory(TagProcessorFactory tagFactory)
Set the TagProcessorFactory to be used. For HTML use Tags.getHtmlTagProcessorFactory()

Parameters:
tagFactory - the TagProcessorFactory that should be used
Returns:
this HtmlPipelineContext

autoBookmark

public HtmlPipelineContext autoBookmark(boolean autoBookmark)
Set to true to enable the automatic creation of bookmarks on <h1> to <h6> tags. Works in conjunction with Header.

Parameters:
autoBookmark - true or false
Returns:
this HtmlPipelineContext

setRootTags

public HtmlPipelineContext setRootTags(List<String> roottags)
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

public HtmlPipelineContext setImageProvider(ImageProvider imageProvider)
An ImageProvider can be provided and works in conjunction with Image and ListStyleTypeCssApplier for List Images.

Parameters:
imageProvider - the ImageProvider to use.
Returns:
this HtmlPipelineContext

setLinkProvider

public HtmlPipelineContext setLinkProvider(LinkProvider linkprovider)
Set the LinkProvider to use if any.

Parameters:
linkprovider - the LinkProvider (@see getLinkProvider()
Returns:
this HtmlPipelineContext

getLastMarginBottom

public Float getLastMarginBottom()
                          throws NoDataException
Specified by:
getLastMarginBottom in interface MarginMemory
Returns:
a Float
Throws:
NoDataException - if there is no LastMarginBottom set

setLastMarginBottom

public void setLastMarginBottom(Float lmb)
Description copied from interface: MarginMemory
Set the last margin bottom.

Specified by:
setLastMarginBottom in interface MarginMemory
Parameters:
lmb - set the float for lmb

setCssAppliers

public void setCssAppliers(CssAppliers cssAppliers)
Specified by:
setCssAppliers in interface CssAppliersAware
Parameters:
cssAppliers - the CssAppliers

getCssAppliers

public CssAppliers getCssAppliers()
Specified by:
getCssAppliers in interface CssAppliersAware
Returns:
the CssAppliers

setCssApplier

public HtmlPipelineContext setCssApplier(CssAppliers cssAppliers)
Fluent variant of setCssAppliers(CssAppliers)

Parameters:
cssAppliers - the cssAppliers
Returns:
this


Copyright © 2015. All Rights Reserved.