1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +02:00

XFA - Save filled data in the pdf when downloading the file (Bug 1716288)

- when binding (after parsing) we get a map between some template nodes and some data nodes;
  - so set user data in input handlers in using data node uids in the annotation storage;
  - to save the form, just put the value we have in the storage in the correct data nodes, serialize the xml as a string and then write the string at the end of the pdf using src/core/writer.js;
  - fix few bugs around data bindings:
    - the "Off" issue in Bug 1716980.
This commit is contained in:
Calixte Denizet 2021-06-25 14:31:55 +02:00
parent d7fdb72a3f
commit 429ffdcd2f
17 changed files with 71564 additions and 113 deletions

View file

@ -29,6 +29,7 @@ import {
$hasSettableValue,
$indexOf,
$insertAt,
$isBindable,
$isDataValue,
$isDescendent,
$namespaceId,
@ -87,12 +88,12 @@ class Binder {
// data node (through $data property): we'll use it
// to save form data.
formNode[$data] = data;
if (formNode[$hasSettableValue]()) {
if (data[$isDataValue]()) {
const value = data[$getDataValue]();
// TODO: use picture.
formNode[$setValue](createText(value));
formNode[$data] = data;
} else if (
formNode instanceof Field &&
formNode.ui &&
@ -103,13 +104,11 @@ class Binder {
.map(child => child[$content].trim())
.join("\n");
formNode[$setValue](createText(value));
formNode[$data] = data;
} else if (this._isConsumeData()) {
warn(`XFA - Nodes haven't the same type.`);
}
} else if (!data[$isDataValue]() || this._isMatchTemplate()) {
this._bindElement(formNode, data);
formNode[$data] = data;
} else {
warn(`XFA - Nodes haven't the same type.`);
}
@ -496,6 +495,12 @@ class Binder {
continue;
}
if (!child[$isBindable]()) {
// The node cannot contain some new data so there is nothing
// to create in the data node.
continue;
}
let global = false;
let picture = null;
let ref = null;