Skip to content

Commit

Permalink
Merge pull request #12230 from timvandermeij/reference-test-print
Browse files Browse the repository at this point in the history
Implement reference testing for printing
  • Loading branch information
timvandermeij authored Aug 18, 2020
2 parents 37e9c97 + 483efed commit b52b36f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
48 changes: 48 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit b52b36f

Please sign in to comment.