diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-03-27 10:48:08 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-03-27 10:48:08 +0000 |
commit | fd0d2dfad7598a9f21398022f1279176a6621cf0 (patch) | |
tree | 1885ab379d305f784ee1ebeca39d0b1fbbd80966 /src | |
parent | 115819066f801bcc827022df242cf30615f4f9a7 (diff) | |
download | xmlgraphics-fop-fd0d2dfad7598a9f21398022f1279176a6621cf0.tar.gz xmlgraphics-fop-fd0d2dfad7598a9f21398022f1279176a6621cf0.zip |
No object number in the constructor.
Support encryption of string and text values.
TODO: We need to improve generation of PDF dictionaries. The current way is suboptimal.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196161 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFInfo.java | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFInfo.java b/src/java/org/apache/fop/pdf/PDFInfo.java index 58cafb02d..01b443370 100644 --- a/src/java/org/apache/fop/pdf/PDFInfo.java +++ b/src/java/org/apache/fop/pdf/PDFInfo.java @@ -51,6 +51,8 @@ package org.apache.fop.pdf; import java.util.Date; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.text.SimpleDateFormat; /** @@ -68,18 +70,11 @@ public class PDFInfo extends PDFObject { private String subject = null; private String keywords = null; - // the name of the application that created the - // original document before converting to PDF - private String creator; - /** - * create an Info object - * - * @param number the object's number + * the name of the application that created the + * original document before converting to PDF */ - public PDFInfo(int number) { - super(number); - } + private String creator; /** * set the producer string @@ -136,39 +131,55 @@ public class PDFInfo extends PDFObject { } /** - * produce the PDF representation of the object - * - * @return the PDF + * @see org.apache.fop.pdf.PDFObject#toPDF() */ 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"; + ByteArrayOutputStream bout = new ByteArrayOutputStream(128); + try { + bout.write(encode(getObjectID())); + bout.write(encode("<< /Type /Info\n")); + if (title != null) { + bout.write(encode("/Title ")); + bout.write(encodeText(this.title)); + bout.write(encode("\n")); + } + if (author != null) { + bout.write(encode("/Author ")); + bout.write(encodeText(this.author)); + bout.write(encode("\n")); + } + if (subject != null) { + bout.write(encode("/Subject ")); + bout.write(encodeText(this.subject)); + bout.write(encode("\n")); + } + if (keywords != null) { + bout.write(encode("/Keywords ")); + bout.write(encodeText(this.keywords)); + bout.write(encode("\n")); + } + + if (creator != null) { + bout.write(encode("/Creator ")); + bout.write(encodeText(this.creator)); + bout.write(encode("\n")); + } + + bout.write(encode("/Producer ")); + bout.write(encodeText(this.producer)); + bout.write(encode("\n")); + + // creation date in form (D:YYYYMMDDHHmmSSOHH'mm') + final Date date = new Date(); + final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + final String str = sdf.format(date) + "+00'00'"; + bout.write(encode("/CreationDate ")); + bout.write(encodeString("D:" + str)); + bout.write(encode("\n>>\nendobj\n")); + } catch (IOException ioe) { + getDocumentSafely().getLogger().error("Ignored I/O exception", ioe); } - if (subject != null) { - p += "/Subject (" + this.subject + ")\n"; - } - if (keywords != null) { - p += "/Keywords (" + this.keywords + ")\n"; - } - - if (creator != null) { - p += "/Creator (" + this.creator + ")\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(); + return bout.toByteArray(); } } |