From 0266898d9599fb55792ed321acfdf77a53c6c22d Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 11 May 2007 08:47:11 +0000 Subject: [PATCH] Bugfix: Integers were not correctly formatted in PDF. This fixes a problem with embedded fonts. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@537129 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/pdf/PDFArray.java | 6 +----- src/java/org/apache/fop/pdf/PDFDictionary.java | 6 +----- src/java/org/apache/fop/pdf/PDFObject.java | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/fop/pdf/PDFArray.java b/src/java/org/apache/fop/pdf/PDFArray.java index 0e7a2b986..abeed1d86 100644 --- a/src/java/org/apache/fop/pdf/PDFArray.java +++ b/src/java/org/apache/fop/pdf/PDFArray.java @@ -127,11 +127,7 @@ public class PDFArray extends PDFObject { p.append(" "); } Object obj = this.values.get(i); - if (obj instanceof PDFWritable) { - p.append(((PDFWritable)obj).toInlinePDFString()); - } else { - p.append("(").append(obj).append(")"); - } + formatObject(obj, p); } p.append("]"); if (hasObjectNumber()) { diff --git a/src/java/org/apache/fop/pdf/PDFDictionary.java b/src/java/org/apache/fop/pdf/PDFDictionary.java index aa15792b2..2a9c3ffe4 100644 --- a/src/java/org/apache/fop/pdf/PDFDictionary.java +++ b/src/java/org/apache/fop/pdf/PDFDictionary.java @@ -84,11 +84,7 @@ public class PDFDictionary extends PDFObject { p.append(key); p.append(" "); Object obj = this.entries.get(key); - if (obj instanceof PDFWritable) { - p.append(((PDFWritable)obj).toInlinePDFString()); - } else { - p.append("(").append(obj).append(")"); - } + formatObject(obj, p); } p.append("\n>>\n"); if (hasObjectNumber()) { diff --git a/src/java/org/apache/fop/pdf/PDFObject.java b/src/java/org/apache/fop/pdf/PDFObject.java index 806f7621d..544a30cc4 100644 --- a/src/java/org/apache/fop/pdf/PDFObject.java +++ b/src/java/org/apache/fop/pdf/PDFObject.java @@ -245,6 +245,21 @@ public abstract class PDFObject implements PDFWritable { }*/ } + /** + * Formats an object for serialization to PDF. + * @param obj the object + * @param sb the StringBuffer to write to + */ + protected void formatObject(Object obj, StringBuffer sb) { + if (obj instanceof PDFWritable) { + sb.append(((PDFWritable)obj).toInlinePDFString()); + } else if (obj instanceof Number) { + sb.append(obj); + } else { + sb.append("(").append(obj).append(")"); + } + } + /** Formatting pattern for PDF date */ protected static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("'D:'yyyyMMddHHmmss"); -- 2.39.5