Merge pull request #12230 from timvandermeij/reference-test-print

Implement reference testing for printing
This commit is contained in:
Tim van der Meij 2020-08-18 13:11:18 +02:00 committed by GitHub
commit b52b36f6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 1 deletions

View File

@ -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) {

View File

@ -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",