mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[api-minor] Extend general transfer function support to browsers without OffscreenCanvas
This patch extends PR 16115 to work in all browsers, regardless of their `OffscreenCanvas` support, such that transfer functions will be applied to general rendering (and not just image data). In order to do this we introduce the `BaseFilterFactory` that is then extended in browsers/Node.js environments, similar to all the other factories used in the API, such that we always have the necessary factory available in `src/display/canvas.js`. These changes help simplify the existing `putBinaryImageData` function, and the new method can easily be stubbed-out in the Firefox PDF Viewer. *Please note:* This patch removes the old *partial* transfer function support, which only applied to image data, from Node.js environments since the `node-canvas` package currently doesn't support filters. However, this should hopefully be fine given that: - Transfer functions are not very commonly used in PDF documents. - Browsers in general, and Firefox in particular, are the *primary* development target for the PDF.js library. - The FAQ only lists Node.js as *mostly* supported, see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
This commit is contained in:
parent
945855a2b8
commit
fc055dbd80
8 changed files with 92 additions and 102 deletions
|
@ -469,6 +469,8 @@ class Driver {
|
|||
.getElementsByTagName("head")[0]
|
||||
.append(xfaStyleElement);
|
||||
}
|
||||
const isOffscreenCanvasSupported =
|
||||
task.isOffscreenCanvasSupported === false ? false : undefined;
|
||||
|
||||
const loadingTask = getDocument({
|
||||
url: new URL(task.file, window.location),
|
||||
|
@ -480,6 +482,7 @@ class Driver {
|
|||
useSystemFonts: task.useSystemFonts,
|
||||
useWorkerFetch: task.useWorkerFetch,
|
||||
enableXfa: task.enableXfa,
|
||||
isOffscreenCanvasSupported,
|
||||
styleElement: xfaStyleElement,
|
||||
});
|
||||
let promise = loadingTask.promise;
|
||||
|
|
|
@ -6281,6 +6281,13 @@
|
|||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue6931-disable-isOffscreenCanvasSupported",
|
||||
"file": "pdfs/issue6931_reduced.pdf",
|
||||
"md5": "e61388913821a5e044bf85a5846d6d9a",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"isOffscreenCanvasSupported": false
|
||||
},
|
||||
{ "id": "annotation-button-widget-annotations",
|
||||
"file": "pdfs/annotation-button-widget.pdf",
|
||||
"md5": "5cf23adfff84256d9cfe261bea96dade",
|
||||
|
@ -7474,6 +7481,15 @@
|
|||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue16114-disable-isOffscreenCanvasSupported",
|
||||
"file": "pdfs/issue16114.pdf",
|
||||
"md5": "c04827ea33692e0f94a5e51716d9aa2e",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq",
|
||||
"isOffscreenCanvasSupported": false
|
||||
},
|
||||
{
|
||||
"id": "bug1820909",
|
||||
"file": "pdfs/bug1820909.pdf",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue