diff --git a/Pdf4QtLib/sources/pdfdocumentbuilder.cpp b/Pdf4QtLib/sources/pdfdocumentbuilder.cpp index ed2141a..78eb7be 100644 --- a/Pdf4QtLib/sources/pdfdocumentbuilder.cpp +++ b/Pdf4QtLib/sources/pdfdocumentbuilder.cpp @@ -1141,6 +1141,11 @@ void PDFDocumentBuilder::copyAnnotation(PDFObjectReference pageReference, PDFObj appendTo(pageReference, pageAnnots); } +void PDFDocumentBuilder::setSecurityHandler(PDFSecurityHandlerPointer handler) +{ + m_storage.setSecurityHandler(qMove(handler)); +} + PDFObjectReference PDFDocumentBuilder::getCatalogReference() const { if (const PDFDictionary* trailerDictionary = getDictionaryFromObject(m_storage.getTrailerDictionary())) @@ -1582,7 +1587,7 @@ PDFContentStreamBuilder::ContentStream PDFContentStreamBuilder::end(QPainter* pa delete m_buffer; m_buffer = nullptr; - PDFDocumentReader reader(nullptr, nullptr, false); + PDFDocumentReader reader(nullptr, nullptr, false, false); result.document = reader.readFromBuffer(bufferData); if (result.document.getCatalog()->getPageCount() > 0) @@ -4288,6 +4293,20 @@ void PDFDocumentBuilder::removeDocumentActions() } +void PDFDocumentBuilder::removeEncryption() +{ + PDFObjectFactory objectBuilder; + + objectBuilder.beginDictionary(); + objectBuilder.beginDictionaryItem("Encrypt"); + objectBuilder << PDFObject(); + objectBuilder.endDictionaryItem(); + objectBuilder.endDictionary(); + PDFObject updatedTrailerDictionary = objectBuilder.takeObject(); + m_storage.updateTrailerDictionary(qMove(updatedTrailerDictionary)); +} + + void PDFDocumentBuilder::removeOutline() { PDFObjectFactory objectBuilder; @@ -4731,14 +4750,6 @@ void PDFDocumentBuilder::setFormFieldValue(PDFObjectReference formField, } -void PDFDocumentBuilder::setLanguage(QLocale locale) -{ - PDFObjectFactory objectBuilder; - - setLanguage(locale.name()); -} - - void PDFDocumentBuilder::setLanguage(QString language) { PDFObjectFactory objectBuilder; @@ -4753,6 +4764,14 @@ void PDFDocumentBuilder::setLanguage(QString language) } +void PDFDocumentBuilder::setLanguage(QLocale locale) +{ + PDFObjectFactory objectBuilder; + + setLanguage(locale.name()); +} + + void PDFDocumentBuilder::setOutline(PDFObjectReference outline) { PDFObjectFactory objectBuilder; @@ -4856,6 +4875,7 @@ void PDFDocumentBuilder::setPageRotation(PDFObjectReference page, mergeTo(page, updatedPageObject); } + void PDFDocumentBuilder::setPageTrimBox(PDFObjectReference page, QRectF box) { diff --git a/Pdf4QtLib/sources/pdfdocumentbuilder.h b/Pdf4QtLib/sources/pdfdocumentbuilder.h index c8e280c..ac49887 100644 --- a/Pdf4QtLib/sources/pdfdocumentbuilder.h +++ b/Pdf4QtLib/sources/pdfdocumentbuilder.h @@ -421,6 +421,11 @@ public: /// \param annotationReference Annotation reference void copyAnnotation(PDFObjectReference pageReference, PDFObjectReference annotationReference); + /// Sets security handler to the object storage. Trailer dictionary is not + /// updated and so must be updated manually. + /// \param handler New security handler + void setSecurityHandler(PDFSecurityHandlerPointer handler); + /* START GENERATED CODE */ /// Appends a new page after last page. @@ -1185,6 +1190,10 @@ public: void removeDocumentActions(); + /// Removes encryption from a document. + void removeEncryption(); + + /// Removes outline tree from document catalog. void removeOutline(); @@ -1371,11 +1380,6 @@ public: PDFObject value); - /// Set document language. - /// \param locale Locale, from which is language determined - void setLanguage(QLocale locale); - - /// Set document language. /// \param language Document language. It should be a language identifier, as defined in ISO 639 /// and ISO 3166. For example, "en-US", where first two letter means language code (en = @@ -1383,6 +1387,11 @@ public: void setLanguage(QString language); + /// Set document language. + /// \param locale Locale, from which is language determined + void setLanguage(QLocale locale); + + /// Set document outline. /// \param outline Document outline root void setOutline(PDFObjectReference outline); diff --git a/Pdf4QtLib/sources/pdfdocumentreader.cpp b/Pdf4QtLib/sources/pdfdocumentreader.cpp index 9aef08c..bea90b5 100644 --- a/Pdf4QtLib/sources/pdfdocumentreader.cpp +++ b/Pdf4QtLib/sources/pdfdocumentreader.cpp @@ -34,11 +34,12 @@ namespace pdf { -PDFDocumentReader::PDFDocumentReader(PDFProgress* progress, const std::function& getPasswordCallback, bool permissive) : +PDFDocumentReader::PDFDocumentReader(PDFProgress* progress, const std::function& getPasswordCallback, bool permissive, bool authorizeOwnerOnly) : m_result(Result::OK), m_getPasswordCallback(getPasswordCallback), m_progress(progress), - m_permissive(permissive) + m_permissive(permissive), + m_authorizeOwnerOnly(authorizeOwnerOnly) { } @@ -375,7 +376,7 @@ PDFDocumentReader::Result PDFDocumentReader::processSecurityHandler(const PDFObj // Read the security handler m_securityHandler = PDFSecurityHandler::createSecurityHandler(encryptObject, id); - PDFSecurityHandler::AuthorizationResult authorizationResult = m_securityHandler->authenticate(m_getPasswordCallback); + PDFSecurityHandler::AuthorizationResult authorizationResult = m_securityHandler->authenticate(m_getPasswordCallback, m_authorizeOwnerOnly); if (authorizationResult == PDFSecurityHandler::AuthorizationResult::Cancelled) { diff --git a/Pdf4QtLib/sources/pdfdocumentreader.h b/Pdf4QtLib/sources/pdfdocumentreader.h index 248c967..3634aac 100644 --- a/Pdf4QtLib/sources/pdfdocumentreader.h +++ b/Pdf4QtLib/sources/pdfdocumentreader.h @@ -40,7 +40,7 @@ class Pdf4QtLIBSHARED_EXPORT PDFDocumentReader Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocumentReader) public: - explicit PDFDocumentReader(PDFProgress* progress, const std::function& getPasswordCallback, bool permissive); + explicit PDFDocumentReader(PDFProgress* progress, const std::function& getPasswordCallback, bool permissive, bool authorizeOwnerOnly); constexpr inline PDFDocumentReader(const PDFDocumentReader&) = delete; constexpr inline PDFDocumentReader(PDFDocumentReader&&) = delete; @@ -166,6 +166,10 @@ private: /// Be permissive when reading, tolerate errors and try to fix broken document bool m_permissive; + /// Authorize as owner only (if owner authorization fails, then whole document + /// reading fails) + bool m_authorizeOwnerOnly; + /// Warnings QStringList m_warnings; }; diff --git a/Pdf4QtLib/sources/pdfsecurityhandler.cpp b/Pdf4QtLib/sources/pdfsecurityhandler.cpp index 73234a4..f95c08e 100644 --- a/Pdf4QtLib/sources/pdfsecurityhandler.cpp +++ b/Pdf4QtLib/sources/pdfsecurityhandler.cpp @@ -369,7 +369,7 @@ PDFSecurityHandlerPointer PDFSecurityHandler::createSecurityHandler(const PDFObj if (it == handler.m_cryptFilters.cend()) { - throw PDFException(PDFTranslationContext::tr("Uknown crypt filter '%1'.").arg(QString::fromLatin1(name))); + throw PDFException(PDFTranslationContext::tr("Unknown crypt filter '%1'.").arg(QString::fromLatin1(name))); } return it->second; @@ -446,7 +446,7 @@ PDFSecurityHandlerPointer PDFSecurityHandler::createSecurityHandler(const PDFObj return PDFSecurityHandlerPointer(new PDFStandardSecurityHandler(qMove(handler))); } -PDFSecurityHandler::AuthorizationResult PDFStandardSecurityHandler::authenticate(const std::function& getPasswordCallback) +PDFSecurityHandler::AuthorizationResult PDFStandardSecurityHandler::authenticate(const std::function& getPasswordCallback, bool authorizeOwnerOnly) { QByteArray password; bool passwordObtained = true; @@ -478,15 +478,18 @@ PDFSecurityHandler::AuthorizationResult PDFStandardSecurityHandler::authenticate } // Try to authorize user password - QByteArray fileEncryptionKey = createFileEncryptionKey(password); - QByteArray U = createEntryValueU_r234(fileEncryptionKey); - - if (U == m_U) + if (!authorizeOwnerOnly) { - // We have authorized owner access - m_authorizationData.authorizationResult = AuthorizationResult::UserAuthorized; - m_authorizationData.fileEncryptionKey = fileEncryptionKey; - return AuthorizationResult::UserAuthorized; + QByteArray fileEncryptionKey = createFileEncryptionKey(password); + QByteArray U = createEntryValueU_r234(fileEncryptionKey); + + if (U == m_U) + { + // We have authorized user access + m_authorizationData.authorizationResult = AuthorizationResult::UserAuthorized; + m_authorizationData.fileEncryptionKey = fileEncryptionKey; + return AuthorizationResult::UserAuthorized; + } } break; @@ -534,7 +537,7 @@ PDFSecurityHandler::AuthorizationResult PDFStandardSecurityHandler::authenticate } // Try to authorize user password - if (!m_authorizationData.isAuthorized()) + if (!m_authorizationData.isAuthorized() && !authorizeOwnerOnly) { QByteArray inputData = password + userData.validationSalt; QByteArray hash = createHash_r56(inputData, password, false); @@ -925,7 +928,7 @@ QByteArray PDFStandardSecurityHandler::createUserPasswordFromOwnerPassword(const const int keyByteLength = m_keyLength / 8; if (keyByteLength > MD5_DIGEST_LENGTH) { - throw PDFException(PDFTranslationContext::tr("Encryption key length (%1) exceeded maximal value of.").arg(keyByteLength).arg(MD5_DIGEST_LENGTH)); + throw PDFException(PDFTranslationContext::tr("Encryption key length (%1) exceeded maximal value of %2.").arg(keyByteLength).arg(MD5_DIGEST_LENGTH)); } if (m_R >= 3) diff --git a/Pdf4QtLib/sources/pdfsecurityhandler.h b/Pdf4QtLib/sources/pdfsecurityhandler.h index 5afeaca..e126573 100644 --- a/Pdf4QtLib/sources/pdfsecurityhandler.h +++ b/Pdf4QtLib/sources/pdfsecurityhandler.h @@ -116,8 +116,9 @@ public: /// to cancel the authentication (and \p Cancelled authentication result is returned) or true, /// to try provided password. /// \param getPasswordCallback Callback to get user password + /// \param authorizeOwnerOnly Authorize owner only /// \returns Result of authentication - virtual AuthorizationResult authenticate(const std::function& getPasswordCallback) = 0; + virtual AuthorizationResult authenticate(const std::function& getPasswordCallback, bool authorizeOwnerOnly) = 0; /// Decrypts the PDF object. This function works properly only (and only if) /// \p authenticate function returns user/owner authorization code. @@ -188,7 +189,7 @@ class PDFNoneSecurityHandler : public PDFSecurityHandler { public: virtual EncryptionMode getMode() const override { return EncryptionMode::None; } - virtual AuthorizationResult authenticate(const std::function&) override { return AuthorizationResult::OwnerAuthorized; } + virtual AuthorizationResult authenticate(const std::function&, bool) override { return AuthorizationResult::OwnerAuthorized; } virtual QByteArray decrypt(const QByteArray& data, PDFObjectReference, EncryptionScope) const override { return data; } virtual QByteArray decryptByFilter(const QByteArray& data, const QByteArray&, PDFObjectReference) const override { return data; } virtual bool isMetadataEncrypted() const override { return true; } @@ -202,7 +203,7 @@ class PDFStandardSecurityHandler : public PDFSecurityHandler { public: virtual EncryptionMode getMode() const override { return EncryptionMode::Standard; } - virtual AuthorizationResult authenticate(const std::function& getPasswordCallback) override; + virtual AuthorizationResult authenticate(const std::function& getPasswordCallback, bool authorizeOwnerOnly) override; virtual QByteArray decrypt(const QByteArray& data, PDFObjectReference reference, EncryptionScope encryptionScope) const override; virtual QByteArray decryptByFilter(const QByteArray& data, const QByteArray& filterName, PDFObjectReference reference) const override; virtual bool isMetadataEncrypted() const override { return m_encryptMetadata; } diff --git a/Pdf4QtViewer/pdfprogramcontroller.cpp b/Pdf4QtViewer/pdfprogramcontroller.cpp index 6c4a5ed..5274bd3 100644 --- a/Pdf4QtViewer/pdfprogramcontroller.cpp +++ b/Pdf4QtViewer/pdfprogramcontroller.cpp @@ -1416,7 +1416,7 @@ void PDFProgramController::openDocument(const QString& fileName) }; // Try to open a new document - pdf::PDFDocumentReader reader(m_progress, qMove(queryPassword), true); + pdf::PDFDocumentReader reader(m_progress, qMove(queryPassword), true, false); pdf::PDFDocument document = reader.readFromFile(fileName); result.errorMessage = reader.getErrorMessage(); diff --git a/PdfTool/PdfTool.pro b/PdfTool/PdfTool.pro index 5eb90e4..2529fa2 100644 --- a/PdfTool/PdfTool.pro +++ b/PdfTool/PdfTool.pro @@ -46,6 +46,7 @@ SOURCES += \ pdftoolaudiobook.cpp \ pdftoolcertstore.cpp \ pdftoolcolorprofiles.cpp \ + pdftooldecrypt.cpp \ pdftoolfetchimages.cpp \ pdftoolfetchtext.cpp \ pdftoolinfo.cpp \ @@ -78,6 +79,7 @@ HEADERS += \ pdftoolaudiobook.h \ pdftoolcertstore.h \ pdftoolcolorprofiles.h \ + pdftooldecrypt.h \ pdftoolfetchimages.h \ pdftoolfetchtext.h \ pdftoolinfo.h \ diff --git a/PdfTool/pdftoolabstractapplication.cpp b/PdfTool/pdftoolabstractapplication.cpp index 242bedd..ceecae3 100644 --- a/PdfTool/pdftoolabstractapplication.cpp +++ b/PdfTool/pdftoolabstractapplication.cpp @@ -899,7 +899,7 @@ PDFToolOptions PDFToolAbstractApplication::getOptions(QCommandLineParser* parser return options; } -bool PDFToolAbstractApplication::readDocument(const PDFToolOptions& options, pdf::PDFDocument& document, QByteArray* sourceData) +bool PDFToolAbstractApplication::readDocument(const PDFToolOptions& options, pdf::PDFDocument& document, QByteArray* sourceData, bool authorizeOwnerOnly) { bool isFirstPasswordAttempt = true; auto passwordCallback = [&options, &isFirstPasswordAttempt](bool* ok) -> QString @@ -908,7 +908,7 @@ bool PDFToolAbstractApplication::readDocument(const PDFToolOptions& options, pdf isFirstPasswordAttempt = false; return options.password; }; - pdf::PDFDocumentReader reader(nullptr, passwordCallback, options.permissiveReading); + pdf::PDFDocumentReader reader(nullptr, passwordCallback, options.permissiveReading, authorizeOwnerOnly); document = reader.readFromFile(options.document); switch (reader.getReadingResult()) diff --git a/PdfTool/pdftoolabstractapplication.h b/PdfTool/pdftoolabstractapplication.h index 5c0129a..bfeef63 100644 --- a/PdfTool/pdftoolabstractapplication.h +++ b/PdfTool/pdftoolabstractapplication.h @@ -187,6 +187,7 @@ public: ErrorUnknown, ErrorNoDocumentSpecified, ErrorDocumentReading, + ErrorDocumentWriting, ErrorCertificateReading, ErrorInvalidArguments, ErrorFailedWriteToFile, @@ -245,7 +246,8 @@ protected: /// \param options Options /// \param document Document /// \param[out] sourceData Pointer, to which source data are stored - bool readDocument(const PDFToolOptions& options, pdf::PDFDocument& document, QByteArray* sourceData = nullptr); + /// \param authorizeOwnerOnly Require to authorize as owner + bool readDocument(const PDFToolOptions& options, pdf::PDFDocument& document, QByteArray* sourceData, bool authorizeOwnerOnly); }; /// This class stores information about all applications available. Application diff --git a/PdfTool/pdftoolattachments.cpp b/PdfTool/pdftoolattachments.cpp index 05b5adf..ec4cf68 100644 --- a/PdfTool/pdftoolattachments.cpp +++ b/PdfTool/pdftoolattachments.cpp @@ -47,7 +47,7 @@ QString PDFToolAttachmentsApplication::getStandardString(StandardString standard int PDFToolAttachmentsApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; - if (!readDocument(options, document)) + if (!readDocument(options, document, nullptr, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolaudiobook.cpp b/PdfTool/pdftoolaudiobook.cpp index cca5096..7bc1ba2 100644 --- a/PdfTool/pdftoolaudiobook.cpp +++ b/PdfTool/pdftoolaudiobook.cpp @@ -332,7 +332,7 @@ int PDFToolAudioBook::getDocumentTextFlow(const PDFToolOptions& options, pdf::PD { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftooldecrypt.cpp b/PdfTool/pdftooldecrypt.cpp new file mode 100644 index 0000000..89cf0c3 --- /dev/null +++ b/PdfTool/pdftooldecrypt.cpp @@ -0,0 +1,89 @@ +// Copyright (C) 2021 Jakub Melka +// +// This file is part of Pdf4Qt. +// +// Pdf4Qt is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// Pdf4Qt is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Pdf4Qt. If not, see . + +#include "pdftooldecrypt.h" +#include "pdfdocumentbuilder.h" +#include "pdfdocumentwriter.h" + +namespace pdftool +{ + +static PDFToolDecryptApplication s_decryptApplication; + +QString PDFToolDecryptApplication::getStandardString(StandardString standardString) const +{ + switch (standardString) + { + case Command: + return "decrypt"; + + case Name: + return PDFToolTranslationContext::tr("Decrypt"); + + case Description: + return PDFToolTranslationContext::tr("Remove encryption from a document (with only owner access only)."); + + default: + Q_ASSERT(false); + break; + } + + return QString(); +} + +int PDFToolDecryptApplication::execute(const PDFToolOptions& options) +{ + pdf::PDFDocument document; + QByteArray sourceData; + if (!readDocument(options, document, &sourceData, true)) + { + if (readDocument(options, document, &sourceData, false)) + { + PDFConsole::writeError(PDFToolTranslationContext::tr("Authorization as owner failed. Encryption removal is not permitted if authorized as user only."), options.outputCodec); + } + return ErrorDocumentReading; + } + + if (document.getStorage().getSecurityHandler()->getMode() == pdf::EncryptionMode::None) + { + PDFConsole::writeError(PDFToolTranslationContext::tr("Document is not encrypted."), options.outputCodec); + return ExitSuccess; + } + + pdf::PDFDocumentBuilder builder(&document); + builder.removeEncryption(); + builder.setSecurityHandler(pdf::PDFSecurityHandlerPointer(new pdf::PDFNoneSecurityHandler())); + document = builder.build(); + + pdf::PDFDocumentWriter writer(nullptr); + pdf::PDFOperationResult result = writer.write(options.document, &document, true); + + if (!result) + { + PDFConsole::writeError(result.getErrorMessage(), options.outputCodec); + return ErrorDocumentWriting; + } + + return ExitSuccess; +} + +PDFToolAbstractApplication::Options PDFToolDecryptApplication::getOptionsFlags() const +{ + return ConsoleFormat | OpenDocument; +} + +} // namespace pdftool diff --git a/PdfTool/pdftooldecrypt.h b/PdfTool/pdftooldecrypt.h new file mode 100644 index 0000000..c31b9b9 --- /dev/null +++ b/PdfTool/pdftooldecrypt.h @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Jakub Melka +// +// This file is part of Pdf4Qt. +// +// Pdf4Qt is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// with the written consent of the copyright owner, any later version. +// +// Pdf4Qt is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Pdf4Qt. If not, see . + +#ifndef PDFTOOLDECRYPT_H +#define PDFTOOLDECRYPT_H + +#include "pdftoolabstractapplication.h" + +namespace pdftool +{ + +class PDFToolDecryptApplication : public PDFToolAbstractApplication +{ +public: + virtual QString getStandardString(StandardString standardString) const override; + virtual int execute(const PDFToolOptions& options) override; + virtual Options getOptionsFlags() const override; +}; + +} // namespace pdftool + +#endif // PDFTOOLDECRYPT_H diff --git a/PdfTool/pdftoolfetchimages.cpp b/PdfTool/pdftoolfetchimages.cpp index e209992..8ec6f2b 100644 --- a/PdfTool/pdftoolfetchimages.cpp +++ b/PdfTool/pdftoolfetchimages.cpp @@ -120,7 +120,7 @@ int PDFToolFetchImages::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolfetchtext.cpp b/PdfTool/pdftoolfetchtext.cpp index 59076cf..07dfd5c 100644 --- a/PdfTool/pdftoolfetchtext.cpp +++ b/PdfTool/pdftoolfetchtext.cpp @@ -48,7 +48,7 @@ int PDFToolFetchTextApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfo.cpp b/PdfTool/pdftoolinfo.cpp index a85db41..60ae3c4 100644 --- a/PdfTool/pdftoolinfo.cpp +++ b/PdfTool/pdftoolinfo.cpp @@ -52,7 +52,7 @@ int PDFToolInfoApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfofonts.cpp b/PdfTool/pdftoolinfofonts.cpp index b5c8f22..c9eba99 100644 --- a/PdfTool/pdftoolinfofonts.cpp +++ b/PdfTool/pdftoolinfofonts.cpp @@ -66,7 +66,7 @@ int PDFToolInfoFonts::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfojavascript.cpp b/PdfTool/pdftoolinfojavascript.cpp index 3c784b9..d6aa098 100644 --- a/PdfTool/pdftoolinfojavascript.cpp +++ b/PdfTool/pdftoolinfojavascript.cpp @@ -48,7 +48,7 @@ int PDFToolInfoJavaScriptApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfometadata.cpp b/PdfTool/pdftoolinfometadata.cpp index b374889..4d99980 100644 --- a/PdfTool/pdftoolinfometadata.cpp +++ b/PdfTool/pdftoolinfometadata.cpp @@ -48,7 +48,7 @@ int PDFToolInfoMetadataApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfonameddestinations.cpp b/PdfTool/pdftoolinfonameddestinations.cpp index 0317bb0..3da0353 100644 --- a/PdfTool/pdftoolinfonameddestinations.cpp +++ b/PdfTool/pdftoolinfonameddestinations.cpp @@ -48,7 +48,7 @@ int PDFToolInfoNamedDestinationsApplication::execute(const PDFToolOptions& optio { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfopageboxes.cpp b/PdfTool/pdftoolinfopageboxes.cpp index b358ad0..785c11b 100644 --- a/PdfTool/pdftoolinfopageboxes.cpp +++ b/PdfTool/pdftoolinfopageboxes.cpp @@ -67,7 +67,7 @@ int PDFToolInfoPageBoxesApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolinfostructuretree.cpp b/PdfTool/pdftoolinfostructuretree.cpp index a9abf4e..dd22145 100644 --- a/PdfTool/pdftoolinfostructuretree.cpp +++ b/PdfTool/pdftoolinfostructuretree.cpp @@ -266,7 +266,7 @@ int PDFToolInfoStructureTreeApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftooloptimize.cpp b/PdfTool/pdftooloptimize.cpp index d2b9a69..288a44b 100644 --- a/PdfTool/pdftooloptimize.cpp +++ b/PdfTool/pdftooloptimize.cpp @@ -55,7 +55,7 @@ int PDFToolOptimize::execute(const PDFToolOptions& options) pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolrender.cpp b/PdfTool/pdftoolrender.cpp index a964948..43503bb 100644 --- a/PdfTool/pdftoolrender.cpp +++ b/PdfTool/pdftoolrender.cpp @@ -147,7 +147,7 @@ int PDFToolRenderBase::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolseparate.cpp b/PdfTool/pdftoolseparate.cpp index b47e49e..b37002f 100644 --- a/PdfTool/pdftoolseparate.cpp +++ b/PdfTool/pdftoolseparate.cpp @@ -51,7 +51,7 @@ int PDFToolSeparate::execute(const PDFToolOptions& options) { pdf::PDFDocument document; QByteArray sourceData; - if (!readDocument(options, document, &sourceData)) + if (!readDocument(options, document, &sourceData, false)) { return ErrorDocumentReading; } diff --git a/PdfTool/pdftoolunite.cpp b/PdfTool/pdftoolunite.cpp index dabb38f..17aa5a4 100644 --- a/PdfTool/pdftoolunite.cpp +++ b/PdfTool/pdftoolunite.cpp @@ -79,7 +79,7 @@ int PDFToolUnite::execute(const PDFToolOptions& options) std::vector pages; for (const QString& fileName : files) { - pdf::PDFDocumentReader reader(nullptr, [](bool* ok) { *ok = false; return QString(); }, options.permissiveReading); + pdf::PDFDocumentReader reader(nullptr, [](bool* ok) { *ok = false; return QString(); }, options.permissiveReading, false); pdf::PDFDocument document = reader.readFromFile(fileName); if (reader.getReadingResult() != pdf::PDFDocumentReader::Result::OK) { diff --git a/PdfTool/pdftoolverifysignatures.cpp b/PdfTool/pdftoolverifysignatures.cpp index 77cf633..2f4603f 100644 --- a/PdfTool/pdftoolverifysignatures.cpp +++ b/PdfTool/pdftoolverifysignatures.cpp @@ -63,7 +63,7 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options) isFirstPasswordAttempt = false; return options.password; }; - pdf::PDFDocumentReader reader(nullptr, passwordCallback, options.permissiveReading); + pdf::PDFDocumentReader reader(nullptr, passwordCallback, options.permissiveReading, false); pdf::PDFDocument document = reader.readFromFile(options.document); switch (reader.getReadingResult()) diff --git a/PdfTool/pdftoolxml.cpp b/PdfTool/pdftoolxml.cpp index 89c1d09..e9488dc 100644 --- a/PdfTool/pdftoolxml.cpp +++ b/PdfTool/pdftoolxml.cpp @@ -196,7 +196,7 @@ QString PDFToolXmlApplication::getStandardString(StandardString standardString) int PDFToolXmlApplication::execute(const PDFToolOptions& options) { pdf::PDFDocument document; - if (!readDocument(options, document)) + if (!readDocument(options, document, nullptr, false)) { return ErrorDocumentReading; } diff --git a/generated_code_definition.xml b/generated_code_definition.xml index 99dd492..ce02031 100644 --- a/generated_code_definition.xml +++ b/generated_code_definition.xml @@ -8932,6 +8932,47 @@ return rootNodeReference; Removes document actions from document catalog. _void + + + + + + + + + + + + + Encrypt + DictionaryItemSimple + PDFObject() + + + + Dictionary + + + + CreateObject + updatedTrailerDictionary + _PDFObject + + + + + + Code + + _void + m_storage.updateTrailerDictionary(qMove(updatedTrailerDictionary)); + + + Structure + removeEncryption + Removes encryption from a document. + _void + @@ -10722,39 +10763,6 @@ return rootNodeReference; Sets form field value. Value must be correct for this form field, no checking is performed. Also, if you use this function, annotation widgets, which are attached to this form field, should also be updated (for example, appearance state and sometimes appearance streams). _void - - - - - - - - - - locale - _QLocale - Locale, from which is language determined - - - Parameters - - _void - - - - - - Code - - _void - setLanguage(locale.name()); - - - Structure - setLanguage - Set document language. - _void - @@ -10812,6 +10820,39 @@ return rootNodeReference; Set document language. _void + + + + + + + + + + locale + _QLocale + Locale, from which is language determined + + + Parameters + + _void + + + + + + Code + + _void + setLanguage(locale.name()); + + + Structure + setLanguage + Set document language. + _void +