]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed PDF-Renderer to work on EBCDIC systems
authorChristian Geisert <chrisg@apache.org>
Fri, 31 May 2002 00:17:16 +0000 (00:17 +0000)
committerChristian Geisert <chrisg@apache.org>
Fri, 31 May 2002 00:17:16 +0000 (00:17 +0000)
(Actually on systems where file.encoding != ASCII/ISO-8859)
 Submitted by: Jason West <Jason.West@mail.state.ky.us>

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@194846 13f79535-47bb-0310-9956-ffa450edef68

31 files changed:
CHANGES
src/org/apache/fop/pdf/ASCII85Filter.java
src/org/apache/fop/pdf/ASCIIHexFilter.java
src/org/apache/fop/pdf/PDFAnnotList.java
src/org/apache/fop/pdf/PDFArray.java
src/org/apache/fop/pdf/PDFCIDFont.java
src/org/apache/fop/pdf/PDFCIDSystemInfo.java
src/org/apache/fop/pdf/PDFDocument.java
src/org/apache/fop/pdf/PDFEncoding.java
src/org/apache/fop/pdf/PDFFileSpec.java
src/org/apache/fop/pdf/PDFFont.java
src/org/apache/fop/pdf/PDFFontDescriptor.java
src/org/apache/fop/pdf/PDFFunction.java
src/org/apache/fop/pdf/PDFGoTo.java
src/org/apache/fop/pdf/PDFGoToRemote.java
src/org/apache/fop/pdf/PDFICCStream.java
src/org/apache/fop/pdf/PDFInfo.java
src/org/apache/fop/pdf/PDFLink.java
src/org/apache/fop/pdf/PDFOutline.java
src/org/apache/fop/pdf/PDFPage.java
src/org/apache/fop/pdf/PDFPages.java
src/org/apache/fop/pdf/PDFPattern.java
src/org/apache/fop/pdf/PDFRectangle.java
src/org/apache/fop/pdf/PDFResources.java
src/org/apache/fop/pdf/PDFRoot.java
src/org/apache/fop/pdf/PDFShading.java
src/org/apache/fop/pdf/PDFStream.java
src/org/apache/fop/pdf/PDFT1Stream.java
src/org/apache/fop/pdf/PDFTTFStream.java
src/org/apache/fop/pdf/PDFWArray.java
src/org/apache/fop/pdf/PDFXObject.java

diff --git a/CHANGES b/CHANGES
index 0e0df64207dbf9710b6664f95f0bb9edb68baa6a..e6243242b0770774c091b045b40cb333d0d7283f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -18,6 +18,10 @@ Done since 0.20.3 release
   Submitted by: Michal Buchtik <BuchtikM@dlsystem.cz>
 - Added support for background-image
   Submitted by: Michael Gratton <mjg@recalldesign.com>
+- Fixed PDF-Renderer to work on EBCDIC systems 
+  (Actually on systems where file.encoding != ASCII/ISO-8859)
+  Submitted by: Jason West <Jason.West@mail.state.ky.us>
+  
 ==============================================================================
 Done since 0.20.2 release
 *** General
index 40706e968c0c491e2826f96dca5e085acf2d2f1c..7c8e43cb848fbe190cb4f70c4500f5d0addd5c71 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
 public class ASCII85Filter extends PDFFilter {
     private static final char ASCII85_ZERO = 'z';
@@ -87,13 +88,15 @@ public class ASCII85Filter extends PDFFilter {
 
         }
         // finally write the two character end of data marker
-        buffer.write(ASCII85_EOD.getBytes(), 0,
-                     ASCII85_EOD.getBytes().length);
-
-
+        byte[] eod;
+        try {
+            eod = ASCII85_EOD.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            eod = ASCII85_EOD.getBytes();
+        }       
+        buffer.write(eod, 0, eod.length);
         byte[] result = buffer.toByteArray();
 
-
         // assert that we have the correct outgoing length
         /*
          * int in = (data.length % 4);
index 775a7fcb473d045b18a3d5442e9aee1c697bb236..d7c93674e577fa4e285f306dbfb8c31eeb001eca 100644 (file)
@@ -8,6 +8,7 @@ package org.apache.fop.pdf;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 
 public class ASCIIHexFilter extends PDFFilter {
     private static final String ASCIIHEX_EOD = ">";
@@ -32,8 +33,11 @@ public class ASCIIHexFilter extends PDFFilter {
         }
         buffer.append(ASCIIHEX_EOD);
 
-        return buffer.toString().getBytes();
-
+        try {
+            return buffer.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return buffer.toString().getBytes();
+        }       
     }
 
 }
index 1a23d85d5ae69271e095d24eeef15713cf66e841..3c509073ba2b876c47151798d5d029418608e7b0 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.pdf;
 
 // Java
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 
 /**
@@ -71,7 +72,12 @@ public class PDFAnnotList extends PDFObject {
                          + "\n");
         }
         p = p.append("]\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
     /*
index 243c19f09e13ee43203fad0c38cd593dbacb43a7..ad02402483c5c1dcdf9b8fe7d8289251835cf2d3 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+//Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing an array object
  */
@@ -42,7 +45,12 @@ public class PDFArray extends PDFObject {
             p.append(values[i]);
         }
         p.append("]\nendobj\n");
-        return p.toString().getBytes();
+        
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index 5323996bb4932c1cfecd79c6b669604eb954122d..b97bf97d3e248c05b12353c0ec0d623c9ef208d1 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 // based on work by Takayuki Takeuchi
 
 /**
@@ -147,7 +150,11 @@ public class PDFCIDFont extends PDFObject {
      * @return the PDF
      */
     public byte[] toPDF() {
-        return toPDFString().getBytes();
+        try {
+            return toPDFString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return toPDFString().getBytes();
+        }       
     }
 
     public String toPDFString() {
index 7104fd9d7661cbc6f173bc8ec36fd3b01accbfc3..dc538c01f056c6da8fad8139d04cbcf07bd343bd 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 // based on work by Takayuki Takeuchi
 
 /**
@@ -36,7 +39,11 @@ public class PDFCIDSystemInfo extends PDFObject {
      * @return the PDF
      */
     public byte[] toPDF() {
-        return toPDFString().getBytes();
+        try {
+            return toPDFString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return toPDFString().getBytes();
+        }       
     }
 
     public String toPDFString() {
index 380ab3b01ae8065b405aa9185c486b72f0b4f525..13cc5fdea14c4111e7c17e984b80131bb2e66299 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.fop.layout.FontDescriptor;
 // Java
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 import java.util.Hashtable;
 import java.util.Enumeration;
@@ -154,6 +155,11 @@ public class PDFDocument {
      */
     protected Vector pendingLinks = null;
 
+    /**
+     * Encoding of the PDF
+     */
+    public static final String ENCODING = "ISO-8859-1";
+
     /**
      * creates an empty PDF document <p>
      *
@@ -1218,7 +1224,12 @@ public class PDFDocument {
     throws IOException {
         this.position=0;
 
-        byte[] pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
+        byte[] pdf;
+        try {
+            pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
+        }       
         stream.write(pdf);
         this.position += pdf.length;
 
@@ -1265,7 +1276,13 @@ public class PDFDocument {
             "%%EOF\n";
 
         /* write the trailer */
-        stream.write(pdf.getBytes());
+        byte[] trailer;
+        try {
+            trailer = pdf.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            trailer = pdf.getBytes();
+        }       
+        stream.write(trailer);
     }
 
     /**
@@ -1297,7 +1314,12 @@ public class PDFDocument {
         }
 
         /* write the xref table and return the character length */
-        byte[] pdfBytes = pdf.toString().getBytes();
+        byte[] pdfBytes;
+        try {
+            pdfBytes = pdf.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            pdfBytes = pdf.toString().getBytes();
+        }       
         stream.write(pdfBytes);
         return pdfBytes.length;
     }
index 68151bdfd841ac17b4cf97dbfad78c1c1989f188..9338969607c348b090e7ef153865072cbc226732 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.pdf;
 
 // Java
+import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
@@ -106,7 +107,12 @@ public class PDFEncoding extends PDFObject {
             p.append(" ]");
         }
         p.append(" >>\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
     /*
index d7c5338d08dcaa5203e5c5629d3cb99c0f89f5f8..3ea5a38b9eb5e33dff2a01417b6050fefbd965a5 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a /FileSpec object.
  *
@@ -41,7 +44,12 @@ public class PDFFileSpec extends PDFObject {
         String p = new String(this.number + " " + this.generation
                               + " obj\n<<\n/Type /FileSpec\n" + "/F ("
                               + this.filename + ")\n" + ">>\nendobj\n");
-        return p.getBytes();
+
+        try {
+            return p.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.getBytes();
+        }       
     }
 
     /*
index 3d1c2ec059ccde73d69d2d29ae7c96e6f9669866..360f7e2f8fd87c46f20bfcf4987cd7aa4b973ddf 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a /Font object.
  *
@@ -218,7 +221,12 @@ public class PDFFont extends PDFObject {
         }
         fillInPDF(p);
         p.append(" >>\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
     /**
index 203879b35ac37831eb0d9c978e0a5b8d3f4cebcf..c99de058187f8ad17bd0515e09c19a8b0d274ed7 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a font descriptor.
  *
@@ -162,7 +165,12 @@ public class PDFFontDescriptor extends PDFObject {
         // CID optional field
         fillInPDF(p);
         p.append("\n >>\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
     /**
index 185addc9eab9e85297dc70a52e16c408270978d5..b17320f477886bb71fc2ddee204c7dab0fbf743b 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 // Java...
 import java.util.Vector;
+import java.io.UnsupportedEncodingException;
 
 /**
  * class representing a PDF Function.
@@ -663,8 +664,11 @@ public class PDFFunction extends PDFObject {
 
         }
 
-        return (p.toString().getBytes());
-
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index f8dd65a8e6f293060af57768d49d887972f1b048..8bcb5a0b7249bebec4c9595b524def93cd85a719 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a /GoTo object.
  *
@@ -91,7 +94,12 @@ public class PDFGoTo extends PDFAction {
         String p = new String(this.number + " " + this.generation
                               + " obj\n<<\n/S /GoTo\n" + destination
                               + ">>\nendobj\n");
-        return p.getBytes();
+                              
+        try {
+            return p.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.getBytes();
+        }       
     }
 
     /*
index aa8ef5afa7f868891b34ad8aa151816d298fa5b1..c238626024c2d6a1ec08cd5babff136ebc74bf51 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a /GoToR object.
  */
@@ -51,7 +54,12 @@ public class PDFGoToRemote extends PDFAction {
                               + pdfFileSpec.referencePDF() + "\n"
                               + "/D [ 0 /XYZ null null null ]"
                               + " \n>>\nendobj\n");
-        return p.getBytes();
+
+        try {
+            return p.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.getBytes();
+        }       
     }
 
 
index 5d96be0cd26158c9359d277fcd9900cf508f25fa..9462eb8dcb3fac9cf98ab939e37a9e351698bcca 100644 (file)
@@ -6,6 +6,10 @@
  */
 
 package org.apache.fop.pdf;
+
+// Java
+import java.io.UnsupportedEncodingException;
+// Fop
 import org.apache.fop.datatypes.ColorSpace;
 
 public class PDFICCStream extends PDFStream {
@@ -45,11 +49,20 @@ public class PDFICCStream extends PDFStream {
 
         pb.append("/Length ").append((_data.size() + 1)).append(" ").append(filterEntry);
         pb.append(" >>\n");
-        byte[] p = pb.toString().getBytes();
+        byte[] p;
+        try {
+            p = pb.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = pb.toString().getBytes();
+        }       
         stream.write(p);
         length += p.length;
         length += outputStreamData(stream);
-        p = "endobj\n".getBytes();
+        try {
+            p = "endobj\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "endobj\n".getBytes();
+        }       
         stream.write(p);
         length += p.length;
         return length;
index a8215fcea8f4618872a27095936b52997da01729..8e346d80ad09dd758d52bc3c1ec5a4a63839e285 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 // Java
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.io.PrintWriter;
 
 /**
@@ -48,7 +49,11 @@ public class PDFInfo extends PDFObject {
         String p = this.number + " " + this.generation
                    + " obj\n<< /Type /Info\n/Producer (" + this.producer
                    + ") >>\nendobj\n";
-        return p.getBytes();
+        try {
+            return p.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.getBytes();
+        }       
     }
 
 }
index 6af94f1d879f2f84cc772ff02961a73c54ec895e..f839a9a0aa981d429c70c1f80b8794c32a346b13 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 // Java
 import java.awt.Rectangle;
+import java.io.UnsupportedEncodingException;
 
 /**
  * class representing an /Annot object of /Subtype /Link
@@ -56,7 +57,12 @@ public class PDFLink extends PDFObject {
                    + (brx / 1000f) + " " + (bry / 1000f) + " ]\n" + "/C [ "
                    + this.color + " ]\n" + "/Border [ 0 0 0 ]\n" + "/A "
                    + this.action.getAction() + "\n" + "/H /I\n>>\nendobj\n";
-        return p.getBytes();
+
+        try {
+            return p.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.getBytes();
+        }       
     }
 
     /*
index 48e281b815d25ae1d5f2a35030085ea1ddc29788..1d280fedb5bd8260aaf3a070e26b918e952aefb7 100644 (file)
@@ -7,6 +7,8 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 
 
@@ -142,8 +144,12 @@ public class PDFOutline extends PDFObject {
 
         }
         result.append(">> endobj\n");
-        return result.toString().getBytes();
 
+        try {
+            return result.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return result.toString().getBytes();
+        }       
     }
 
     /**
index 8fce260985e54ce05d125948f2a9a2314d1ed470..19e3ab1351e70a899745bfe16831bf068467675a 100644 (file)
@@ -7,6 +7,8 @@
 
 package org.apache.fop.pdf;
 
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a /Page object.
  *
@@ -129,7 +131,11 @@ public class PDFPage extends PDFObject {
 
         sb = sb.append(">>\nendobj\n");
 
-        return sb.toString().getBytes();
+        try {
+            return sb.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return sb.toString().getBytes();
+        }       
     }
 
 }
index 4035fc2ebb45ca3d88597410db243735c18d9eb7..9274fdda6c431b287868dbc33f1f57a1bcb61170 100644 (file)
@@ -9,8 +9,10 @@ package org.apache.fop.pdf;
 
 // Java
 import java.io.PrintWriter;
-import org.apache.fop.messaging.MessageHandler;
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
+// Fop
+import org.apache.fop.messaging.MessageHandler;
 
 /**
  * class representing a /Pages object.
@@ -88,7 +90,12 @@ public class PDFPages extends PDFObject {
             p = p.append(kids.elementAt(i) + " ");
         }
         p = p.append("] >>\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index 3fa15d59b7a987135636b9c6f4facb27f0e4d5bd..cc1c5dbcf7456e6c5e038b8a790bc780e8e3141f 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.pdf;
 
 // Java...
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 
 // FOP...
@@ -288,10 +289,11 @@ public class PDFPattern extends PDFPathPaint {
 
         p.append("endobj\n");
 
-
-
-        return (p.toString().getBytes());
-
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index 2dc04fb74fee2c8be3096b5d5490016ed75603b0..b89e9a45162dad87a09e0e0ff1784240d8d128e8 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 /**
  * class representing a rectangle
  *
@@ -67,7 +70,11 @@ public class PDFRectangle {
      * @return the PDF
      */
     public byte[] toPDF() {
-        return toPDFString().getBytes();
+        try {
+            return toPDFString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return toPDFString().getBytes();
+        }       
     }
 
     public String toPDFString() {
index d51b716e45a50c1836389d427ed74e53d8802e9e..45602cb2291a0824f59f6b9162600fa51c08428b 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 // Java
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.Vector;
 import java.util.Hashtable;
@@ -138,7 +139,11 @@ public class PDFResources extends PDFObject {
 
         p = p.append(">> \nendobj\n");
 
-        return p.toString().getBytes();
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index 8741bd519e4bc667662107ad26cc33fd4fc59db0..edd6bdda3e76d29b1ead59f369c7e684f76d078c 100644 (file)
@@ -9,6 +9,7 @@ package org.apache.fop.pdf;
 
 // Java
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.io.PrintWriter;
 
 /**
@@ -96,7 +97,12 @@ public class PDFRoot extends PDFObject {
 
         }
         p.append(" >>\nendobj\n");
-        return p.toString().getBytes();
+
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index a1a1a9be0913ae5154c9771e90cbf605b5f2125e..8d5b1f20843c186905c1207f6626b16298a1dcf5 100644 (file)
@@ -8,6 +8,7 @@
 package org.apache.fop.pdf;
 
 // Java...
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 
 // FOP
@@ -505,7 +506,11 @@ public class PDFShading extends PDFObject {
 
         p.append(">> \nendobj\n");
 
-        return (p.toString().getBytes());
+        try {
+            return p.toString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return p.toString().getBytes();
+        }       
     }
 
 }
index 01b87b9d6bfbad91737666118ca01f5fa3244f9f..56d1e3af51f41776ecdc65a44ae9640afe92b206 100644 (file)
@@ -7,11 +7,14 @@
 
 package org.apache.fop.pdf;
 
+// Java
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 import java.util.Enumeration;
+// Fop
 import org.apache.fop.configuration.Configuration;
 import org.apache.fop.messaging.MessageHandler;
 
@@ -53,7 +56,11 @@ public class PDFStream extends PDFObject {
      */
     public void add(String s) {
         try {
-            _data.write(s.getBytes());
+            try {
+                _data.write(s.getBytes(PDFDocument.ENCODING));
+            } catch (UnsupportedEncodingException ue) {
+                _data.write(s.getBytes());
+            }
         } catch (IOException ex) {
             ex.printStackTrace();
         }
@@ -133,19 +140,35 @@ public class PDFStream extends PDFObject {
                     if (r < 16) {
                         _data.write('0');
                     }
-                    _data.write(Integer.toHexString(r).getBytes());
+                    try {
+                        _data.write(Integer.toHexString(r).getBytes(PDFDocument.ENCODING));
+                    } catch (UnsupportedEncodingException ue) {
+                        _data.write(Integer.toHexString(r).getBytes());
+                    }
                     if (g < 16) {
                         _data.write('0');
                     }
-                    _data.write(Integer.toHexString(g).getBytes());
+                    try {
+                        _data.write(Integer.toHexString(g).getBytes(PDFDocument.ENCODING));
+                    } catch (UnsupportedEncodingException ue) {
+                        _data.write(Integer.toHexString(g).getBytes());
+                    }
                     if (b < 16) {
                         _data.write('0');
                     }
-                    _data.write(Integer.toHexString(b).getBytes());
+                    try {
+                        _data.write(Integer.toHexString(b).getBytes(PDFDocument.ENCODING));
+                    } catch (UnsupportedEncodingException ue) {
+                        _data.write(Integer.toHexString(b).getBytes());
+                    }
                     _data.write(' ');
                 }
             }
-            _data.write(">\n".getBytes());
+            try {
+                _data.write(">\n".getBytes(PDFDocument.ENCODING));
+            } catch (UnsupportedEncodingException ue) {
+                _data.write(">\n".getBytes());
+            }
         } catch (IOException ex) {
             ex.printStackTrace();
         }
@@ -195,14 +218,23 @@ public class PDFStream extends PDFObject {
     protected int output(OutputStream stream) throws IOException {
         int length = 0;
         String filterEntry = applyFilters();
-        byte[] p = (this.number + " " + this.generation + " obj\n<< /Length "
+        String s = this.number + " " + this.generation + " obj\n<< /Length "
                     + (_data.size() + 1) + " " + filterEntry
-                    + " >>\n").getBytes();
-
+                    + " >>\n";
+        byte[] p;
+        try {
+            p = s.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = s.getBytes();
+        }
         stream.write(p);
         length += p.length;
         length += outputStreamData(stream);
-        p = "endobj\n".getBytes();
+        try {
+            p = "endobj\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "endobj\n".getBytes();
+        }
         stream.write(p);
         length += p.length;
         return length;
@@ -214,12 +246,21 @@ public class PDFStream extends PDFObject {
      */
     protected int outputStreamData(OutputStream stream) throws IOException {
         int length = 0;
-        byte[] p = "stream\n".getBytes();
+        byte[] p;
+        try {
+            p = "stream\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "stream\n".getBytes();
+        }
         stream.write(p);
         length += p.length;
         _data.writeTo(stream);
         length += _data.size();
-        p = "\nendstream\n".getBytes();
+        try {
+            p = "\nendstream\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "\nendstream\n".getBytes();
+        }
         stream.write(p);
         length += p.length;
         return length;
index a651a0637bae4e83a0a7805a56d43bc6f2c651f2..5588a0c01414844a526a32d2d3a26332161a4193 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 public class PDFT1Stream extends PDFStream {
     private int origLength;
     private int len1, len3;
@@ -41,7 +44,12 @@ public class PDFT1Stream extends PDFStream {
         // Get the first binary number and search backwards for "eexec"
         len1 = 30;
 
-        byte[] eexec = (new String("currentfile eexec")).getBytes();
+        byte[] eexec;
+        try {
+            eexec = "currentfile eexec".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            eexec = "currentfile eexec".getBytes();
+        }       
         // System.out.println("Length1="+len1);
         while (!byteCmp(originalData, len1 - eexec.length, eexec))
             len1++;
@@ -50,7 +58,13 @@ public class PDFT1Stream extends PDFStream {
 
         // Length3 is length of the last portion of the file
         len3 = 0;
-        byte[] cltom = (new String("cleartomark")).getBytes();
+        byte[] cltom;
+        try {
+            cltom = "cleartomark".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            cltom = "cleartomark".getBytes();
+        }       
+        
         len3 -= cltom.length;
         while (!byteCmp(originalData, origLength + len3, cltom)) {
             len3--;
@@ -60,9 +74,24 @@ public class PDFT1Stream extends PDFStream {
         len3++;
         // Eat 512 zeroes
         int numZeroes = 0;
-        byte[] ws1 = "\n".getBytes();
-        byte[] ws2 = "\r".getBytes();
-        byte[] ws3 = "0".getBytes();
+        byte[] ws1;
+        try {
+            ws1 = "\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            ws1 = "\n".getBytes();
+        }       
+        byte[] ws2;
+        try {
+            ws2 = "\r".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            ws2 = "\r".getBytes();
+        }       
+        byte[] ws3;
+        try {
+            ws3 = "0".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            ws3 = "0".getBytes();
+        }       
         while ((originalData[origLength - len3] == ws1[0] || originalData[origLength - len3] == ws2[0] || originalData[origLength - len3] == ws3[0])
                && numZeroes < 512) {
             len3++;
@@ -85,12 +114,22 @@ public class PDFT1Stream extends PDFStream {
                                     + (origLength - len3 - len1)
                                     + " /Length3 " + len3 + " >>\n");
 
-        byte[] p = preData.getBytes();
+        byte[] p;
+        try {
+            p = preData.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = preData.getBytes();
+        }       
+
         stream.write(p);
         length += p.length;
 
         length += outputStreamData(stream);
-        p = "endobj\n".getBytes();
+        try {
+            p = "endobj\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "endobj\n".getBytes();
+        }       
         stream.write(p);
         length += p.length;
         //System.out.println("Embedded Type1 font");
index ac0a7bf8d1b86d6ee003b76db55268d00ae8e8d2..a6e89434904c2b8cefece0e64c22217d4167ce07 100644 (file)
@@ -7,6 +7,9 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
+
 public class PDFTTFStream extends PDFStream {
     private int origLength;
 
@@ -27,12 +30,22 @@ public class PDFTTFStream extends PDFStream {
                                     + " " + "/Length1 " + origLength
                                     + " >>\n");
 
-        byte[] p = preData.getBytes();
+        byte[] p;
+        try {
+            p = preData.getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = preData.getBytes();
+        }       
+        
         stream.write(p);
         length += p.length;
 
         length += outputStreamData(stream);
-        p = "endobj\n".getBytes();
+        try {
+            p = "endobj\n".getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            p = "endobj\n".getBytes();
+        }       
         stream.write(p);
         length += p.length;
         return length;
index a391f45f31694bd1c4427b086a4f3ad50492f3bd..da86f7d48ad40350961ab661a587840bd1523b9b 100644 (file)
@@ -7,6 +7,8 @@
 
 package org.apache.fop.pdf;
 
+// Java
+import java.io.UnsupportedEncodingException;
 import java.util.Vector;
 
 /**
@@ -63,7 +65,11 @@ public class PDFWArray {
     }
 
     public byte[] toPDF() {
-        return toPDFString().getBytes();
+        try {
+            return toPDFString().getBytes(PDFDocument.ENCODING);
+        } catch (UnsupportedEncodingException ue) {
+            return toPDFString().getBytes();
+        }       
     }
 
     public String toPDFString() {
index ef859f807c5cea1712fc4d7d8183e89085f2bdef..db2ec8cb43125b3f334b5b70663874557a4dadf1 100644 (file)
@@ -12,11 +12,12 @@ package org.apache.fop.pdf;
 
 // Java
 import java.io.IOException;
-import org.apache.fop.messaging.MessageHandler;
+import java.io.UnsupportedEncodingException;
 import java.io.OutputStream;
 
 // FOP
 import org.apache.fop.datatypes.ColorSpace;
+import org.apache.fop.messaging.MessageHandler;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFICCStream;
 import org.apache.fop.image.FopImage;
@@ -119,8 +120,18 @@ public class PDFXObject extends PDFObject {
                 post.append("PreEPS_state restore\n");
                 post.append("end % userdict\n");
 
-                byte[] preBytes = preamble.toString().getBytes();
-                byte[] postBytes = post.toString().getBytes();
+                byte[] preBytes;
+                try {
+                    preBytes = preamble.toString().getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    preBytes = preamble.toString().getBytes();
+                }       
+                byte[] postBytes;
+                try {
+                    postBytes = post.toString().getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    postBytes = post.toString().getBytes();
+                }       
                 byte[] imgData = new byte[preBytes.length + postBytes.length + fopimage.getBitmaps().length];
 
                 System.arraycopy (preBytes, 0, imgData, 0, preBytes.length);
@@ -145,13 +156,22 @@ public class PDFXObject extends PDFObject {
                 p = p + ">>\n";
 
                 // push the pdf dictionary on the writer
-                byte[] pdfBytes = p.getBytes();
+                byte[] pdfBytes;
+                try {
+                    pdfBytes = p.getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    pdfBytes = p.getBytes();
+                }       
                 stream.write(pdfBytes);
                 length += pdfBytes.length;
                 // push all the image data on  the writer and takes care of length for trailer
                 length += imgStream.outputStreamData(stream);
 
-                pdfBytes = ("endobj\n").getBytes();
+                try {
+                    pdfBytes = ("endobj\n").getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    pdfBytes = ("endobj\n").getBytes();
+                }       
                 stream.write(pdfBytes);
                 length += pdfBytes.length;
 
@@ -210,13 +230,22 @@ public class PDFXObject extends PDFObject {
                 fopimage.close();
 
                 // push the pdf dictionary on the writer
-                byte[] pdfBytes = p.getBytes();
+                byte[] pdfBytes;
+                try {
+                    pdfBytes = p.getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    pdfBytes = p.getBytes();
+                }       
                 stream.write(pdfBytes);
                 length += pdfBytes.length;
                 // push all the image data on  the writer and takes care of length for trailer
                 length += imgStream.outputStreamData(stream);
 
-                pdfBytes = ("endobj\n").getBytes();
+                try {
+                    pdfBytes = ("endobj\n").getBytes(PDFDocument.ENCODING);
+                } catch (UnsupportedEncodingException ue) {
+                    pdfBytes = ("endobj\n").getBytes();
+                }       
                 stream.write(pdfBytes);
                 length += pdfBytes.length;
             }