UX - Command line arguments for new user
jgranduel opened this issue · comments
Hi,
thanks for this needed application! Here a few remarks (not real issues):
When giving my first trial, I found not having -h|--help
among command line arguments a bit annoying (or -v|--version
).
It would maybe be easier for adoption to give a way to generate a key and certificate? I did it with openssl req -x509 -newkey rsa:4096 -keyout ./key.pem -out ./cert.pem -sha256 -days 365
(found on SOF how-to-generate-a-self-signed-ssl-certificate-using-openssl) or provide any better way.
PowerShell> java -jar ./open-pdf-sign.jar -k ./key.pem -c ./cert.pem -i a.pdf -o b.pdf -p <passphrase> --page -1
French bundle is not present (was expecting to use fr_FR
). How to add a Property file. I found en.properties
and de-AT.properties
in source, but how to add one and how to pass one to the CLI? Maybe as othe CLI arguments as there are juste 4 lines in the bundle?
Could the printed message generated when the bundle is not present or really wrong be more elaborate than the Java stack trace :-) ?
ava.util.MissingResourceException: Can't find bundle for base name strings, locale
at java.base/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586)
at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1549)
at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:932)
at org.openpdfsign.Configuration.<init>(Configuration.java:34)
at org.openpdfsign.Configuration.getInstance(Configuration.java:50)
at org.openpdfsign.CLIApplication.main(CLIApplication.java:40)
Could there be a hint about height of the signature table to help placing it in the right position, some kind of verbose
mode?
The borders of the table (top and bottom) are not always visible. I don't know if it's something you can act upon...
Best Regards and thanks again.
Here is the PR to make the help option more available to the first time user:
#22
Thank you for the issue and PR! I'll look into the Bundle handling, it shouldn't lead to a stacktrace.
For the key generation, I think you're best served with openssl, if you need a self-issued key. You can also buy these files from a certificate authority.
Most of the text in the Resource Bundle is already customizable, but I'll look into that.
For the table border: Can you give an example on when they are not visible? We're using vandeseer/easytable for drawing. If I'm not mistaken the "inner" border lines are a bit stronger (as neighbouring cell lines are duplicated) but also the outer borders should be drawn.
On verbose: I you have an idea on how, I'd welcome it. We're already using slf4j-simple with different levels, but I didn't find a way to set the logging level during runtime unfortunately.
Thanks!
I thought I was confused between CLI arguments and bundles, because of hint
and hint_text
and timestamp
which don't have the exact same meaning:
Bundle contents:
signee=Signee
timestamp=Timestamp
hint=Hint
hint_text=You can check the validity of this certificate at https://www.signaturpruefung.gv.at
Could we pass arguments superseding these keys with the meaning? When we use argument --hint
, it's in fact a hint_text
which is read if I am not wrong. Could the whole table be built from command line arguments (including translation of terms?)? Argument --locale
should load the bundle which 'fr_FR' should load 'fr_FR.properties' file, what do you think?
(Sorry if my comment is redundant with yours, you were writing at the same time as I was !)
Using Coherent PDF or cpdf from time to time, there a few options for placing text onto a pdf:
-top Set position relative to center top of page
-topleft Set position relative to top left of page
-topright Set position relative to top right of page
-left Set position relative to center left of page
-bottomleft Set position relative to bottom left of page
-bottom Set position relative to center bottom of page
-bottomright Set position relative to bottom right of page
-right Set position relative to center right of page
It might be overwhelming but a source of inspiration for placing the signature on the right place! (least surprise principle... for lazy users, you know!)
Thanks!
If I'm not mistaken the "inner" border lines are a bit stronger (as neighbouring cell lines are duplicated)
you are not! after zooming, I can confirm it!
I packaged the code on my laptop. Thanks for -h | --help
. Just one small remark while you are at it:
Usage: <main class> [options]
Options:
-b, --binary
binary output of PDF
Default: false
-c, --certificate
certificate (chain) to be used
--config
use a configuration file
--help, -h
prints this page
Default: false
--hint
text to be displayed in signature field
--host
run as server with the given hostname
--image
Image to be placed in signature block
-i, --input
input pdf file
--help, -h
is written long option first contrary to other options.
Best regards
On PowerShell I am getting this:
PS C:\Users\sul00\Desktop> java -jar ./open-pdf-sign.jar --input suleman.pdf --output output.pdf --certificate cert.cer --key key.key --page -1 --locale de-AT
Exception in thread "main" java.lang.ClassCastException: class org.bouncycastle.pkcs.PKCS10CertificationRequest cannot be cast to class org.bouncycastle.cert.X509CertificateHolder (org.bouncycastle.pkcs.PKCS10CertificationRequest and org.bouncycastle.cert.X509CertificateHolder are in unnamed module of loader 'app')
at org.openpdfsign.KeyStoreLoader.loadKeyStoreFromKeys(KeyStoreLoader.java:50)
at org.openpdfsign.CLIApplication.main(CLIApplication.java:53)
My Java Config:
C:\Users\sul00\Desktop>java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Microsoft-25199 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Microsoft-25199 (build 11.0.12+7, mixed mode)
@Suleman-Elahi please open a separate issue for this bug report
@Suleman-Elahi please open a separate issue for this bug report
It is fixed. I was using this website to generate private keys and certificate: https://www.ssl.com/online-csr-and-key-generator/
But then I used OpenSSL command from the above comment, and it worked.
Playing with the zoom in Acrobat Reader, the signature table can have borders missing (or disappear!) like in picture below. Can't you reproduce it?
Unfortunately, no, I can't reproduce it. I would expect this to be some sort of aliasing-bug in the viewer though. Do the lines reappear if you zoom into the document? The lines are quite thin, maybe it's smaller than one device pixel on some monitors/resolutions.
--help, -h is written long option first contrary to other options
Will be fixed in PR 23, thank you for noticing!
Using Coherent PDF or cpdf from time to time, there a few options for placing text onto a pdf
Thank you for that! PDF positioning can be quite strange (e.g. with rotated/scaled documents). In the initial design decision we opted for a (top, left, width, height)
bounding box with positioning the signature with all positioning being done from the top-left of the page. While it can look "off" in certain formats, this allows for a consistent size of the signature box on different page formats (as e.g. defining (top, left, bottom, right)
would lead to too big/small boxes depending on paper size.
Thank you again for all the feedback! All points should be implemented now in the latest release (v0.1.3
)
- Parameter
--version
allows printing the binary version - Using
--label-hint
,--label-signee
and--label-timestamp
also the row labels can be customized - If a locale is not included in the shipped bundles, open-pdf-sign now fails gracefully instead of throwing a stacktrace
- README is adjusted with all new parameters