Use object destructuring a bit more in the src/core/document.js file

This commit is contained in:
Jonas Jenwald 2025-05-07 13:41:50 +02:00
parent 92b065c87e
commit 36fafbc05c

View File

@ -1363,7 +1363,7 @@ class PDFDocument {
hasXfa: false, hasXfa: false,
hasSignatures: false, hasSignatures: false,
}; };
const acroForm = this.catalog.acroForm; const { acroForm } = this.catalog;
if (!acroForm) { if (!acroForm) {
return shadow(this, "formInfo", formInfo); return shadow(this, "formInfo", formInfo);
} }
@ -1403,22 +1403,22 @@ class PDFDocument {
} }
get documentInfo() { get documentInfo() {
const { catalog, formInfo, xref } = this;
const docInfo = { const docInfo = {
PDFFormatVersion: this.version, PDFFormatVersion: this.version,
Language: this.catalog.lang, Language: catalog.lang,
EncryptFilterName: this.xref.encrypt EncryptFilterName: xref.encrypt?.filterName ?? null,
? this.xref.encrypt.filterName
: null,
IsLinearized: !!this.linearization, IsLinearized: !!this.linearization,
IsAcroFormPresent: this.formInfo.hasAcroForm, IsAcroFormPresent: formInfo.hasAcroForm,
IsXFAPresent: this.formInfo.hasXfa, IsXFAPresent: formInfo.hasXfa,
IsCollectionPresent: !!this.catalog.collection, IsCollectionPresent: !!catalog.collection,
IsSignaturesPresent: this.formInfo.hasSignatures, IsSignaturesPresent: formInfo.hasSignatures,
}; };
let infoDict; let infoDict;
try { try {
infoDict = this.xref.trailer.get("Info"); infoDict = xref.trailer.get("Info");
} catch (err) { } catch (err) {
if (err instanceof MissingDataException) { if (err instanceof MissingDataException) {
throw err; throw err;