Skip to content

Commit 98dc351

Browse files
Merge pull request #20824 from calixteman/bug2015853
Add the possibility to merge/update acroforms when merging/extracting (bug 2015853)
2 parents 897e538 + baf8647 commit 98dc351

6 files changed

Lines changed: 713 additions & 36 deletions

File tree

src/core/core_utils.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,38 @@ function getParentToUpdate(dict, ref, xref) {
208208
return result;
209209
}
210210

211+
function deepCompare(a, b) {
212+
if (a === b) {
213+
return true;
214+
}
215+
if (a instanceof Dict && b instanceof Dict) {
216+
if (a.size !== b.size) {
217+
return false;
218+
}
219+
for (const [key, value1] of a.getRawEntries()) {
220+
const value2 = b.getRaw(key);
221+
if (value2 === undefined || !deepCompare(value1, value2)) {
222+
return false;
223+
}
224+
}
225+
return true;
226+
}
227+
228+
if (Array.isArray(a) && Array.isArray(b)) {
229+
if (a.length !== b.length) {
230+
return false;
231+
}
232+
for (let i = 0, ii = a.length; i < ii; i++) {
233+
if (!deepCompare(a[i], b[i])) {
234+
return false;
235+
}
236+
}
237+
return true;
238+
}
239+
240+
return false;
241+
}
242+
211243
// prettier-ignore
212244
const ROMAN_NUMBER_MAP = [
213245
"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM",
@@ -745,6 +777,7 @@ export {
745777
arrayBuffersToBytes,
746778
codePointIter,
747779
collectActions,
780+
deepCompare,
748781
encodeToXmlString,
749782
escapePDFName,
750783
escapeString,

0 commit comments

Comments
 (0)