Merge pull request #18853 from calixteman/issue18036
Keep the empty lines in the text fields
This commit is contained in:
commit
5a25c477b7
@ -2299,7 +2299,7 @@ class WidgetAnnotation extends Annotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(typeof value === "string", "Expected `value` to be a string.");
|
assert(typeof value === "string", "Expected `value` to be a string.");
|
||||||
value = value.trim();
|
value = value.trimEnd();
|
||||||
|
|
||||||
if (this.data.combo) {
|
if (this.data.combo) {
|
||||||
// The value can be one of the exportValue or any other values.
|
// The value can be one of the exportValue or any other values.
|
||||||
@ -2934,6 +2934,28 @@ class TextWidgetAnnotation extends WidgetAnnotation {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async extractTextContent(evaluator, task, viewBox) {
|
||||||
|
await super.extractTextContent(evaluator, task, viewBox);
|
||||||
|
const text = this.data.textContent;
|
||||||
|
if (!text) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The text extractor doesn't handle empty lines correctly, so if the
|
||||||
|
// content we get is more or less (modulo whitespaces) the same as the
|
||||||
|
// field value we just ignore it.
|
||||||
|
const allText = text.join("\n");
|
||||||
|
if (allText === this.data.fieldValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const regex = allText.replaceAll(/([.*+?^${}()|[\]\\])|(\s+)/g, (_m, p1) =>
|
||||||
|
p1 ? `\\${p1}` : "\\s+"
|
||||||
|
);
|
||||||
|
if (new RegExp(`^\\s*${regex}\\s*$`).test(this.data.fieldValue)) {
|
||||||
|
this.data.textContent = this.data.fieldValue.split("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getFieldObject() {
|
getFieldObject() {
|
||||||
return {
|
return {
|
||||||
id: this.data.id,
|
id: this.data.id,
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -674,3 +674,4 @@
|
|||||||
!issue18072.pdf
|
!issue18072.pdf
|
||||||
!stamps.pdf
|
!stamps.pdf
|
||||||
!issue15096.pdf
|
!issue15096.pdf
|
||||||
|
!issue18036.pdf
|
||||||
|
|||||||
BIN
test/pdfs/issue18036.pdf
Executable file
BIN
test/pdfs/issue18036.pdf
Executable file
Binary file not shown.
@ -8477,13 +8477,13 @@
|
|||||||
"value": "Hello World"
|
"value": "Hello World"
|
||||||
},
|
},
|
||||||
"33R": {
|
"33R": {
|
||||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
"value": "\nHello World\nDlrow Olleh\nHello World"
|
||||||
},
|
},
|
||||||
"36R": {
|
"36R": {
|
||||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
"value": "\nHello World\nDlrow Olleh\nHello World"
|
||||||
},
|
},
|
||||||
"39R": {
|
"39R": {
|
||||||
"value": "Hello World\nDlrow Olleh\nHello World"
|
"value": "\nHello World\nDlrow Olleh\nHello World"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -10684,5 +10684,13 @@
|
|||||||
"value": false
|
"value": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue18036",
|
||||||
|
"file": "pdfs/issue18036.pdf",
|
||||||
|
"md5": "940ad97fc1a6f8d288a213af80313c7e",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user