Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QPrinter: write password protected pdf



  • Hi all.

    It's posible to write password protected pdf file using QPrinter?
    I can't find anything about that in documentation.
    Thanks in advance.
    Regards.



  • It is not documented because it is not possible with Qt (neither user nor owner password). You could post-process the file to encrypt it (user password) with reference to the relevant "PDF specification":http://www.adobe.com/devnet/pdf/pdf_reference.html or use a third-party library to generate the PDF in the first place.



  • Thanks ChrisW67.
    I saw some third-party library, but it's not possible encrypt an existing file. It's necessary rewrite all pdf code.
    Thanks again.



  • Yes, you would need to parse the PDF file, encrypt the string objects and content streams using the weak RC4 scheme or AES (or another option) and rewrite the file with the necessary extra dictionary entries describing the encryption/document permissions.


Log in to reply