DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41434>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41434

           Summary: [PATCH] Fix PDF Genaration for non ASCII compatibable
                    locales
           Product: Fop
           Version: all
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: pdf
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: [EMAIL PROTECTED]


Currently, the PDF library of FOP uses getBytes in various places. The behaviour
of this functions depends on current locale. If the locale is not compatible
with ASCII, an invalid PDF will be generated (eg. with default locale IBM-1047).

To fix this, the getBytes call are replaced with a call to PDFDocument.encode.
Patch is made for the 0.93 version. As the pdf library in the trunk version is
the same, the patch should also be applied there.

diff -urN fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFDocument.java
fop-brz/fop-0.93/src/java/org/apache/fop/
pdf/PDFDocument.java
--- fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFDocument.java     
2007-01-03 21:44:52.000000000 +0100
+++ fop-brz/fop-0.93/src/java/org/apache/fop/pdf/PDFDocument.java      
2007-01-11 18:14:07.000000000 +0100
@@ -849,7 +849,7 @@

         getProfile().verifyPDFVersion();

-        byte[] pdf = ("%PDF-" + getPDFVersionString() + "\n").getBytes();
+        byte[] pdf = encode("%PDF-" + getPDFVersionString() + "\n");
         stream.write(pdf);
         this.position += pdf.length;

@@ -870,9 +870,9 @@
         try {
             MessageDigest digest = MessageDigest.getInstance("MD5");
             DateFormat df = new
SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS");
-            digest.update(df.format(new Date()).getBytes());
+            digest.update(encode(df.format(new Date())));
             //Ignoring the filename here for simplicity even though it's
recommended by the PDF spec
-            digest.update(String.valueOf(this.position).getBytes());
+            digest.update(encode(String.valueOf(this.position)));
             digest.update(getInfo().toPDF());
             byte[] res = digest.digest();
             String s = PDFText.toHex(res);
diff -urN fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFRectangle.java
fop-brz/fop-0.93/src/java/org/apache/fop
/pdf/PDFRectangle.java
--- fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFRectangle.java    
2007-01-03 21:44:49.000000000 +0100
+++ fop-brz/fop-0.93/src/java/org/apache/fop/pdf/PDFRectangle.java     
2007-01-11 18:20:50.000000000 +0100
@@ -79,7 +79,7 @@
      * @return the PDF
      */
     public byte[] toPDF() {
-        return toPDFString().getBytes();
+        return PDFDocument.encode(toPDFString());
     }

     /**
diff -urN fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFStream.java
fop-brz/fop-0.93/src/java/org/apache/fop/pd
f/PDFStream.java
--- fop-orig/fop-0.93/src/java/org/apache/fop/pdf/PDFStream.java       
2007-01-03 21:44:44.000000000 +0100
+++ fop-brz/fop-0.93/src/java/org/apache/fop/pdf/PDFStream.java 2007-01-11
18:21:19.000000000 +0100
@@ -57,7 +57,7 @@
      */
     public void add(String s) {
         try {
-            data.getOutputStream().write(s.getBytes());
+            data.getOutputStream().write(PDFDocument.encode(s));
         } catch (IOException ex) {
             //TODO throw the exception and catch it elsewhere
             ex.printStackTrace();

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

Reply via email to