aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremusic <emina.music@egiz.gv.at>2018-10-30 12:54:12 +0100
committeremusic <emina.music@egiz.gv.at>2018-10-30 12:54:12 +0100
commit98b7afef9f2179ff3cc9013bb1fdca8b7659e964 (patch)
treedecde71a0faf3a75305c7faf6a750cf49fe240e9
parent8245626bd80a433e459d07ef9b7d1ec64027d304 (diff)
downloadpdf-as-4-98b7afef9f2179ff3cc9013bb1fdca8b7659e964.tar.gz
pdf-as-4-98b7afef9f2179ff3cc9013bb1fdca8b7659e964.tar.bz2
pdf-as-4-98b7afef9f2179ff3cc9013bb1fdca8b7659e964.zip
Positioning of signature block on first page enabled
-rw-r--r--build.gradle2
-rw-r--r--pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java42
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java10
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java2
4 files changed, 22 insertions, 34 deletions
diff --git a/build.gradle b/build.gradle
index 622e296f..9ae665d3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,7 +16,7 @@ task wrapper(type: Wrapper) {
allprojects {
apply plugin: 'com.github.ben-manes.versions'
repositories { mavenCentral() }
- version = '4.1.4'
+ version = '4.1.5-SNAPSHOT'
}
configurations {
diff --git a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java
index 4f22cdc1..cf764d47 100644
--- a/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java
+++ b/pdf-as-cli/src/main/java/at/gv/egiz/pdfas/cli/Main.java
@@ -23,34 +23,12 @@
******************************************************************************/
package at.gv.egiz.pdfas.cli;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.nio.charset.StandardCharsets;
-import java.security.SecureRandom;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.UUID;
-
-import javax.activation.DataSource;
-
-import at.gv.egiz.pdfas.lib.api.*;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
-import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
-
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.utils.StreamUtils;
+import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
+import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.PdfAs;
+import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.pdfas.lib.api.sign.SignResult;
@@ -61,8 +39,18 @@ import at.gv.egiz.pdfas.moa.MOAConnector;
import at.gv.egiz.pdfas.sigs.pades.PAdESSigner;
import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore;
import at.gv.egiz.sl.util.BKUSLConnector;
+import org.apache.commons.cli.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import static at.gv.egiz.pdfas.lib.api.IConfigurationConstants.DEFAULT_CONFIG_PROTECT_PDF;
+import javax.activation.DataSource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.UUID;
public class Main {
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
index 1a51b4db..a147c791 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
@@ -171,22 +171,22 @@ public class Positioning {
page = pos.getPage();
// System.out.println("XXXXPAGE="+page+" doc_pages="+doc_pages);
- if (page > doc_pages && page!=1) {
+ if (page > doc_pages) {
make_new_page = true;
page = doc_pages;
// throw new PDFDocumentException(227, "Page number is to big(="
// + page+
// ") cannot be parsed.");
}
-
- if (page < doc_pages && page!=1) {
+ /*if (page < doc_pages && page!=1) {
page = page - 1;
- }
+ }*/
}
+
+
PDPage pdPage = pdfDataSource.getPage(page-1);
- //PDPage pdPage = pdfDataSource.getPages().get(page);
PDRectangle cropBox = pdPage.getCropBox();
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
index 897218e5..3cb103a7 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
@@ -383,7 +383,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
IOUtils.closeQuietly(colorProfile);
}
}
- options.setPage(positioningInstruction.getPage());
+ options.setPage(positioningInstruction.getPage()-1);
options.setVisualSignature(properties.getVisibleSignature());
}