From 03f2f489cec0738d12038e5909dde3fba84f68db Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 24 May 2018 13:02:10 +0200 Subject: [PATCH] pdf: Accept Identity encryption Identity encryption means there is no encryption at all. --- read.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/read.go b/read.go index 32a7c807..f788f0f2 100644 --- a/read.go +++ b/read.go @@ -896,6 +896,9 @@ func (r *Reader) initEncrypt(password string) error { if V != 1 && V != 2 && (V != 4 || !okayV4(encrypt)) { return fmt.Errorf("unsupported PDF: encryption version V=%d; %v", V, objfmt(encrypt)) } + if V == 4 && encrypt["StmF"].(name) == name("Identity") { + return nil // No encryption applied. + } ids, ok := r.trailer["ID"].(array) if !ok || len(ids) < 1 { @@ -1003,6 +1006,9 @@ func okayV4(encrypt dict) bool { if stmf != strf { return false } + if stmf == name("Identity") { + return true // No encryption applied. + } cfparam, ok := cf[stmf].(dict) if cfparam["AuthEvent"] != nil && cfparam["AuthEvent"] != name("DocOpen") { return false