Class PdfTarget


  • public class PdfTarget
    extends PdfObjectWrapper<PdfDictionary>
    A target dictionary locates the target in relation to the source, in much the same way that a relative path describes the physical relationship between two files in a file system. Target dictionaries may be nested recursively to specify one or more intermediate targets before reaching the final one.
    • Constructor Detail

    • Method Detail

      • create

        public static PdfTarget create​(PdfDictionary pdfObject)
        Creates a new PdfTarget object by the underlying dictionary.
        Parameters:
        pdfObject - the underlying dictionary object
        Returns:
        a new PdfTarget object by the underlying dictionary
      • create

        private static PdfTarget create​(PdfName r)
        Creates a new PdfTarget object given its type. The type must be either PdfName.P, or PdfName.C. If it is PdfName.C, additional entries must be specified according to the spec.
        Parameters:
        r - the relationship between the current document and the target
      • createParentTarget

        public static PdfTarget createParentTarget()
        Creates a new target object pointing to the parent of the current document.
        Returns:
        created PdfTarget
      • createChildTarget

        public static PdfTarget createChildTarget()
        Creates a new target object pointing to the child of the current document.
        Returns:
        created PdfTarget
      • createChildTarget

        public static PdfTarget createChildTarget​(java.lang.String embeddedFileName)
        Creates a new target object pointing to a file in the EmbeddedFiles name tree.
        Parameters:
        embeddedFileName - the name of the file in the EmbeddedFiles name tree
        Returns:
        created object
      • createChildTarget

        public static PdfTarget createChildTarget​(java.lang.String namedDestination,
                                                  java.lang.String annotationIdentifier)
        Creates a new target object pointing to a file attachment annotation.
        Parameters:
        namedDestination - a named destination in the current document that provides the page number of the file attachment annotation
        annotationIdentifier - a unique annotation identifier (PdfName.NM entry) of the annotation
        Returns:
        created object
      • createChildTarget

        public static PdfTarget createChildTarget​(int pageNumber,
                                                  int annotationIndex)
        Creates a new target object pointing to a file attachment annotation.
        Parameters:
        pageNumber - the number of the page in the current document, one-based
        annotationIndex - the index of the annotation in the Annots entry of the page, zero-based
        Returns:
        created object
      • setName

        public PdfTarget setName​(java.lang.String name)
        Sets the name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.
        Parameters:
        name - the name of the file
        Returns:
        this object wrapper
      • getName

        public java.lang.String getName()
        Gets name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.
        Returns:
        the name of the child file for this target
      • setAnnotation

        public PdfTarget setAnnotation​(PdfFileAttachmentAnnotation pdfAnnotation,
                                       PdfDocument pdfDocument)
        Sets the /P and /A values corresponding to provided annotation, which is already added to a page.
        Parameters:
        pdfAnnotation - the annotation to be set
        pdfDocument - the corresponding document
        Returns:
        this object wrapper
      • getAnnotation

        public PdfFileAttachmentAnnotation getAnnotation​(PdfDocument pdfDocument)
        Gets the annotation specified by /A and /P entry values.
        Parameters:
        pdfDocument - specifies the corresponding document
        Returns:
        the annotation specified by /A and /P entry value.
      • setTarget

        public PdfTarget setTarget​(PdfTarget target)
        Sets a target dictionary specifying additional path information to the target document. If this entry is absent, the current document is the target file containing the destination.
        Parameters:
        target - the additional path target dictionary
        Returns:
        this object wrapper
      • getTarget

        public PdfTarget getTarget()
        Get a target dictionary specifying additional path information to the target document. If the current target object is the final node in the target path, null is returned.
        Returns:
        a target dictionary specifying additional path information to the target document
      • put

        public PdfTarget put​(PdfName key,
                             PdfObject value)
        This is a convenient method to put key-value pairs to the underlying PdfObject.
        Parameters:
        key - the key, a PdfName instance
        value - the value
        Returns:
        this object wrapper
      • isWrappedObjectMustBeIndirect

        protected boolean isWrappedObjectMustBeIndirect()
        Defines if the object behind this wrapper must be an indirect object in the resultant document.

        If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

        Return value of this method shouldn't depend on any logic, it should return always true or false.
        Specified by:
        isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfDictionary>
        Returns:
        true if in the resultant document the object behind the wrapper must be indirect, otherwise false.