Browse Source

Fix loading of PDF files with invalid or missing Type3 characters (issue 5039)

Jonas Jenwald 11 years ago
parent
commit
2485f11829
  1. 7
      src/core/evaluator.js
  2. 7
      src/display/canvas.js
  3. 1
      test/pdfs/.gitignore
  4. BIN
      test/pdfs/issue5039.pdf
  5. 7
      test/test_manifest.json

7
src/core/evaluator.js

@ -1760,13 +1760,16 @@ var TranslatedFont = (function TranslatedFontClosure() { @@ -1760,13 +1760,16 @@ var TranslatedFont = (function TranslatedFontClosure() {
var glyphStream = charProcs[key];
var operatorList = new OperatorList();
return evaluator.getOperatorList(glyphStream, fontResources,
operatorList).
then(function () {
operatorList).then(function () {
charProcOperatorList[key] = operatorList.getIR();
// Add the dependencies to the parent operator list so they are
// resolved before sub operator list is executed synchronously.
parentOperatorList.addDependencies(operatorList.dependencies);
}, function (reason) {
warn('Type3 font resource \"' + key + '\" is not available');
var operatorList = new OperatorList();
charProcOperatorList[key] = operatorList.getIR();
});
}.bind(this, charProcKeys[i]));
}

7
src/display/canvas.js

@ -1489,11 +1489,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { @@ -1489,11 +1489,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
continue;
}
var operatorList = font.charProcOperatorList[glyph.operatorListId];
if (!operatorList) {
warn('Type3 character \"' + glyph.operatorListId +
'\" is not available');
continue;
}
this.processingType3 = glyph;
this.save();
ctx.scale(fontSize, fontSize);
ctx.transform.apply(ctx, fontMatrix);
var operatorList = font.charProcOperatorList[glyph.operatorListId];
this.executeOperatorList(operatorList);
this.restore();

1
test/pdfs/.gitignore vendored

@ -52,6 +52,7 @@ @@ -52,6 +52,7 @@
!issue1002.pdf
!issue925.pdf
!issue4668.pdf
!issue5039.pdf
!gradientfill.pdf
!bug903856.pdf
!bug850854.pdf

BIN
test/pdfs/issue5039.pdf

Binary file not shown.

7
test/test_manifest.json

@ -1024,6 +1024,13 @@ @@ -1024,6 +1024,13 @@
"link": true,
"type": "eq"
},
{ "id": "issue5039",
"file": "pdfs/issue5039.pdf",
"md5": "5c131f458ee6b65cc096ccaf0474ee3a",
"link": false,
"rounds": 1,
"type": "eq"
},
{ "id": "issue1257",
"file": "pdfs/issue1257.pdf",
"md5": "9111533826bc21ed774e8e01603a2f54",

Loading…
Cancel
Save