mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
XFA - Overwrite AcroForm dictionary when saving if no datasets in XFA (bug 1720179)
- aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1720179 - in some pdfs the XFA array in AcroForm dictionary doesn't contain an entry for 'datasets' (which contains saved data), so basically this patch allows to overwrite the AcroForm dictionary with an updated XFA array when doing an incremental update.
This commit is contained in:
parent
804abb3786
commit
77b9657e57
4 changed files with 140 additions and 4 deletions
|
@ -573,6 +573,7 @@ class WorkerMessageHandler {
|
|||
const promises = [
|
||||
pdfManager.onLoadedStream(),
|
||||
pdfManager.ensureCatalog("acroForm"),
|
||||
pdfManager.ensureCatalog("acroFormRef"),
|
||||
pdfManager.ensureDoc("xref"),
|
||||
pdfManager.ensureDoc("startXRef"),
|
||||
];
|
||||
|
@ -597,6 +598,7 @@ class WorkerMessageHandler {
|
|||
return Promise.all(promises).then(function ([
|
||||
stream,
|
||||
acroForm,
|
||||
acroFormRef,
|
||||
xref,
|
||||
startXRef,
|
||||
...refs
|
||||
|
@ -621,15 +623,22 @@ class WorkerMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
const xfa = (acroForm instanceof Dict && acroForm.get("XFA")) || [];
|
||||
const xfa = (acroForm instanceof Dict && acroForm.get("XFA")) || null;
|
||||
let xfaDatasets = null;
|
||||
let hasDatasets = false;
|
||||
if (Array.isArray(xfa)) {
|
||||
for (let i = 0, ii = xfa.length; i < ii; i += 2) {
|
||||
if (xfa[i] === "datasets") {
|
||||
xfaDatasets = xfa[i + 1];
|
||||
acroFormRef = null;
|
||||
hasDatasets = true;
|
||||
}
|
||||
}
|
||||
if (xfaDatasets === null) {
|
||||
xfaDatasets = xref.getNewRef();
|
||||
}
|
||||
} else {
|
||||
acroFormRef = null;
|
||||
// TODO: Support XFA streams.
|
||||
warn("Unsupported XFA type.");
|
||||
}
|
||||
|
@ -666,6 +675,9 @@ class WorkerMessageHandler {
|
|||
newRefs,
|
||||
xref,
|
||||
datasetsRef: xfaDatasets,
|
||||
hasDatasets,
|
||||
acroFormRef,
|
||||
acroForm,
|
||||
xfaData,
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue