Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct the correct field name and strip out classes when searching #16915

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,7 @@ class Annotation {
}

if (loopDict.has("T")) {
const t = stringToPDFString(loopDict.get("T"));
if (!t.startsWith("#")) {
// If it starts with a # then it's a class which is not a concept for
// datasets elements (https://www.pdfa.org/norm-refs/XFA-3_3.pdf#page=96).
fieldName.unshift(t);
}
fieldName.unshift(stringToPDFString(loopDict.get("T")));
}
}
return fieldName.join(".");
Expand Down
5 changes: 5 additions & 0 deletions src/core/xml_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ class SimpleDOMNode {
}

const component = paths[pos];
if (component.name.startsWith("#") && pos < paths.length - 1) {
// If it starts with a # then it's a class which is not a concept for
// datasets elements (https://www.pdfa.org/norm-refs/XFA-3_3.pdf#page=96).
return this.searchNode(paths, pos + 1);
}
const stack = [];
let node = this;

Expand Down
12 changes: 12 additions & 0 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,7 @@ describe("api", function () {
const value = "Hello World";

pdfDoc.annotationStorage.setValue("2055R", { value });
pdfDoc.annotationStorage.setValue("2090R", { value });

const data = await pdfDoc.saveDocument();
await loadingTask.destroy();
Expand All @@ -2051,6 +2052,17 @@ describe("api", function () {
);
expect(surName.nodeValue).toEqual(value);

// The path for the date is:
// PPTC_153[0].Page1[0].DeclerationAndSignatures[0]
// .#subform[2].currentDate[0]
// and it contains a class (i.e. #subform[2]) which is irrelevant in the
// context of datasets (it's more a template concept).
const date = getNamedNodeInXML(
datasets.node,
"xfa:data.PPTC_153.Page1.DeclerationAndSignatures.currentDate.#text"
);
expect(date.nodeValue).toEqual(value);

await loadingTask.destroy();
});

Expand Down