From 08a241fc4b0a919946fa2285f49b553bf2151c31 Mon Sep 17 00:00:00 2001
From: Yury Delendik <ydelendik@mozilla.com>
Date: Thu, 5 Apr 2012 10:40:37 -0500
Subject: [PATCH] Convert Unicode strings in the document info (#1458)

---
 src/core.js   | 11 +++++++++--
 web/viewer.js |  4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/core.js b/src/core.js
index a90974386..3f3e95294 100644
--- a/src/core.js
+++ b/src/core.js
@@ -596,8 +596,15 @@ var PDFDocModel = (function PDFDocModelClosure() {
     },
     getDocumentInfo: function PDFDocModel_getDocumentInfo() {
       var info;
-      if (this.xref.trailer.has('Info'))
-        info = this.xref.fetch(this.xref.trailer.get('Info'));
+      if (this.xref.trailer.has('Info')) {
+        var infoDict = this.xref.fetch(this.xref.trailer.get('Info'));
+
+        info = {};
+        infoDict.forEach(function(key, value) {
+          info[key] = typeof value !== 'string' ? value :
+            stringToPDFString(value);
+        });
+      }
 
       return shadow(this, 'getDocumentInfo', info);
     },
diff --git a/web/viewer.js b/web/viewer.js
index 8977b53c0..72e887f4a 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -571,8 +571,8 @@ var PDFView = {
         pdfTitle = metadata.get('dc:title');
     }
 
-    if (!pdfTitle && info && info.has('Title'))
-      pdfTitle = info.get('Title');
+    if (!pdfTitle && info && info['Title'])
+      pdfTitle = info['Title'];
 
     if (pdfTitle)
       document.title = pdfTitle;