Source Code Cross Referenced for PDDocumentInformation.java in  » PDF » PDFBox-0.7.3 » org » pdfbox » pdmodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » PDFBox 0.7.3 » org.pdfbox.pdmodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2003-2005, www.pdfbox.org
003:         * All rights reserved.
004:         *
005:         * Redistribution and use in source and binary forms, with or without
006:         * modification, are permitted provided that the following conditions are met:
007:         *
008:         * 1. Redistributions of source code must retain the above copyright notice,
009:         *    this list of conditions and the following disclaimer.
010:         * 2. Redistributions in binary form must reproduce the above copyright notice,
011:         *    this list of conditions and the following disclaimer in the documentation
012:         *    and/or other materials provided with the distribution.
013:         * 3. Neither the name of pdfbox; nor the names of its
014:         *    contributors may be used to endorse or promote products derived from this
015:         *    software without specific prior written permission.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:         * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         *
028:         * http://www.pdfbox.org
029:         *
030:         */package org.pdfbox.pdmodel;
031:
032:        import java.io.IOException;
033:
034:        import java.util.Calendar;
035:
036:        import org.pdfbox.cos.COSBase;
037:        import org.pdfbox.cos.COSDictionary;
038:        import org.pdfbox.cos.COSName;
039:
040:        import org.pdfbox.pdmodel.common.COSObjectable;
041:
042:        /**
043:         * This is the document metadata.  Each getXXX method will return the entry if
044:         * it exists or null if it does not exist.  If you pass in null for the setXXX
045:         * method then it will clear the value.
046:         *
047:         * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
048:         * @version $Revision: 1.12 $
049:         */
050:        public class PDDocumentInformation implements  COSObjectable {
051:            private static final COSName TITLE = COSName.getPDFName("Title");
052:            private static final COSName AUTHOR = COSName.getPDFName("Author");
053:            private static final COSName SUBJECT = COSName
054:                    .getPDFName("Subject");
055:            private static final COSName KEYWORDS = COSName
056:                    .getPDFName("Keywords");
057:            private static final COSName CREATOR = COSName
058:                    .getPDFName("Creator");
059:            private static final COSName PRODUCER = COSName
060:                    .getPDFName("Producer");
061:            private static final COSName CREATION_DATE = COSName
062:                    .getPDFName("CreationDate");
063:            private static final COSName MODIFICATION_DATE = COSName
064:                    .getPDFName("ModDate");
065:            private static final COSName TRAPPED = COSName
066:                    .getPDFName("Trapped");
067:            private COSDictionary info;
068:
069:            /**
070:             * Default Constructor.
071:             */
072:            public PDDocumentInformation() {
073:                info = new COSDictionary();
074:            }
075:
076:            /**
077:             * Constructor that is used for a preexisting dictionary.
078:             *
079:             * @param dic The underlying dictionary.
080:             */
081:            public PDDocumentInformation(COSDictionary dic) {
082:                info = dic;
083:            }
084:
085:            /**
086:             * This will get the underlying dictionary that this object wraps.
087:             *
088:             * @return The underlying info dictionary.
089:             */
090:            public COSDictionary getDictionary() {
091:                return info;
092:            }
093:
094:            /**
095:             * Convert this standard java object to a COS object.
096:             *
097:             * @return The cos object that matches this Java object.
098:             */
099:            public COSBase getCOSObject() {
100:                return info;
101:            }
102:
103:            /**
104:             * This will get the title of the document.  This will return null if no title exists.
105:             *
106:             * @return The title of the document.
107:             */
108:            public String getTitle() {
109:                return info.getString(TITLE);
110:            }
111:
112:            /**
113:             * This will set the title of the document.
114:             *
115:             * @param title The new title for the document.
116:             */
117:            public void setTitle(String title) {
118:                info.setString(TITLE, title);
119:            }
120:
121:            /**
122:             * This will get the author of the document.  This will return null if no author exists.
123:             *
124:             * @return The author of the document.
125:             */
126:            public String getAuthor() {
127:                return info.getString(AUTHOR);
128:            }
129:
130:            /**
131:             * This will set the author of the document.
132:             *
133:             * @param author The new author for the document.
134:             */
135:            public void setAuthor(String author) {
136:                info.setString(AUTHOR, author);
137:            }
138:
139:            /**
140:             * This will get the subject of the document.  This will return null if no subject exists.
141:             *
142:             * @return The subject of the document.
143:             */
144:            public String getSubject() {
145:                return info.getString(SUBJECT);
146:            }
147:
148:            /**
149:             * This will set the subject of the document.
150:             *
151:             * @param subject The new subject for the document.
152:             */
153:            public void setSubject(String subject) {
154:                info.setString(SUBJECT, subject);
155:            }
156:
157:            /**
158:             * This will get the keywords of the document.  This will return null if no keywords exists.
159:             *
160:             * @return The keywords of the document.
161:             */
162:            public String getKeywords() {
163:                return info.getString(KEYWORDS);
164:            }
165:
166:            /**
167:             * This will set the keywords of the document.
168:             *
169:             * @param keywords The new keywords for the document.
170:             */
171:            public void setKeywords(String keywords) {
172:                info.setString(KEYWORDS, keywords);
173:            }
174:
175:            /**
176:             * This will get the creator of the document.  This will return null if no creator exists.
177:             *
178:             * @return The creator of the document.
179:             */
180:            public String getCreator() {
181:                return info.getString(CREATOR);
182:            }
183:
184:            /**
185:             * This will set the creator of the document.
186:             *
187:             * @param creator The new creator for the document.
188:             */
189:            public void setCreator(String creator) {
190:                info.setString(CREATOR, creator);
191:            }
192:
193:            /**
194:             * This will get the producer of the document.  This will return null if no producer exists.
195:             *
196:             * @return The producer of the document.
197:             */
198:            public String getProducer() {
199:                return info.getString(PRODUCER);
200:            }
201:
202:            /**
203:             * This will set the producer of the document.
204:             *
205:             * @param producer The new producer for the document.
206:             */
207:            public void setProducer(String producer) {
208:                info.setString(PRODUCER, producer);
209:            }
210:
211:            /**
212:             * This will get the creation date of the document.  This will return null if no creation date exists.
213:             *
214:             * @return The creation date of the document.
215:             * 
216:             * @throws IOException If there is an error creating the date.
217:             */
218:            public Calendar getCreationDate() throws IOException {
219:                return info.getDate(CREATION_DATE);
220:            }
221:
222:            /**
223:             * This will set the creation date of the document.
224:             *
225:             * @param date The new creation date for the document.
226:             */
227:            public void setCreationDate(Calendar date) {
228:                info.setDate(CREATION_DATE, date);
229:            }
230:
231:            /**
232:             * This will get the modification date of the document.  This will return null if no modification date exists.
233:             *
234:             * @return The modification date of the document.
235:             * 
236:             * @throws IOException If there is an error creating the date.
237:             */
238:            public Calendar getModificationDate() throws IOException {
239:                return info.getDate(MODIFICATION_DATE);
240:            }
241:
242:            /**
243:             * This will set the modification date of the document.
244:             *
245:             * @param date The new modification date for the document.
246:             */
247:            public void setModificationDate(Calendar date) {
248:                info.setDate(MODIFICATION_DATE, date);
249:            }
250:
251:            /**
252:             * This will get the trapped value for the document.
253:             * This will return null if one is not found.
254:             *
255:             * @return The trapped value for the document.
256:             */
257:            public String getTrapped() {
258:                return info.getNameAsString(TRAPPED);
259:            }
260:
261:            /**
262:             *  This will get the value of a custom metadata information field for the document.
263:             *  This will return null if one is not found.
264:             *
265:             * @param fieldName Name of custom metadata field from pdf document.
266:             * 
267:             * @return String Value of metadata field
268:             * 
269:             * @author  Gerardo Ortiz
270:             */
271:            public String getCustomMetadataValue(String fieldName) {
272:                return info.getString(fieldName);
273:            }
274:
275:            /**
276:             * Set the custom metadata value.
277:             * 
278:             * @param fieldName The name of the custom metadata field.
279:             * @param fieldValue The value to the custom metadata field.
280:             */
281:            public void setCustomMetadataValue(String fieldName,
282:                    String fieldValue) {
283:                info.setString(fieldName, fieldValue);
284:            }
285:
286:            /**
287:             * This will set the trapped of the document.  This will be
288:             * 'True', 'False', or 'Unknown'.
289:             *
290:             * @param value The new trapped value for the document.
291:             */
292:            public void setTrapped(String value) {
293:                if (value != null && !value.equals("True")
294:                        && !value.equals("False") && !value.equals("Unknown")) {
295:                    throw new RuntimeException("Valid values for trapped are "
296:                            + "'True', 'False', or 'Unknown'");
297:                }
298:
299:                info.setName(TRAPPED, value);
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.