Package com.itextpdf.kernel.pdf.action
Class PdfTarget
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.action.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 Summary
Constructors Modifier Constructor Description privatePdfTarget(PdfDictionary pdfObject)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PdfTargetcreate(PdfDictionary pdfObject)Creates a newPdfTargetobject by the underlying dictionary.private static PdfTargetcreate(PdfName r)Creates a newPdfTargetobject given its type.static PdfTargetcreateChildTarget()Creates a new target object pointing to the child of the current document.static PdfTargetcreateChildTarget(int pageNumber, int annotationIndex)Creates a new target object pointing to a file attachment annotation.static PdfTargetcreateChildTarget(java.lang.String embeddedFileName)Creates a new target object pointing to a file in the EmbeddedFiles name tree.static PdfTargetcreateChildTarget(java.lang.String namedDestination, java.lang.String annotationIdentifier)Creates a new target object pointing to a file attachment annotation.static PdfTargetcreateParentTarget()Creates a new target object pointing to the parent of the current document.PdfFileAttachmentAnnotationgetAnnotation(PdfDocument pdfDocument)Gets the annotation specified by /A and /P entry values.java.lang.StringgetName()Gets name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.PdfTargetgetTarget()Get a target dictionary specifying additional path information to the target document.protected booleanisWrappedObjectMustBeIndirect()Defines if the object behind this wrapper must be an indirect object in the resultant document.PdfTargetput(PdfName key, PdfObject value)This is a convenient method to put key-value pairs to the underlyingPdfObject.PdfTargetsetAnnotation(PdfFileAttachmentAnnotation pdfAnnotation, PdfDocument pdfDocument)Sets the /P and /A values corresponding to provided annotation, which is already added to a page.PdfTargetsetName(java.lang.String name)Sets the name of the file in the EmbeddedFiles name tree for the child target located in the EmbeddedFiles.PdfTargetsetTarget(PdfTarget target)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
-
-
-
-
Constructor Detail
-
PdfTarget
private PdfTarget(PdfDictionary pdfObject)
-
-
Method Detail
-
create
public static PdfTarget create(PdfDictionary pdfObject)
Creates a newPdfTargetobject by the underlying dictionary.- Parameters:
pdfObject- the underlying dictionary object- Returns:
- a new
PdfTargetobject by the underlying dictionary
-
create
private static PdfTarget create(PdfName r)
Creates a newPdfTargetobject given its type. The type must be eitherPdfName.P, orPdfName.C. If it isPdfName.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 annotationannotationIdentifier- a unique annotation identifier (PdfName.NMentry) 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-basedannotationIndex- 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 setpdfDocument- 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,nullis 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 underlyingPdfObject.- Parameters:
key- the key, aPdfNameinstancevalue- 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:
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary>- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
-