1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

[api-minor] Improve pdf reading in high contrast mode

- Use Canvas & CanvasText color when they don't have their default value
  as background and foreground colors.
- The colors used to draw (stroke/fill) in a pdf are replaced by the bg/fg
  ones according to their luminance.
This commit is contained in:
Calixte Denizet 2022-05-04 15:37:13 +02:00
parent 8135d7ccf6
commit c8afd6ce8c
9 changed files with 159 additions and 13 deletions

View file

@ -648,7 +648,8 @@ class Driver {
renderForms = false,
renderPrint = false,
renderXfa = false,
annotationCanvasMap = null;
annotationCanvasMap = null,
pageColors = null;
if (task.annotationStorage) {
const entries = Object.entries(task.annotationStorage),
@ -699,6 +700,7 @@ class Driver {
renderForms = !!task.forms;
renderPrint = !!task.print;
renderXfa = !!task.enableXfa;
pageColors = task.pageColors || null;
// Render the annotation layer if necessary.
if (renderAnnotations || renderForms || renderXfa) {
@ -746,6 +748,7 @@ class Driver {
viewport,
optionalContentConfigPromise: task.optionalContentConfigPromise,
annotationCanvasMap,
pageColors,
transform,
};
if (renderForms) {

View file

@ -60,6 +60,38 @@
"enhance": true,
"type": "text"
},
{ "id": "tracemonkey-forced-colors-eq",
"file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1,
"pageColors": {
"background": "black",
"foreground": "#00FF00"
},
"type": "eq"
},
{ "id": "tracemonkey-viewer-colors-eq",
"file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1,
"pageColors": {
"background": "Canvas",
"foreground": "CanvasText"
},
"type": "eq",
"about": "Uses the same pageColors as the viewer."
},
{ "id": "tracemonkey-default-colors-eq",
"file": "pdfs/tracemonkey.pdf",
"md5": "9a192d8b1a7dc652a19835f6f08098bd",
"rounds": 1,
"pageColors": {
"background": "white",
"foreground": "black"
},
"type": "eq",
"about": "Uses the default colors."
},
{ "id": "issue3925",
"file": "pdfs/issue3925.pdf",
"md5": "c5c895deecf7a7565393587e0d61be2b",