Skip to content

Commit

Permalink
Merge pull request #17512 from calixteman/issue17492
Browse files Browse the repository at this point in the history
Take into account empty lines when extracting text content from the appearance
  • Loading branch information
calixteman authored Jan 15, 2024
2 parents e98a813 + 405f573 commit 2ca20de
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2816,6 +2816,10 @@ class PartialEvaluator {
}
}

if (keepWhiteSpace) {
compareWithLastPosition(0);
}

return;
}

Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -624,3 +624,4 @@
!bug1871353.pdf
!bug1871353.1.pdf
!file_pdfjs_form.pdf
!issue17492.pdf
Binary file added test/pdfs/issue17492.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2ca20de

Please sign in to comment.