01: package com.lowagie.text.pdf.collection;
02:
03: import com.lowagie.text.pdf.PdfDictionary;
04: import com.lowagie.text.pdf.PdfName;
05: import com.lowagie.text.pdf.PdfNumber;
06: import com.lowagie.text.pdf.PdfObject;
07: import com.lowagie.text.pdf.PdfString;
08:
09: 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: } else {
31: put(PdfName.R, PdfName.P);
32: }
33: }
34:
35: /**
36: * If this dictionary refers to a child that is a document level attachment,
37: * you need to specify the name that was used to attach the document.
38: * @param target the name in the EmbeddedFiles name tree
39: */
40: public void setEmbeddedFileName(String target) {
41: put(PdfName.N, new PdfString(target, null));
42: }
43:
44: /**
45: * If this dictionary refers to a child that is a file attachment added to a page,
46: * you need to specify the name of the page (or use setFileAttachmentPage to specify the page number).
47: * Once you have specified the page, you still need to specify the attachment using another method.
48: * @param name the named destination referring to the page with the file attachment.
49: */
50: public void setFileAttachmentPagename(String name) {
51: put(PdfName.P, new PdfString(name, null));
52: }
53:
54: /**
55: * If this dictionary refers to a child that is a file attachment added to a page,
56: * you need to specify the page number (or use setFileAttachmentPagename to specify a named destination).
57: * Once you have specified the page, you still need to specify the attachment using another method.
58: * @param page the page number of the page with the file attachment.
59: */
60: public void setFileAttachmentPage(int page) {
61: put(PdfName.P, new PdfNumber(page));
62: }
63:
64: /**
65: * If this dictionary refers to a child that is a file attachment added to a page,
66: * you need to specify the page with setFileAttachmentPage or setFileAttachmentPageName,
67: * and then specify the name of the attachment added to this page (or use setFileAttachmentIndex).
68: * @param name the name of the attachment
69: */
70: public void setFileAttachmentName(String name) {
71: put(PdfName.A, new PdfString(name, PdfObject.TEXT_UNICODE));
72: }
73:
74: /**
75: * If this dictionary refers to a child that is a file attachment added to a page,
76: * you need to specify the page with setFileAttachmentPage or setFileAttachmentPageName,
77: * and then specify the index of the attachment added to this page (or use setFileAttachmentName).
78: * @param annotation the number of the attachment
79: */
80: public void setFileAttachmentIndex(int annotation) {
81: put(PdfName.A, new PdfNumber(annotation));
82: }
83:
84: /**
85: * If this dictionary refers to an intermediate target, you can
86: * add the next target in the sequence.
87: * @param nested the next target in the sequence
88: */
89: public void setAdditionalPath(PdfTargetDictionary nested) {
90: put(PdfName.T, nested);
91: }
92: }
|