Skip to content

Commit

Permalink
Merge pull request #3 from Jocomol/master
Browse files Browse the repository at this point in the history
Version 1.2
  • Loading branch information
jmarxuach authored Jul 20, 2020
2 parents 53d409e + a1c799e commit 5e66aee
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 165 deletions.
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

64 changes: 40 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,62 @@ You need a PKCS12 certificate. It should be a <filename>.pfx file.
You need a password for the .pfx
A PDF file to sign.

You can create your own self signed certificate with this following 4 commands in ubuntu. Release includes this certificate with password <12345>.
## self signed certificate creation
You can create your own self signed certificate with this following 4 commands in Ubuntu.

```bash
openssl genrsa -aes128 -out myself.key 2048
```

```bash
openssl req -new -days 365 -key myself.key -out myself.csr
```

```bash
openssl x509 -in myself.csr -out myself.crt -req -signkey myself.key -days 365
openssl pkcs12 -export -out myself.pfx -inkey myself.key -in myself.crt
```

## Signing
Example:
```bash
openssl pkcs12 -export -out myself.pfx -inkey myself.key -in myself.crt
java -jar BatchPDFSign.jar myCertificate.pfx mySecurePassword myPdfFile.pdf outputfile.pdf PDF_A_1A
```
### Synopsis
**java -jar BatchPDFSign.jar** _certificate.pfx_ _password_ _filetosign.pdf_ \[outputfile.pdf] \[PDFAFormat]

Then you can sign a PDF file with following command line.
- **type exactly as shown**
- _replace with appropriate argument_
- \[optional]

```bash
java -jar BatchPDFSign.jar <certificate.pfx> <password> <filetosign.pdf>
```
### certificate
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.

With a specific output file.
```bash
java -jar BatchPDFSign.jar <certificate.pfx> <password> <filetosign.pdf> <outputfile.pdf>
```
### password
This parameter is the password for the certificate. The password is set during the creation of the certificate file.

For the example included in the releases.
### filetosign
The file you want to sign.

```bash
java -jar BatchPDFSign.jar myself.pfx 12345 test.pdf</code>
```
### outputfile
If this parameter is set, a new file with this name will be created and signed. The original file will remain untouched.

With an output file defined.
### PDFAFormat
The PDF/A Format of the file, if this flag is set, the flag "outputfile" also needs to be set.
More information can be found in the chapter PDF/A.

```bash
java -jar BatchPDFSign.jar myself.pfx 12345 test.pdf test-sig.pdf
```
## PDF/A
Following PDF/A formats are supported:
- PDF_A_1A
- PDF_A_1B
- PDF_A_2A
- PDF_A_2B
- PDF_A_2U
- PDF_A_3A
- PDF_A_3B
- PDF_A_3U
- ZUGFeRD
- ZUGFeRDBasic
- ZUGFeRDComfort
- ZUGFeRDExtended

## Development
You'll need:
- Maven
- Java 14 JDK

That's all folks.
40 changes: 35 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,44 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>BatchPDFSign</artifactId>
<groupId>BatchPDFSign</groupId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<dependencies>
<!-- commons.io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<!-- itextpdf.com -->
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-pdfa</artifactId>
<version>${itext.version}</version>
</dependency>
<!-- bouncycastle.org -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -33,7 +53,7 @@
<finalName>BatchPDFSign</finalName>
<archive>
<manifest>
<mainClass>BatchPDFSign.BatchPDFSign</mainClass>
<mainClass>BatchPDFSign.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand All @@ -42,10 +62,20 @@
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
<properties>
<commons-io.version>2.7</commons-io.version>
<itext.version>1.4</itext.version>
<itext.version>5.5.13.1</itext.version>
<bouncycastle.version>1.66</bouncycastle.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
</project>
Loading

0 comments on commit 5e66aee

Please sign in to comment.