1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #16718 from calixteman/bug1844572

Don't replace Acroform dictionary if nothing has changed when saving (bug 1844572)
This commit is contained in:
calixteman 2023-07-24 10:00:43 +02:00 committed by GitHub
commit 71f113bf85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 3 deletions

View file

@ -544,6 +544,7 @@ class WorkerMessageHandler {
pdfManager.ensureCatalog("acroForm"),
pdfManager.ensureCatalog("acroFormRef"),
pdfManager.ensureDoc("startXRef"),
pdfManager.ensureDoc("linearization"),
];
const newAnnotationsByPage = !isPureXfa
@ -595,6 +596,7 @@ class WorkerMessageHandler {
acroForm,
acroFormRef,
startXRef,
linearization,
...refs
]) {
let newRefs = [];
@ -656,7 +658,9 @@ class WorkerMessageHandler {
infoRef: xref.trailer.getRaw("Info") || null,
info: infoObj,
fileIds: xref.trailer.get("ID") || null,
startXRef: xref.lastXRefStreamPos ?? startXRef,
startXRef: linearization
? startXRef
: xref.lastXRefStreamPos ?? startXRef,
filename,
};
}

View file

@ -231,7 +231,7 @@ async function updateAcroform({
warn("XFA - Cannot save it");
}
if (!needAppearances && (!hasXfa || !xfaDatasetsRef)) {
if (!needAppearances && (!hasXfa || !xfaDatasetsRef || hasXfaDatasetsEntry)) {
return;
}

View file

@ -33,6 +33,8 @@ import { BaseStream } from "./base_stream.js";
import { CipherTransformFactory } from "./crypto.js";
class XRef {
#firstXRefStmPos = null;
constructor(stream, pdfManager) {
this.stream = stream;
this.pdfManager = pdfManager;
@ -705,6 +707,7 @@ class XRef {
// (possible infinite recursion)
this._xrefStms.add(obj);
this.startXRefQueue.push(obj);
this.#firstXRefStmPos ??= obj;
}
} else if (Number.isInteger(obj)) {
// Parse in-stream XRef
@ -754,7 +757,10 @@ class XRef {
}
get lastXRefStreamPos() {
return this._xrefStms.size > 0 ? Math.max(...this._xrefStms) : null;
return (
this.#firstXRefStmPos ??
(this._xrefStms.size > 0 ? Math.max(...this._xrefStms) : null)
);
}
getEntry(i) {