Package com.itextpdf.kernel.pdf.action
Class PdfTarget
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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PdfTarget
create
(PdfDictionary pdfObject) Creates a newPdfTarget
object by the underlying dictionary.static PdfTarget
Creates a new target object pointing to the child of the current document.static PdfTarget
createChildTarget
(int pageNumber, int annotationIndex) Creates a new target object pointing to a file attachment annotation.static PdfTarget
createChildTarget
(String embeddedFileName) Creates a new target object pointing to a file in the EmbeddedFiles name tree.static PdfTarget
createChildTarget
(String namedDestination, String annotationIdentifier) Creates a new target object pointing to a file attachment annotation.static PdfTarget
Creates a new target object pointing to the parent of the current document.getAnnotation
(PdfDocument pdfDocument) Gets the annotation specified by /A and /P entry values.getName()
Gets name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.Get a target dictionary specifying additional path information to the target document.protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.This is a convenient method to put key-value pairs to the underlyingPdfObject
.setAnnotation
(PdfFileAttachmentAnnotation pdfAnnotation, PdfDocument pdfDocument) Sets the /P and /A values corresponding to provided annotation, which is already added to a page.Sets the name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.Sets a target dictionary specifying additional path information to the target document.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Method Details
-
create
Creates a newPdfTarget
object by the underlying dictionary.- Parameters:
-
pdfObject
- the underlying dictionary object - Returns:
-
a new
PdfTarget
object by the underlying dictionary
-
createParentTarget
Creates a new target object pointing to the parent of the current document.- Returns:
-
created
PdfTarget
-
createChildTarget
Creates a new target object pointing to the child of the current document.- Returns:
-
created
PdfTarget
-
createChildTarget
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
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
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
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
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
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
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
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
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
This is a convenient method to put key-value pairs to the underlyingPdfObject
.- Parameters:
-
key
- the key, aPdfName
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 classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-