Don't replace Acroform dictionary if nothing has changed when saving (bug 1844572)
This commit is contained in:
parent
1a69b6ad64
commit
33fdec1392
@ -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) {
|
||||
|
2
test/pdfs/bug1844572.pdf.link
Normal file
2
test/pdfs/bug1844572.pdf.link
Normal file
@ -0,0 +1,2 @@
|
||||
https://bugzilla.mozilla.org/attachment.cgi?id=9344818
|
||||
|
@ -8008,5 +8008,28 @@
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bug1844572-save-print",
|
||||
"file": "pdfs/bug1844572.pdf",
|
||||
"md5": "22a96775e884131d59c05fa92e0a42f6",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"link": true,
|
||||
"save": true,
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"pdfjs_internal_editor_0": {
|
||||
"annotationType": 3,
|
||||
"color": [0, 0, 0],
|
||||
"fontSize": 10,
|
||||
"value": "Hello World",
|
||||
"pageIndex": 0,
|
||||
"rect": [
|
||||
115.80000000000001, 325.0679969482421, 171.3, 342.5679999999999
|
||||
],
|
||||
"rotation": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user