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] 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 ddc89ce76..efc28063e 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) {