mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 08:08:07 +02:00
JS - Handle correctly hierarchy of fields (#13133)
* JS - Handle correctly hierarchy of fields - it aims to fix #13132; - annotations can inherit their actions from the parent field; - there are some fields which act as a container for other fields: - they can be access through js so need to add them with an empty type (nothing in the spec about that but checked in Acrobat); - calculation order list (CO) can reference them so need make them through this.getField; - getArray method must return kids. - field values are number, string, ... depending of their type but nothing in the spec on how to know what's the type: - according to the comment for Canonical Format: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=461 - it seems that this "type" can be guessed from js action Format (when setting a type in Acrobat DC, the only affected thing is this action). - util.scand with an empty string returns the current date.
This commit is contained in:
parent
75a6b2fa13
commit
84d7cccb1d
13 changed files with 337 additions and 106 deletions
|
@ -695,4 +695,71 @@ describe("Interaction", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("in issue13132.pdf", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("issue13132.pdf", "#\\31 71R");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must compute sum of fields", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.waitForFunction(
|
||||
"window.PDFViewerApplication.scriptingReady === true"
|
||||
);
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.document.getElementById("171R").scrollIntoView();
|
||||
});
|
||||
|
||||
let sum = 0;
|
||||
for (const [id, val] of [
|
||||
["#\\31 38R", 1],
|
||||
["#\\37 7R", 2],
|
||||
["#\\39 3R", 3],
|
||||
["#\\31 51R", 4],
|
||||
["#\\37 9R", 5],
|
||||
]) {
|
||||
const prev = await page.$eval("#\\31 71R", el => el.value);
|
||||
|
||||
await page.type(id, val.toString(), { delay: 100 });
|
||||
await page.keyboard.press("Tab");
|
||||
|
||||
await page.waitForFunction(
|
||||
_prev =>
|
||||
getComputedStyle(document.querySelector("#\\31 71R")).value !==
|
||||
_prev,
|
||||
{},
|
||||
prev
|
||||
);
|
||||
|
||||
sum += val;
|
||||
|
||||
const total = await page.$eval("#\\31 71R", el => el.value);
|
||||
expect(total).withContext(`In ${browserName}`).toEqual(`£${sum}`);
|
||||
}
|
||||
|
||||
// Some unrendered annotations have been updated, so check
|
||||
// that they've the correct value when rendered.
|
||||
await page.evaluate(() => {
|
||||
window.document
|
||||
.querySelectorAll('[data-page-number="4"][class="page"]')[0]
|
||||
.scrollIntoView();
|
||||
});
|
||||
await page.waitForSelector("#\\32 99R", {
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
const total = await page.$eval("#\\32 99R", el => el.value);
|
||||
expect(total).withContext(`In ${browserName}`).toEqual(`£${sum}`);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
1
test/pdfs/issue13132.pdf.link
Normal file
1
test/pdfs/issue13132.pdf.link
Normal file
|
@ -0,0 +1 @@
|
|||
https://web.archive.org/web/20210324123420/https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/866023/IHT205_2004-2006.pdf
|
|
@ -2561,6 +2561,12 @@
|
|||
"link": true,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "issue13132",
|
||||
"file": "pdfs/issue13132.pdf",
|
||||
"md5": "1b28964b9188047bc6c786302c95029f",
|
||||
"link": true,
|
||||
"type": "other"
|
||||
},
|
||||
{ "id": "issue4722",
|
||||
"file": "pdfs/issue4722.pdf",
|
||||
"md5": "a42ca858af7d179358f92f47e57c0fed",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue