Class OutlineHandler

java.lang.Object
com.itextpdf.html2pdf.attach.impl.OutlineHandler

public class OutlineHandler extends Object
A OutlineHandler handles creating outlines for tags.

This class is not reusable and a new instance shall be created for every new conversion process.

  • Constructor Details

    • OutlineHandler

      public OutlineHandler()
  • Method Details

    • createStandardHandler

      public static OutlineHandler createStandardHandler()
      Creates an OutlineHandler with standard predefined mappings.
      Returns:
      the outline handler
    • putTagPriorityMapping

      public OutlineHandler putTagPriorityMapping (String tagName, Integer priority)
      Put tag priority mapping.
      Parameters:
      tagName - the tag name
      priority - the priority
      Returns:
      the outline handler
    • putAllTagPriorityMappings

      public OutlineHandler putAllTagPriorityMappings (Map<String,Integer> mappings)
      Put all tag priority mappings.
      Parameters:
      mappings - the mappings
      Returns:
      the outline handler
    • getTagPriorityMapping

      public Integer getTagPriorityMapping (String tagName)
      Gets the tag priority mapping.
      Parameters:
      tagName - the tag name
      Returns:
      the tag priority mapping
    • hasTagPriorityMapping

      public boolean hasTagPriorityMapping (String tagName)
      Checks for tag priority mapping.
      Parameters:
      tagName - the tag name
      Returns:
      true, if the tag name is listed in the tag priorities mapping
    • reset

      public void reset()
      Resets the current state so that this OutlineHandler is ready to process new document
    • setDestinationNamePrefix

      public void setDestinationNamePrefix (String destinationNamePrefix)
      Sets the destination name prefix. The destination name prefix serves as the prefix for the destination names created in the generateUniqueDestinationName(com.itextpdf.styledxmlparser.node.IElementNode) method.
      Parameters:
      destinationNamePrefix - the destination name prefix
    • getDestinationNamePrefix

      public String getDestinationNamePrefix()
      Gets the destination name prefix. The destination name prefix serves as the prefix for the destination names created in the generateUniqueDestinationName(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 the addOutlineAndDestToDocument(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

      protected String generateOutlineName (com.itextpdf.styledxmlparser.node.IElementNode element)
      Generate the outline name. This method is used in the addOutlineAndDestToDocument(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