Class LinkContext

java.lang.Object
com.itextpdf.html2pdf.attach.impl.LinkContext
All Implemented Interfaces:
IDocumentTreeJob

public class LinkContext extends Object implements IDocumentTreeJob
This class keeps track of information regarding link (destinations) that occur in the document. Doing so enables us to drastically trim the amount of PdfDestinations that will end up being included in the document. For performance reasons it was decided to scan the DOM tree only once and store the result in a separate object (this object) in the ProcessorContext.

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

  • Constructor Details

    • LinkContext

      public LinkContext()
      Construct an (empty) LinkContext
  • Method Details

    • scanForIds

      @Deprecated public LinkContext scanForIds (com.itextpdf.styledxmlparser.node.INode root)
      Deprecated.
      Scan the DOM tree for all (internal) link targets Deprecated in favor of process(INode, int)
      Parameters:
      root - the DOM tree root node
      Returns:
      this LinkContext
    • process

      public void process (com.itextpdf.styledxmlparser.node.INode node, int level)
      Check if an element is a link.
      Specified by:
      process in interface IDocumentTreeJob
      Parameters:
      node - the node to process
      level - the hierarchical level of the node in the document tree structure
    • isUsedLinkDestination

      public boolean isUsedLinkDestination (String linkDestination)
      Returns whether a given (internal) link destination is used by at least one href element in the document
      Parameters:
      linkDestination - link destination
      Returns:
      whether a given (internal) link destination is used by at least one href element in the document
    • addLinkAnnotation

      public void addLinkAnnotation (String id, com.itextpdf.kernel.pdf.annot.PdfLinkAnnotation annot)
      Add link annotation to the context.
      Parameters:
      id - link destination.
      annot - link annotation to store.
    • getLinkAnnotation

      public com.itextpdf.kernel.pdf.annot.PdfLinkAnnotation getLinkAnnotation (String id)
      Get link annotation.
      Parameters:
      id - link destination.
      Returns:
      link annotation for the given link destination.