Skip to content

Commit

Permalink
Fix hasEncryption logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharcoux committed Aug 13, 2023
1 parent ae3f351 commit dc6eb8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/PDFContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const byAscendingObjectNumber = (
) => a.objectNumber - b.objectNumber;

class PDFContext {
isDecrypted = false;
isDecrypted = true;
static create = () => new PDFContext();

largestObjectNumber: number;
Expand Down Expand Up @@ -73,7 +73,7 @@ class PDFContext {
}

hasEncryption(): boolean {
return !!this.lookup(this.trailerInfo.Encrypt) || !this.isDecrypted;
return !!this.lookup(this.trailerInfo.Encrypt) && !this.isDecrypted;
}

assign(ref: PDFRef, object: PDFObject): void {
Expand Down
2 changes: 1 addition & 1 deletion src/core/parser/PDFParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PDFParser extends PDFObjectParser {
);
this.objectsPerTick = objectsPerTick;
this.throwOnInvalidObject = throwOnInvalidObject;
this.context.isDecrypted = !!cryptoFactory?.encryptionKey
this.context.isDecrypted = !cryptoFactory || !!cryptoFactory?.encryptionKey
}

async parseDocument(): Promise<PDFContext> {
Expand Down

0 comments on commit dc6eb8b

Please sign in to comment.