summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-06-15 02:40:20 +0200
committerJay Berkenbilt <ejb@ql.org>2013-06-15 02:42:39 +0200
commiteae8370cd9c4e6ac748931a425721303561bd6ac (patch)
treeb6e83bb8bca29b286e9c50fb73f2cb96d7641499 /libqpdf
parenta3576a73593987b26cd3eff346f8f7c11f713cbd (diff)
downloadqpdf-eae8370cd9c4e6ac748931a425721303561bd6ac.tar.zst
Add optional /Length key in crypt filter dictionary
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFWriter.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index dde6e559..8d169f3b 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -726,8 +726,12 @@ QPDFWriter::setEncryptionParametersInternal(
std::string method = (this->encrypt_use_aes
? ((V < 5) ? "/AESV2" : "/AESV3")
: "/V2");
+ // The PDF spec says the /Length key is optional, but the PDF
+ // previewer on some versions of MacOS won't open encrypted
+ // files without it.
encryption_dictionary["/CF"] =
- "<< /StdCF << /AuthEvent /DocOpen /CFM " + method + " >> >>";
+ "<< /StdCF << /AuthEvent /DocOpen /CFM " + method +
+ " /Length " + std::string((V < 5) ? "16" : "32") + " >> >>";
}
this->encrypted = true;