blob: 1004389f9212fb61cee1efd99317b288e5cf510b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.pdf;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* class representing an /Info object
*/
public class PDFInfo extends PDFObject {
/**
* the application producing the PDF
*/
protected String producer;
protected String title = null;
protected String author = null;
protected String subject = null;
protected String keywords = null;
// the name of the application that created the
// original document before converting to PDF
protected String creator;
/**
* create an Info object
*
* @param number the object's number
*/
public PDFInfo(int number) {
super(number);
}
/**
* set the producer string
*
* @param producer the producer string
*/
public void setProducer(String producer) {
this.producer = producer;
}
public void setTitle(String t) {
this.title = t;
}
public void setAuthor(String a) {
this.author = a;
}
public void setSubject(String s) {
this.subject = s;
}
public void setKeywords(String k) {
this.keywords = k;
}
/**
* produce the PDF representation of the object
*
* @return the PDF
*/
public byte[] toPDF() {
String p = this.number + " " + this.generation
+ " obj\n<< /Type /Info\n";
if (title != null) {
p += "/Title (" + this.title + ")\n";
}
if (author != null) {
p += "/Author (" + this.author + ")\n";
}
if (subject != null) {
p += "/Subject (" + this.subject + ")\n";
}
if (keywords != null) {
p += "/Keywords (" + this.keywords + ")\n";
}
p += "/Producer (" + this.producer + ")\n";
// creation date in form (D:YYYYMMDDHHmmSSOHH'mm')
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String str = sdf.format(date) + "+00'00'";
p += "/CreationDate (D:" + str + ")";
p += " >>\nendobj\n";
return p.getBytes();
}
}
|