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

View File

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

BIN
test/pdfs/issue16500.pdf Executable file

Binary file not shown.

View File

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