var defaultWidth = privateDict['defaultWidthX'];
       var charstrings = [];
       var differences = properties.differences;
-      var index = 0;
+      var index = properties.firstChar || 0;
       for (var i = 1; i < charsets.length; i++) {
         var code = -1;
         var glyph = charsets[i];
           }
         }
 
-        var mapping = properties.glyphs[glyph] || {};
+        var mapping =
+          properties.glyphs[glyph] || properties.glyphs[index] || {};
         if (code == -1)
           index = code = mapping.unicode || index;
 
 
       var stream = this.stream;
       stream.pos = 0;
       var buffer = stream.getBytes();
-      var position = 0, length = buffer.length;
+      var position = stream.start, length = buffer.length;
       var trailers = [], xrefStms = [];
       var state = 0;
       var currentToken;
           this.readXRef(xrefStms[i]);
       }
       // finding main trailer
+      var dict;
       for (var i = 0; i < trailers.length; ++i) {
         stream.pos = trailers[i];
         var parser = new Parser(new Lexer(stream), true);
         if (!isCmd(obj, 'trailer'))
           continue;
         // read the trailer dictionary
-        var dict;
         if (!isDict(dict = parser.getObj()))
           continue;
         // taking the first one with 'ID'
         if (dict.has('ID'))
           return dict;
       }
+      // no tailer with 'ID', taking last one (if exists)
+      if (dict)
+        return dict;
       // nothing helps
       error('Invalid PDF structure');
       return null;
         var glyph = differences[i];
         var replaceGlyph = true;
         if (!glyph) {
-          glyph = baseEncoding[i];
+          glyph = baseEncoding[i] || i;
           replaceGlyph = false;
         }
         var index = GlyphsUnicode[glyph] || i;
           width: isNum(width) ? width : properties.defaultWidth
         };
 
-        if (glyph && (replaceGlyph || !glyphs[glyph]))
+        if (replaceGlyph || !glyphs[glyph])
             glyphs[glyph] = map[i];
 
         // If there is no file, the character mapping can't be modified