[api-minor] Render pushbuttons on their own canvas (bug 1737260)

- First step to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1737260;
 - several interactive pdfs use the possibility to hide/show buttons to show different icons;
 - render pushbuttons on their own canvas and then insert it the annotation_layer;
 - update test/driver.js in order to convert canvases for pushbuttons into images.
This commit is contained in:
Calixte Denizet 2021-11-06 18:36:49 +01:00
parent 891f21fba6
commit 33ea817b20
13 changed files with 333 additions and 86 deletions

View file

@ -1161,6 +1161,8 @@ class PDFDocumentProxy {
* created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,
* the configuration will be fetched automatically with the default visibility
* states set.
* @property {Map<string, Canvas>} [annotationCanvasMap] - Map some annotation
* ids with canvases used to render them.
*/
/**
@ -1374,6 +1376,7 @@ class PDFPageProxy {
canvasFactory = null,
background = null,
optionalContentConfigPromise = null,
annotationCanvasMap = null,
}) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
if (arguments[0]?.renderInteractiveForms !== undefined) {
@ -1491,6 +1494,7 @@ class PDFPageProxy {
},
objs: this.objs,
commonObjs: this.commonObjs,
annotationCanvasMap,
operatorList: intentState.operatorList,
pageIndex: this._pageIndex,
canvasFactory: canvasFactoryInstance,
@ -3216,6 +3220,7 @@ class InternalRenderTask {
params,
objs,
commonObjs,
annotationCanvasMap,
operatorList,
pageIndex,
canvasFactory,
@ -3226,6 +3231,7 @@ class InternalRenderTask {
this.params = params;
this.objs = objs;
this.commonObjs = commonObjs;
this.annotationCanvasMap = annotationCanvasMap;
this.operatorListIdx = null;
this.operatorList = operatorList;
this._pageIndex = pageIndex;
@ -3284,7 +3290,8 @@ class InternalRenderTask {
this.objs,
this.canvasFactory,
imageLayer,
optionalContentConfig
optionalContentConfig,
this.annotationCanvasMap
);
this.gfx.beginDrawing({
transform,