diff --git a/src/display/api.js b/src/display/api.js index 1ebdd22ed..5a37e574c 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1884,6 +1884,7 @@ var WorkerTransport = (function WorkerTransportClosure() { var font = new FontFaceObject(exportedData, { isEvalSupported: params.isEvalSupported, disableFontFace: params.disableFontFace, + ignoreErrors: params.ignoreErrors, fontRegistry, }); var fontReady = (fontObjs) => { diff --git a/src/display/font_loader.js b/src/display/font_loader.js index 411872582..be662bcae 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -338,6 +338,7 @@ var IsEvalSupportedCached = { var FontFaceObject = (function FontFaceObjectClosure() { function FontFaceObject(translatedData, { isEvalSupported = true, disableFontFace = false, + ignoreErrors = false, fontRegistry = null, }) { this.compiledGlyphs = Object.create(null); // importing translated data @@ -346,6 +347,7 @@ var FontFaceObject = (function FontFaceObjectClosure() { } this.isEvalSupported = isEvalSupported !== false; this.disableFontFace = disableFontFace === true; + this.ignoreErrors = ignoreErrors === true; this.fontRegistry = fontRegistry; } FontFaceObject.prototype = { @@ -390,7 +392,19 @@ var FontFaceObject = (function FontFaceObjectClosure() { return this.compiledGlyphs[character]; } - let cmds = objs.get(this.loadedName + '_path_' + character), current; + let cmds, current; + try { + cmds = objs.get(this.loadedName + '_path_' + character); + } catch (ex) { + if (!this.ignoreErrors) { + throw ex; + } + warn(`getPathGenerator - ignoring character: "${ex}".`); + + return this.compiledGlyphs[character] = function(c, size) { + // No-op function, to allow rendering to continue. + }; + } // If we can, compile cmds into JS for MAXIMUM SPEED... if (this.isEvalSupported && IsEvalSupportedCached.value) { diff --git a/test/pdfs/issue4244.pdf.link b/test/pdfs/issue4244.pdf.link new file mode 100644 index 000000000..05767bbfe --- /dev/null +++ b/test/pdfs/issue4244.pdf.link @@ -0,0 +1 @@ +https://web.archive.org/web/20180613082417/https://tcpdf.org/files/examples/example_026.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 6b8142274..99213a1a7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2267,6 +2267,13 @@ "rounds": 1, "type": "eq" }, + { "id": "issue4244", + "file": "pdfs/issue4244.pdf", + "md5": "26845274a32a537182ced1fd693a38b2", + "rounds": 1, + "link": true, + "type": "eq" + }, { "id": "preistabelle", "file": "pdfs/preistabelle.pdf", "md5": "d2f0b2086160d4f3d325c79a5dc1fb4d",