diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDF.cc | 11 | ||||
-rw-r--r-- | libqpdf/QPDFJob.cc | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 812fb127..583a028c 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -2777,3 +2777,14 @@ QPDF::everPushedInheritedAttributesToPages() const { return this->m->ever_pushed_inherited_attributes_to_pages; } + +void +QPDF::removeSecurityRestrictions() +{ + auto root = getRoot(); + root.removeKey("/Perms"); + auto acroform = root.getKey("/AcroForm"); + if (acroform.isDictionary() && acroform.hasKey("/SigFlags")) { + acroform.replaceKey("/SigFlags", QPDFObjectHandle::newInteger(0)); + } +} diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index c46e1951..6cd3c385 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -2333,6 +2333,9 @@ QPDFJob::handleTransformations(QPDF& pdf) afdh = std::make_shared<QPDFAcroFormDocumentHelper>(pdf); } }; + if (m->remove_restrictions) { + pdf.removeSecurityRestrictions(); + } if (m->externalize_inline_images || (m->optimize_images && (!m->keep_inline_images))) { for (auto& ph: dh.getAllPages()) { |