Simplify writeObject function

It'll avoid to have the duplication of the code to get the encrypt transform,
and last but not least, it'll avoid to forget about encryption.
This commit is contained in:
Calixte Denizet 2023-09-08 19:29:29 +02:00
parent b903b3030a
commit 52cc1220e4
3 changed files with 24 additions and 98 deletions

View file

@ -321,16 +321,7 @@ class Page {
const savedDict = pageDict.get("Annots");
pageDict.set("Annots", annotationsArray);
const buffer = [];
let transform = null;
if (this.xref.encrypt) {
transform = this.xref.encrypt.createCipherTransform(
this.ref.num,
this.ref.gen
);
}
await writeObject(this.ref, pageDict, buffer, transform);
await writeObject(this.ref, pageDict, buffer, this.xref);
if (savedDict) {
pageDict.set("Annots", savedDict);
}