Class OutlineHandler
java.lang.Object
com.itextpdf.html2pdf.attach.impl.OutlineHandler
A
OutlineHandler handles creating outlines for marks. Marks are extracted via interface IOutlineMarkExtractor.
This class is not reusable and a new instance shall be created for every new conversion process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.itextpdf.kernel.pdf.PdfOutlineThe current outline.protected DequeString, com.itextpdf.kernel.pdf.PdfDictionary>> The destinations in process.The levels in process.protected IOutlineMarkExtractorThe mark extractor defines what part of element will be used to create outline -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected OutlineHandleraddOutlineAndDestToDocument(ITagWorker tagWorker, com.itextpdf.styledxmlparser.node.IElementNode element, ProcessorContext context) Adds the outline and the destination.static OutlineHandlercreateHandler(IOutlineMarkExtractor extractor) Creates an OutlineHandler with customIOutlineMarkExtractorstatic OutlineHandlerCreates an OutlineHandler with standardTagOutlineMarkExtractorand predefined mappings.protected StringgenerateOutlineName(com.itextpdf.styledxmlparser.node.IElementNode element) Generate the outline name.protected StringgenerateUniqueDestinationName(com.itextpdf.styledxmlparser.node.IElementNode element) Generate the unique destination name.Gets the destination name prefix.Get mark extractor.getMarkPriorityMapping(String markName) Gets the mark from priority mapping.booleanhasMarkPriorityMapping(String markName) Checks for tag in priority mapping.putAllMarksPriorityMappings(Map<String, Integer> mappings) Put all marks into priority mappings.putMarkPriorityMapping(String markName, Integer priority) Put mark into priority mapping.voidreset()Resets the current state so that thisOutlineHandleris ready to process new documentvoidsetDestinationNamePrefix(String destinationNamePrefix) Sets the destination name prefix.protected OutlineHandlersetDestinationToElement(ITagWorker tagWorker, com.itextpdf.styledxmlparser.node.IElementNode element) Sets the destination to element.setMarkExtractor(IOutlineMarkExtractor extractor) Set mark extractor.
-
Field Details
-
currentOutline
protected com.itextpdf.kernel.pdf.PdfOutline currentOutlineThe current outline. -
destinationsInProcess
The destinations in process. -
levelsInProcess
The levels in process. -
markExtractor
The mark extractor defines what part of element will be used to create outline
-
-
Constructor Details
-
OutlineHandler
public OutlineHandler()Creates an OutlineHandler with standardTagOutlineMarkExtractor.
-
-
Method Details
-
createStandardHandler
Creates an OutlineHandler with standardTagOutlineMarkExtractorand predefined mappings.- Returns:
- the outline handler
-
createHandler
Creates an OutlineHandler with customIOutlineMarkExtractor- Parameters:
-
extractor- the mark extractor - Returns:
- the outline handler
-
getMarkExtractor
Get mark extractor.- Returns:
- the mark extractor
-
setMarkExtractor
Set mark extractor.- Parameters:
-
extractor- the mark extractor - Returns:
- the outline handler
-
putMarkPriorityMapping
Put mark into priority mapping.- Parameters:
-
markName- the mark name -
priority- the priority - Returns:
- the outline handler
-
putAllMarksPriorityMappings
Put all marks into priority mappings.- Parameters:
-
mappings- the mappings - Returns:
- the outline handler
-
getMarkPriorityMapping
Gets the mark from priority mapping.- Parameters:
-
markName- the mark name - Returns:
- the tag priority mapping
-
hasMarkPriorityMapping
Checks for tag in priority mapping.- Parameters:
-
markName- the mark name - Returns:
- true, if the tag name is listed in the tag priorities mapping
-
reset
public void reset()Resets the current state so that thisOutlineHandleris ready to process new document -
setDestinationNamePrefix
Sets the destination name prefix. The destination name prefix serves as the prefix for the destination names created in thegenerateUniqueDestinationName(com.itextpdf.styledxmlparser.node.IElementNode)method.- Parameters:
-
destinationNamePrefix- the destination name prefix
-
getDestinationNamePrefix
Gets the destination name prefix. The destination name prefix serves as the prefix for the destination names created in thegenerateUniqueDestinationName(com.itextpdf.styledxmlparser.node.IElementNode)method.- Returns:
- the destination name prefix
-
generateUniqueDestinationName
protected String generateUniqueDestinationName(com.itextpdf.styledxmlparser.node.IElementNode element) Generate the unique destination name. The destination name is a unique identifier for the outline so it is generated for the outline in theaddOutlineAndDestToDocument(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.styledxmlparser.node.IElementNode, com.itextpdf.html2pdf.attach.ProcessorContext)method. You can override this method to set your own way to generate the destination names, to avoid the destination name conflicts when merging several PDF files created by html2pdf.- Parameters:
-
element- the element - Returns:
- the unique destination name
-
generateOutlineName
Generate the outline name. This method is used in theaddOutlineAndDestToDocument(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.styledxmlparser.node.IElementNode, com.itextpdf.html2pdf.attach.ProcessorContext)method. You can override this method to set your own way to generate the outline names.- Parameters:
-
element- the element - Returns:
- the unique destination name
-
addOutlineAndDestToDocument
protected OutlineHandler addOutlineAndDestToDocument(ITagWorker tagWorker, com.itextpdf.styledxmlparser.node.IElementNode element, ProcessorContext context) Adds the outline and the destination. Adds the outline and its corresponding the destination to the PDF document if the priority mapping is set for the element.- Parameters:
-
tagWorker- the tag worker -
element- the element -
context- the processor context - Returns:
- the outline handler
-
setDestinationToElement
protected OutlineHandler setDestinationToElement(ITagWorker tagWorker, com.itextpdf.styledxmlparser.node.IElementNode element) Sets the destination to element. Sets the destination previously created in theaddOutlineAndDestToDocument(com.itextpdf.html2pdf.attach.ITagWorker, com.itextpdf.styledxmlparser.node.IElementNode, com.itextpdf.html2pdf.attach.ProcessorContext)method to the tag worker element.- Parameters:
-
tagWorker- the tag worker -
element- the element - Returns:
- the outline handler
-