KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > collection > PdfTargetDictionary


1 package com.lowagie.text.pdf.collection;
2
3 import com.lowagie.text.pdf.PdfDictionary;
4 import com.lowagie.text.pdf.PdfName;
5 import com.lowagie.text.pdf.PdfNumber;
6 import com.lowagie.text.pdf.PdfObject;
7 import com.lowagie.text.pdf.PdfString;
8
9 public class PdfTargetDictionary extends PdfDictionary {
10     
11     /**
12      * Creates dictionary referring to a target document that is the parent of the current document.
13      * @param nested null if this is the actual target, another target if this is only an intermediate target.
14      */

15     public PdfTargetDictionary(PdfTargetDictionary nested) {
16         super();
17         put(PdfName.R, PdfName.P);
18         if (nested != null)
19             setAdditionalPath(nested);
20     }
21     
22     /**
23      * Creates a dictionary referring to a target document.
24      * @param child if false, this refers to the parent document; if true, this refers to a child document, and you'll have to specify where to find the child using the other methods of this class
25      */

26     public PdfTargetDictionary(boolean child) {
27         super();
28         if (child) {
29             put(PdfName.R, PdfName.C);
30         }
31         else {
32             put(PdfName.R, PdfName.P);
33         }
34     }
35     
36     /**
37      * If this dictionary refers to a child that is a document level attachment,
38      * you need to specify the name that was used to attach the document.
39      * @param target the name in the EmbeddedFiles name tree
40      */

41     public void setEmbeddedFileName(String JavaDoc target) {
42         put(PdfName.N, new PdfString(target, null));
43     }
44     
45     /**
46      * If this dictionary refers to a child that is a file attachment added to a page,
47      * you need to specify the name of the page (or use setFileAttachmentPage to specify the page number).
48      * Once you have specified the page, you still need to specify the attachment using another method.
49      * @param name the named destination referring to the page with the file attachment.
50      */

51     public void setFileAttachmentPagename(String JavaDoc name) {
52         put(PdfName.P, new PdfString(name, null));
53     }
54     
55     /**
56      * If this dictionary refers to a child that is a file attachment added to a page,
57      * you need to specify the page number (or use setFileAttachmentPagename to specify a named destination).
58      * Once you have specified the page, you still need to specify the attachment using another method.
59      * @param page the page number of the page with the file attachment.
60      */

61     public void setFileAttachmentPage(int page) {
62         put(PdfName.P, new PdfNumber(page));
63     }
64     
65     /**
66      * If this dictionary refers to a child that is a file attachment added to a page,
67      * you need to specify the page with setFileAttachmentPage or setFileAttachmentPageName,
68      * and then specify the name of the attachment added to this page (or use setFileAttachmentIndex).
69      * @param name the name of the attachment
70      */

71     public void setFileAttachmentName(String JavaDoc name) {
72         put(PdfName.A, new PdfString(name, PdfObject.TEXT_UNICODE));
73     }
74     
75     /**
76      * If this dictionary refers to a child that is a file attachment added to a page,
77      * you need to specify the page with setFileAttachmentPage or setFileAttachmentPageName,
78      * and then specify the index of the attachment added to this page (or use setFileAttachmentName).
79      * @param annotation the number of the attachment
80      */

81     public void setFileAttachmentIndex(int annotation) {
82         put(PdfName.A, new PdfNumber(annotation));
83     }
84     
85     /**
86      * If this dictionary refers to an intermediate target, you can
87      * add the next target in the sequence.
88      * @param nested the next target in the sequence
89      */

90     public void setAdditionalPath(PdfTargetDictionary nested) {
91         put(PdfName.T, nested);
92     }
93 }
94
Popular Tags