pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1686942 - in /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools: PDFDebugger.java gui/PDFTreeCellRenderer.java
Date Mon, 22 Jun 2015 21:16:19 GMT
Author: jahewson
Date: Mon Jun 22 21:16:18 2015
New Revision: 1686942

URL: http://svn.apache.org/r1686942
Log:
PDFBOX-2530: Display unprintable strings as hex

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java?rev=1686942&r1=1686941&r2=1686942&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java Mon Jun 22 21:16:18
2015
@@ -458,7 +458,17 @@ public class PDFDebugger extends javax.s
         }
         else if( selectedNode instanceof COSString )
         {
-            data = "" + ((COSString)selectedNode).getString();
+            String text = ((COSString) selectedNode).getString();
+            // display unprintable strings as hex
+            for (char c : text.toCharArray())
+            {
+                if (Character.isISOControl(c))
+                {
+                    text = "<" + ((COSString) selectedNode).toHexString() + ">";
+                    break;
+                }
+            }
+            data = "" + text;
         }
         else if( selectedNode instanceof COSStream )
         {

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java?rev=1686942&r1=1686941&r2=1686942&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
(original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/gui/PDFTreeCellRenderer.java
Mon Jun 22 21:16:18 2015
@@ -77,7 +77,17 @@ public class PDFTreeCellRenderer extends
         }
         else if (nodeValue instanceof COSString)
         {
-            result = ((COSString) nodeValue).getString();
+            String text = ((COSString) nodeValue).getString();
+            // display unprintable strings as hex
+            for (char c : text.toCharArray())
+            {
+                if (Character.isISOControl(c))
+                {
+                    text = "<" + ((COSString) nodeValue).toHexString() + ">";
+                    break;
+                }
+            }
+            result = text;
         }
         else if (nodeValue instanceof COSName)
         {



Mime
View raw message