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:
commit
71f113bf85
5 changed files with 38 additions and 3 deletions
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ async function updateAcroform({
|
|||
warn("XFA - Cannot save it");
|
||||
}
|
||||
|
||||
if (!needAppearances && (!hasXfa || !xfaDatasetsRef)) {
|
||||
if (!needAppearances && (!hasXfa || !xfaDatasetsRef || hasXfaDatasetsEntry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue