Take into account empty lines when extracting text content from the appearance

Fixes #17492.
This commit is contained in:
Calixte Denizet 2024-01-14 19:34:06 +01:00
parent 0d011472a4
commit 405f573d70
4 changed files with 19 additions and 0 deletions

View File

@ -2816,6 +2816,10 @@ class PartialEvaluator {
}
}
if (keepWhiteSpace) {
compareWithLastPosition(0);
}
return;
}

View File

@ -624,3 +624,4 @@
!bug1871353.pdf
!bug1871353.1.pdf
!file_pdfjs_form.pdf
!issue17492.pdf

BIN
test/pdfs/issue17492.pdf Normal file

Binary file not shown.

View File

@ -2550,6 +2550,20 @@ describe("api", function () {
await loadingTask.destroy();
});
it("read content from multiline textfield containing an empty line", async function () {
const loadingTask = getDocument(buildGetDocumentParams("issue17492.pdf"));
const pdfDoc = await loadingTask.promise;
const pdfPage = await pdfDoc.getPage(1);
const annotations = await pdfPage.getAnnotations();
const field = annotations.find(annotation => annotation.id === "144R");
expect(!!field).toEqual(true);
expect(field.fieldValue).toEqual("Several\n\nOther\nJobs");
expect(field.textContent).toEqual(["Several", "", "Other", "Jobs"]);
await loadingTask.destroy();
});
describe("Cross-origin", function () {
let loadingTask;
function _checkCanLoad(expectSuccess, filename, options) {