From 06b818dcd39b5aeaeeee5c247483633a02a0222e Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Fri, 27 Sep 2019 21:00:30 +0900 Subject: Exclude signature dictionary from compressible objects It seems better not to compress signature dictionaries. Various PDF digital signing tools, including Adobe Acrobat Reader DC, do not compress signature dictionaries. Table 8.93 "Entries in a signature dictionary" in PDF 1.5 reference describes that /ByteRange in the signature dictionary shall be used to describe a digest that does not include the signature value (/Contents) itself. The byte ranges cannot be determined if the dictionary is compressed. --- libqpdf/QPDF.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index c546fbe1..6c0c700a 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -2673,7 +2673,13 @@ QPDF::getCompressibleObjGens() { QTC::TC("qpdf", "QPDF exclude encryption dictionary"); } - else if (! obj.isStream()) + else if ((! obj.isStream()) && + (! (obj.isDictionary() && + obj.hasKey("/ByteRange") && + obj.hasKey("/Contents") && + obj.hasKey("/Type") && + obj.getKey("/Type").isName() && + obj.getKey("/Type").getName() == "/Sig"))) { result.push_back(og); } -- cgit v1.2.3-54-g00ecf