Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/docs/tools/mutool-sign.rst @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 mutool sign | |
| 2 =========== | |
| 3 | |
| 4 The ``sign`` command reads an input PDF file and by default prints information | |
| 5 about each signature field object. The command applies to the signature field | |
| 6 objects given, or every signature field if none are specified. Given suitable | |
| 7 option signature fields can be verified, cleared or signed using a given | |
| 8 certificate and certificate password. | |
| 9 | |
| 10 .. code-block:: bash | |
| 11 | |
| 12 mutool sign [options] input.pdf [signature object numbers] | |
| 13 | |
| 14 ``[options]`` | |
| 15 Options are as follows: | |
| 16 | |
| 17 ``-p`` password | |
| 18 Use the specified password if the file is encrypted. | |
| 19 | |
| 20 ``-v`` | |
| 21 Verify each signature field and check whether the document has changed since signing. | |
| 22 | |
| 23 ``-c`` | |
| 24 Revert each signed signature field back to its unsigned state. | |
| 25 | |
| 26 ``-s`` certificate file | |
| 27 Sign each signature field with the certificate in the given file. | |
| 28 | |
| 29 ``-P`` certificate password | |
| 30 The password used together with the certificate to sign a signature field. | |
| 31 | |
| 32 ``-o`` filename | |
| 33 Output PDF file name. | |
| 34 | |
| 35 ``input.pdf`` | |
| 36 The input PDF document. | |
| 37 | |
| 38 ``[signature object numbers]`` | |
| 39 Can be used to specify a particular set of signature field objects to apply the ``sign`` command to. | |
| 40 | |
| 41 Signing | |
| 42 ------------------------- | |
| 43 | |
| 44 Signing digital signatures in MuPDF requires that you have a PFX certificate. | |
| 45 You can create a self-signed certificate using OpenSSL by following these | |
| 46 steps: | |
| 47 | |
| 48 1) Generate a self-signed certificate and private key: | |
| 49 | |
| 50 .. code-block:: bash | |
| 51 | |
| 52 openssl req -x509 -days 365 -newkey rsa:2048 -keyout cert.pem -out cert.pem | |
| 53 | |
| 54 2) Convert to PFX format: | |
| 55 | |
| 56 .. code-block:: bash | |
| 57 | |
| 58 openssl pkcs12 -export -in cert.pem -out cert.pfx | |
| 59 | |
| 60 Examples | |
| 61 -------- | |
| 62 | |
| 63 The following command should show all signature fields in the PDF whether signed or unsigned: | |
| 64 | |
| 65 .. code-block:: bash | |
| 66 | |
| 67 mutool sign -v unsigned.pdf | |
| 68 | |
| 69 Once you know the object number of an unsigned signature field, then do the following: | |
| 70 | |
| 71 .. code-block:: bash | |
| 72 | |
| 73 mutool sign -s certificate.pfx -P password123 -o signed.pdf unsigned.pdf 4242 | |
| 74 | |
| 75 This assumes that object ``4242 0 R`` is the signature field. Re-running ``sign -v`` on ``signed.pdf`` should then show that the signature was signed. | |
| 76 | |
| 77 To clear a signature use the ``-c`` option: | |
| 78 | |
| 79 .. code-block:: bash | |
| 80 | |
| 81 mutool sign -c -o unsigned.pdf signed.pdf 4242 |
