From 3705e5e45986d66c5bb644f22b17de8e341839c9 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 24 Mar 2017 17:24:30 +0100 Subject: [PATCH] Use a proper `MessageHandler` for `PartialEvaluator.getTextContent` to avoid errors for fonts relying on built-in CMap files (PR 8064 follow-up) *My apologies for inadvertently breaking this in PR 8064; apparently we don't have any tests that cover this use-case :(* Without this patch `getTextContent` will fail if called before `getOperatorList`, since loading of fonts during text-extraction may require fetching of built-in CMap files. *Please note:* The `text` test added here, which uses an already existing PDF file, fails without this patch. --- src/core/document.js | 7 +------ src/core/worker.js | 2 +- test/test_manifest.json | 9 ++++++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 716b9a21d..0cb7dfe0e 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -310,14 +310,9 @@ var Page = (function PageClosure() { }); }, - extractTextContent: function Page_extractTextContent(task, + extractTextContent: function Page_extractTextContent(handler, task, normalizeWhitespace, combineTextItems) { - var handler = { - on: function nullHandlerOn() {}, - send: function nullHandlerSend() {} - }; - var self = this; var pdfManager = this.pdfManager; diff --git a/src/core/worker.js b/src/core/worker.js index 756c9e8a6..ec8aa4b1c 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -906,7 +906,7 @@ var WorkerMessageHandler = { startWorkerTask(task); var pageNum = pageIndex + 1; var start = Date.now(); - return page.extractTextContent(task, normalizeWhitespace, + return page.extractTextContent(handler, task, normalizeWhitespace, combineTextItems).then( function(textContent) { finishWorkerTask(task); diff --git a/test/test_manifest.json b/test/test_manifest.json index a266aea45..e99a638f6 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2757,10 +2757,17 @@ "md5": "797093d67c4d4d4231ac6e1fb66bf6c3", "rounds": 1, "link": true, - "firstPage": 1, "lastPage": 1, "type": "eq" }, + { "id": "mao-text", + "file": "pdfs/mao.pdf", + "md5": "797093d67c4d4d4231ac6e1fb66bf6c3", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "text" + }, { "id": "noembed-identity", "file": "pdfs/noembed-identity.pdf", "md5": "05d3803b6c22451e18cb60d8d8c75c0c",