KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > jpdf > PDFInfo


1 /*
2  * $Id: PDFInfo.java,v 1.1.1.1 2001/10/29 19:51:08 ezb Exp $
3  *
4  * $Date: 2001/10/29 19:51:08 $
5  *
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */

22 package gnu.jpdf;
23
24 import java.io.*;
25
26 /**
27  * <p>This class stores details of the author, the PDF generator etc.
28  * The values are accessible via the PDFDocument class.</p>
29  *
30  * @author Peter T. Mount
31  * @author Eric Z. Beard, ericzbeard@hotmail.com
32  * @author $Author: ezb $
33  * @version $Revision: 1.1.1.1 $, $Date: 2001/10/29 19:51:08 $
34  
35  */

36 public class PDFInfo extends PDFObject
37 {
38   private String JavaDoc author;
39   private String JavaDoc creator;
40   private String JavaDoc title;
41   private String JavaDoc subject;
42   private String JavaDoc keywords;
43
44   /**
45    * This constructs a minimal info object
46    */

47   public PDFInfo() {
48     super(null);
49   }
50   
51   /**
52    * @param title Title of this document
53    */

54   public PDFInfo(String JavaDoc title) {
55     this();
56     this.title = title;
57   }
58
59
60   
61   /**
62    * Get the value of author.
63    * @return value of author.
64    */

65   public String JavaDoc getAuthor() {
66     return author;
67   }
68   
69   /**
70    * Set the value of author.
71    * @param v Value to assign to author.
72    */

73   public void setAuthor(String JavaDoc v) {
74     this.author = v;
75   }
76   
77   
78
79   /**
80    * PDF has two values, a Creator and a Producer. The creator field is
81    * available for calling code. The producer is fixed by this library.
82    * Get the value of creator.
83    * @return value of creator.
84    */

85   public String JavaDoc getCreator() {
86     return creator;
87   }
88   
89   /**
90    * Set the value of creator.
91    * @param v Value to assign to creator.
92    */

93   public void setCreator(String JavaDoc v) {
94     this.creator = v;
95   }
96   
97   /**
98    * Get the value of title.
99    * @return value of title.
100    */

101   public String JavaDoc getTitle() {
102     return title;
103   }
104   
105   /**
106    * Set the value of title.
107    * @param v Value to assign to title.
108    */

109   public void setTitle(String JavaDoc v) {
110     this.title = v;
111   }
112   
113   /**
114    * Get the value of subject.
115    * @return value of subject.
116    */

117   public String JavaDoc getSubject() {
118     return subject;
119   }
120   
121   /**
122    * Set the value of subject.
123    * @param v Value to assign to subject.
124    */

125   public void setSubject(String JavaDoc v) {
126     this.subject = v;
127   }
128   
129   /**
130    * Get the value of keywords.
131    * @return value of keywords.
132    */

133   public String JavaDoc getKeywords() {
134     return keywords;
135   }
136   
137   /**
138    * Set the value of keywords.
139    * @param v Value to assign to keywords.
140    */

141   public void setKeywords(String JavaDoc v) {
142     this.keywords = v;
143   }
144     
145   /**
146    * @param os OutputStream to send the object to
147    * @exception IOException on error
148    */

149   public void write(OutputStream os) throws IOException {
150     // Write the object header
151
writeStart(os);
152     
153     // now the objects body
154

155     if(author!=null) {
156       os.write("/Author (".getBytes());
157       os.write(PDFStringHelper.makePDFString(author).getBytes());
158       os.write(")\n".getBytes());
159     }
160     
161     if(creator!=null) {
162       os.write("/Creator (".getBytes());
163       os.write(PDFStringHelper.makePDFString(creator).getBytes());
164       os.write(")\n".getBytes());
165     }
166     
167     os.write("/Producer ".getBytes());
168     os.write(PDFStringHelper.makePDFString("gnujpdf - gnujpdf.sourceforge.net")
169              .getBytes());
170     os.write("\n".getBytes());
171     
172     if(title!=null) {
173       os.write("/Title ".getBytes());
174       os.write(PDFStringHelper.makePDFString(title).getBytes());
175       os.write("\n".getBytes());
176     }
177     
178     if(subject!=null) {
179       os.write("/Subject (".getBytes());
180       os.write(PDFStringHelper.makePDFString(subject).getBytes());
181       os.write(")\n".getBytes());
182     }
183     
184     if(keywords!=null) {
185       os.write("/Keywords (".getBytes());
186       os.write(PDFStringHelper.makePDFString(keywords).getBytes());
187       os.write(")\n".getBytes());
188     }
189     
190     // finish off with its footer
191
writeEnd(os);
192   } // end write
193

194 } // end class PDFInfo
195
Popular Tags