Skip to content

Commit

Permalink
Merge pull request #17 from zedif/improve_docs
Browse files Browse the repository at this point in the history
improve documentation of new options
  • Loading branch information
jmarxuach authored Mar 7, 2022
2 parents b153fd9 + 543e83c commit f18b65f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
44 changes: 36 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Command line tool for digital signature of PDF files, useful for example in Batc
BatchPDFSign is a command line to sign PDF file with a PKCS12 certificate.

To use it you need:
- a PKCS12 certificate. It should be a <filename>.pfx file.
- a password for the .pfx
- a PKCS12 certificate. It should be a <filename>.pfx or <filename>.p12 file.
- a password for the certificate
- and a PDF file to sign.

## self signed certificate creation
Expand All @@ -26,12 +26,26 @@ openssl pkcs12 -export -out myself.pfx -inkey myself.key -in myself.crt

## Signing
### Synopsis
required options: i, k, p
usage: BatchPDFSign
-i,--input <arg> input file path
-k,--key <arg> key file path
-o,--output <arg> output file
-p,--password <arg> keyfile password
```
usage: BatchPDFSignPortable
-i,--input <arg> input file path
-k,--key <arg> key file path
-o,--output <arg> output file
-p,--password <arg> keyfile password
--page <arg> page of signature rectangle; needs to be specified
to output signature rectangle
--fs <arg> font size of text in signature rectangle (default:
12); needs --page to be specified as well
--rh <arg> height of signature rectangle; needs --page to be
specified as well
--rw <arg> width of signature rectangle; needs --page to be
specified as well
--rx <arg> x position of signature rectangle; needs --page to
be specified as well
--ry <arg> y position of signature rectangle; needs --page to
be specified as well
--signtext <arg> signature text; needs --page to be specified as
```

### key file path
This parameter is the certificate you want to sign the pdf with. It can be generated with the code documented in the chapter self signed certificate creation.
Expand All @@ -45,6 +59,20 @@ The file you want to sign.
### output file
If this parameter is set, a new file with this name will be created and signed. The original file will remain untouched.

### visible signature
By default, the signature will not be (easily) visible in the final PDF file. If you want to make it easier for users to see, and with that and some GUIs easier to check the signature, you have to specify the location and size of the "signature rectangle". You also have the option to change the font size and to specify your own text.

- --page
this option is required if you want the signature to appear. If you give this option, you will also have to specify --rx, --ry, --rw and --rh.
- --rx and --ry
specify the location of the signature rectangle
- --rw and --rh
specify the width and height of the signature rectangle
- --fs
specify the font size of the text within the signature rectangle; 12 by default
- --signtext
override the standard text provided by the signature-library with your own, provided text

## Development
You'll need:
- Maven
Expand Down
14 changes: 7 additions & 7 deletions portable/src/main/java/BatchPDFSign/portable/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ public static void main(String[] args){
output.setRequired(false);
options.addOption(output);

Option pageOpt = new Option("", "page", true, "page of signature rectangle; needs to be specified to output signature rectangle");
Option pageOpt = new Option(null, "page", true, "page of signature rectangle; needs to be specified to output signature rectangle");
output.setRequired(false);
options.addOption(pageOpt);

Option rectPosXOpt = new Option("", "rx", true, "x position of signature rectangle");
Option rectPosXOpt = new Option(null, "rx", true, "x position of signature rectangle; needs --page to be specified as well");
output.setRequired(false);
options.addOption(rectPosXOpt);

Option rectPosYOpt = new Option("", "ry", true, "y position of signature rectangle");
Option rectPosYOpt = new Option(null, "ry", true, "y position of signature rectangle; needs --page to be specified as well");
output.setRequired(false);
options.addOption(rectPosYOpt);

Option rectWidthOpt = new Option("", "rw", true, "width of signature rectangle");
Option rectWidthOpt = new Option(null, "rw", true, "width of signature rectangle; needs --page to be specified as well");
output.setRequired(false);
options.addOption(rectWidthOpt);

Option rectHeightOpt = new Option("", "rh", true, "height of signature rectangle");
Option rectHeightOpt = new Option(null, "rh", true, "height of signature rectangle; needs --page to be specified as well");
output.setRequired(false);
options.addOption(rectHeightOpt);

Option fontsizeOpt = new Option("", "fs", true, "height of signature rectangle");
Option fontsizeOpt = new Option(null, "fs", true, "font size of text in signature rectangle (default: 12); needs --page to be specified as well");
output.setRequired(false);
options.addOption(fontsizeOpt);

Option signTextOpt = new Option("", "signtext", true, "signature text");
Option signTextOpt = new Option(null, "signtext", true, "signature text; needs --page to be specified as well");
output.setRequired(false);
options.addOption(signTextOpt);

Expand Down

0 comments on commit f18b65f

Please sign in to comment.