From 8ccf09d5dd410a7ebd9c048b91bbd73fa7f7e5ba Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Mon, 17 Aug 2020 22:03:01 +0200 Subject: [PATCH 1/2] Implement reference testing for printing This commit includes support for rendering pages in printing mode, which, when combined with annotation storage data, is useful for testing if form data is correctly rendered onto the printed canvas. --- test/driver.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/driver.js b/test/driver.js index ddc89ce769bf9..efc28063edeed 100644 --- a/test/driver.js +++ b/test/driver.js @@ -519,7 +519,8 @@ var Driver = (function DriverClosure() { // Initialize various `eq` test subtypes, see comment below. var renderAnnotations = false, - renderForms = false; + renderForms = false, + renderPrint = false; var textLayerCanvas, annotationLayerCanvas; var initPromise; @@ -559,6 +560,7 @@ var Driver = (function DriverClosure() { // accidentally changing the behaviour for other types of tests. renderAnnotations = !!task.annotations; renderForms = !!task.forms; + renderPrint = !!task.print; // Render the annotation layer if necessary. if (renderAnnotations || renderForms) { @@ -604,6 +606,19 @@ var Driver = (function DriverClosure() { viewport, renderInteractiveForms: renderForms, }; + if (renderPrint) { + const annotationStorage = task.annotationStorage; + if (annotationStorage) { + const docAnnotationStorage = task.pdfDoc.annotationStorage; + const entries = Object.entries(annotationStorage); + for (const [key, value] of entries) { + docAnnotationStorage.setValue(key, value); + } + renderContext.annotationStorage = docAnnotationStorage; + } + renderContext.intent = "print"; + } + var completeRender = function (error) { // if text layer is present, compose it on top of the page if (textLayerCanvas) { From 483efedc664abeed12cd5d66d62417ebd68cc81a Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Mon, 17 Aug 2020 22:34:02 +0200 Subject: [PATCH 2/2] Include reference tests for text/choice/button widget printing --- test/test_manifest.json | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/test_manifest.json b/test/test_manifest.json index dac514ba5058c..9a9370bd84be7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -4448,6 +4448,22 @@ "type": "eq", "forms": true }, + { "id": "annotation-text-widget-print", + "file": "pdfs/annotation-text-widget.pdf", + "md5": "b7b8923a12998fca8603fae53f73f19b", + "rounds": 1, + "type": "eq", + "print": true, + "annotationStorage": { + "61R": "Single line, unlimited length", + "62R": "Single lin", + "63R": "Single line, center aligned", + "64R": "Single line, right aligned", + "65R": "", + "66R": "zyxwvutsrqponmlkjihgfedcba", + "67R": "Multiline\nstring" + } + }, { "id": "annotation-choice-widget-annotations", "file": "pdfs/annotation-choice-widget.pdf", "md5": "7dfb0d743a0da0f4a71b209ab43b0be5", @@ -4462,6 +4478,20 @@ "type": "eq", "forms": true }, + { "id": "annotation-choice-widget-print", + "file": "pdfs/annotation-choice-widget.pdf", + "md5": "7dfb0d743a0da0f4a71b209ab43b0be5", + "rounds": 1, + "type": "eq", + "print": true, + "annotationStorage": { + "57R": "Ipsum", + "58R": "Lorem", + "59R": "Dolor", + "62R": "Sit", + "63R": "" + } + }, { "id": "issue11931", "file": "pdfs/issue11931.pdf", "md5": "9ea233037992e1f10280420a49e72845", @@ -4488,6 +4518,24 @@ "type": "eq", "forms": true }, + { "id": "annotation-button-widget-print", + "file": "pdfs/annotation-button-widget.pdf", + "md5": "5cf23adfff84256d9cfe261bea96dade", + "rounds": 1, + "type": "eq", + "print": true, + "annotationStorage": { + "105R": true, + "106R": false, + "107R": false, + "108R": true, + "109R": false, + "110R": false, + "111R": true, + "112R": false, + "113R": false + } + }, { "id": "annotation-polyline-polygon", "file": "pdfs/annotation-polyline-polygon.pdf", "md5": "e68611602f58c8ca70cc40575ba3b04e",