Try to not omit some values when printing a choice list with several selected items

This commit is contained in:
Calixte Denizet 2023-05-31 18:48:42 +02:00
parent a2118f52b0
commit 0e610cab04
4 changed files with 24 additions and 10 deletions

View File

@ -3334,15 +3334,15 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
const vPadding = (lineHeight - fontSize) / 2;
const numberOfVisibleLines = Math.floor(totalHeight / lineHeight);
let firstIndex;
if (valueIndices.length === 1) {
const valuePosition = valueIndices[0];
const indexInPage = valuePosition % numberOfVisibleLines;
firstIndex = valuePosition - indexInPage;
} else {
// If nothing is selected (valueIndice.length === 0), we render
// from the first element.
firstIndex = valueIndices.length ? valueIndices[0] : 0;
let firstIndex = 0;
if (valueIndices.length > 0) {
const minIndex = Math.min(...valueIndices);
const maxIndex = Math.max(...valueIndices);
firstIndex = Math.max(0, maxIndex - numberOfVisibleLines + 1);
if (firstIndex > minIndex) {
firstIndex = minIndex;
}
}
const end = Math.min(firstIndex + numberOfVisibleLines + 1, lineCount);

View File

@ -596,3 +596,4 @@
!issue14755.pdf
!issue16473.pdf
!bug1529502.pdf
!issue16500.pdf

BIN
test/pdfs/issue16500.pdf Executable file

Binary file not shown.

View File

@ -7694,5 +7694,18 @@
"md5": "4830e765a3d6cb64d39b84de11178f6e",
"rounds": 1,
"type": "eq"
}
},
{
"id": "issue16500",
"file": "pdfs/issue16500.pdf",
"md5": "6466546aaa5fcf31235bdf100496705c",
"rounds": 1,
"type": "eq",
"print": true,
"annotationStorage": {
"7R": {
"value": ["Three", "Five"]
}
}
}
]