001: /*
002: * $Id: PDFInfo.java,v 1.1.1.1 2001/10/29 19:51:08 ezb Exp $
003: *
004: * $Date: 2001/10/29 19:51:08 $
005: *
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: */
022: package gnu.jpdf;
023:
024: import java.io.*;
025:
026: /**
027: * <p>This class stores details of the author, the PDF generator etc.
028: * The values are accessible via the PDFDocument class.</p>
029: *
030: * @author Peter T. Mount
031: * @author Eric Z. Beard, ericzbeard@hotmail.com
032: * @author $Author: ezb $
033: * @version $Revision: 1.1.1.1 $, $Date: 2001/10/29 19:51:08 $
034:
035: */
036: public class PDFInfo extends PDFObject {
037: private String author;
038: private String creator;
039: private String title;
040: private String subject;
041: private String keywords;
042:
043: /**
044: * This constructs a minimal info object
045: */
046: public PDFInfo() {
047: super (null);
048: }
049:
050: /**
051: * @param title Title of this document
052: */
053: public PDFInfo(String title) {
054: this ();
055: this .title = title;
056: }
057:
058: /**
059: * Get the value of author.
060: * @return value of author.
061: */
062: public String getAuthor() {
063: return author;
064: }
065:
066: /**
067: * Set the value of author.
068: * @param v Value to assign to author.
069: */
070: public void setAuthor(String v) {
071: this .author = v;
072: }
073:
074: /**
075: * PDF has two values, a Creator and a Producer. The creator field is
076: * available for calling code. The producer is fixed by this library.
077: * Get the value of creator.
078: * @return value of creator.
079: */
080: public String getCreator() {
081: return creator;
082: }
083:
084: /**
085: * Set the value of creator.
086: * @param v Value to assign to creator.
087: */
088: public void setCreator(String v) {
089: this .creator = v;
090: }
091:
092: /**
093: * Get the value of title.
094: * @return value of title.
095: */
096: public String getTitle() {
097: return title;
098: }
099:
100: /**
101: * Set the value of title.
102: * @param v Value to assign to title.
103: */
104: public void setTitle(String v) {
105: this .title = v;
106: }
107:
108: /**
109: * Get the value of subject.
110: * @return value of subject.
111: */
112: public String getSubject() {
113: return subject;
114: }
115:
116: /**
117: * Set the value of subject.
118: * @param v Value to assign to subject.
119: */
120: public void setSubject(String v) {
121: this .subject = v;
122: }
123:
124: /**
125: * Get the value of keywords.
126: * @return value of keywords.
127: */
128: public String getKeywords() {
129: return keywords;
130: }
131:
132: /**
133: * Set the value of keywords.
134: * @param v Value to assign to keywords.
135: */
136: public void setKeywords(String v) {
137: this .keywords = v;
138: }
139:
140: /**
141: * @param os OutputStream to send the object to
142: * @exception IOException on error
143: */
144: public void write(OutputStream os) throws IOException {
145: // Write the object header
146: writeStart(os);
147:
148: // now the objects body
149:
150: if (author != null) {
151: os.write("/Author (".getBytes());
152: os.write(PDFStringHelper.makePDFString(author).getBytes());
153: os.write(")\n".getBytes());
154: }
155:
156: if (creator != null) {
157: os.write("/Creator (".getBytes());
158: os.write(PDFStringHelper.makePDFString(creator).getBytes());
159: os.write(")\n".getBytes());
160: }
161:
162: os.write("/Producer ".getBytes());
163: os.write(PDFStringHelper.makePDFString(
164: "gnujpdf - gnujpdf.sourceforge.net").getBytes());
165: os.write("\n".getBytes());
166:
167: if (title != null) {
168: os.write("/Title ".getBytes());
169: os.write(PDFStringHelper.makePDFString(title).getBytes());
170: os.write("\n".getBytes());
171: }
172:
173: if (subject != null) {
174: os.write("/Subject (".getBytes());
175: os.write(PDFStringHelper.makePDFString(subject).getBytes());
176: os.write(")\n".getBytes());
177: }
178:
179: if (keywords != null) {
180: os.write("/Keywords (".getBytes());
181: os
182: .write(PDFStringHelper.makePDFString(keywords)
183: .getBytes());
184: os.write(")\n".getBytes());
185: }
186:
187: // finish off with its footer
188: writeEnd(os);
189: } // end write
190:
191: } // end class PDFInfo
|