aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2026-06-22 16:08:26 +0200
committerJakob Heher <jakob.heher@iaik.tugraz.at>2026-06-22 16:08:26 +0200
commitb791a9140fae5a07fd2c9f24c7f44803b472ed77 (patch)
tree60835cc074f800a4ee725462fa7af2afe1abbdae
parent2f209e01da276e9862d6e0f63d02bcfb14728d9b (diff)
downloadpdf-as-4-b791a9140fae5a07fd2c9f24c7f44803b472ed77.tar.gz
pdf-as-4-b791a9140fae5a07fd2c9f24c7f44803b472ed77.tar.bz2
pdf-as-4-b791a9140fae5a07fd2c9f24c7f44803b472ed77.zip
remove pdfbox 2 module
-rw-r--r--.github/workflows/release.yml4
-rw-r--r--.gitignore2
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-3.properties (renamed from pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-2.properties)44
-rw-r--r--pdf-as-lib/src/main/resources/placeholder/pdfbox-reader.properties23
-rw-r--r--pdf-as-pdfbox-2/.gitignore1
-rw-r--r--pdf-as-pdfbox-2/build.gradle56
-rw-r--r--pdf-as-pdfbox-2/licenses/jai-imageio-core.txt39
-rw-r--r--pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.info.txt28
-rw-r--r--pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.txt36
-rw-r--r--pdf-as-pdfbox-2/licenses/levigo-jbig2-imageio.txt675
-rw-r--r--pdf-as-pdfbox-2/src/main/java/META-INF/MANIFEST.MF3
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXBackend.java53
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java67
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/configuration/ProfileValidator.java124
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/PDFBoxPlaceholderExtractor.java29
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java58
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java605
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java361
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java68
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java22
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java81
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java900
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/SignatureDataExtractor.java86
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/FontInfoCache.java8
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/IDGenerator.java5
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/ImageObject.java64
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsFontCache.java66
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsTemplateCreator.java212
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java693
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureDesigner.java472
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java150
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java268
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java741
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxStamper.java56
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxVisualObject.java108
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/StamperFactory.java26
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/TableDrawUtils.java708
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/pdfbox2/PDFBOXVerifier.java185
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFPage.java660
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFUtilities.java154
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathConstructionOperatorProcessor.java85
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathPaintingOperatorProcessor.java66
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/ClosePath.java97
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveTo.java114
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateFinalPoint.java111
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateInitialPoint.java113
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/LineTo.java100
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/MoveTo.java103
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseAndStrokePath.java88
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillEvenOddAndStrokePath.java89
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillNonZeroAndStrokePath.java89
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/EndPath.java97
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillEvenOddAndStrokePath.java101
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillNonZeroAndStrokePath.java101
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathEvenOddRule.java100
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathNonZeroWindingNumberRule.java103
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/StrokePath.java99
-rw-r--r--pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.backend.PDFASBackend1
-rw-r--r--pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator1
-rw-r--r--pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java66
-rw-r--r--pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java182
-rw-r--r--pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/TTFFontTest.java46
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/1Sign_manyQR.pdfbin188967 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/Test-sign.pdfbin62464 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/Testdoc_Signatur.pdfbin84684 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign-sign.pdfbin260014 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign.pdfbin216197 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign.pdfbin172415 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign.pdfbin128804 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/data/platzhalter_en_de_test.pdfbin46732 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/manySignFields.pdfbin181760 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/manySignFields_signed4.pdfbin233204 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/new_qr_2-2.pdfbin182043 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed.pdfbin225097 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed.pdfbin267093 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed_signed.pdfbin310607 -> 0 bytes
-rw-r--r--pdf-as-pdfbox-3/src/main/kotlin/at/gv/egiz/pdfas/lib/impl/pdfbox3/Placeholder.kt2
-rw-r--r--pdf-as-tests/build.gradle9
-rw-r--r--pdf-as-web/build.gradle1
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java2
-rw-r--r--settings.gradle2
82 files changed, 30 insertions, 9883 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a4fa72a2..62f9187f 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -44,5 +44,5 @@ jobs:
with:
name: ${{ env.PROJECT_NAME }}-${{ env.SHORT_SHA }}-release
path: |
- release/${VERSION}/pdf-as-lib-${VERSION}.zip
- release/${VERSION}/pdf-as-web-${VERSION}.war \ No newline at end of file
+ releases/${VERSION}/pdf-as-lib-${VERSION}.zip
+ releases/${VERSION}/pdf-as-web-${VERSION}.war \ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 170e38c6..424e7680 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,8 +14,6 @@ out/
pdf-as-tests/src/test/test-suites/*
pdf-as-tests/src/test/test-suites/*/
-!pdf-as-tests/src/test/test-suites/public_pdfbox1/
-!pdf-as-tests/src/test/test-suites/public_pdfbox2/
!pdf-as-tests/src/test/test-suites/public_pdfbox3/
pdf-as-tests/src/test/test-suites/**/index.html
pdf-as-tests/src/test/test-suites/**/test_result.html
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b9ac20cf..6e7f6e26 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -95,5 +95,5 @@ release:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_SHORT_SHA}-release"
expire_in: never
paths:
- - "../release/${VERSION}/pdf-as-web-${VERSION}.war"
- - "../release/${VERSION}/pdf-as-lib-${VERSION}.zip"
+ - "../releases/${VERSION}/pdf-as-web-${VERSION}.war"
+ - "../releases/${VERSION}/pdf-as-lib-${VERSION}.zip"
diff --git a/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-2.properties b/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-3.properties
index 759fb51c..c9b1eadf 100644
--- a/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-2.properties
+++ b/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader-3.properties
@@ -1,23 +1,23 @@
-cm = org.apache.pdfbox.contentstream.operator.state.Concatenate
-gs = org.apache.pdfbox.contentstream.operator.state.SetGraphicsStateParameters
-q = org.apache.pdfbox.contentstream.operator.state.Save
-Q = org.apache.pdfbox.contentstream.operator.state.Restore
-Tm = org.apache.pdfbox.contentstream.operator.state.SetMatrix
-w = org.apache.pdfbox.contentstream.operator.state.SetLineWidth
-BT = org.apache.pdfbox.contentstream.operator.text.BeginText
-ET = org.apache.pdfbox.contentstream.operator.text.EndText
-T* = org.apache.pdfbox.contentstream.operator.text.NextLine
-Tc = org.apache.pdfbox.contentstream.operator.text.SetCharSpacing
-Td = org.apache.pdfbox.contentstream.operator.text.MoveText
-TD = org.apache.pdfbox.contentstream.operator.text.MoveTextSetLeading
-Tf = org.apache.pdfbox.contentstream.operator.text.SetFontAndSize
-Tj = org.apache.pdfbox.contentstream.operator.text.ShowText
-TJ = org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted
-TL = org.apache.pdfbox.contentstream.operator.text.SetTextLeading
-Tr = org.apache.pdfbox.contentstream.operator.text.SetTextRenderingMode
-Ts = org.apache.pdfbox.contentstream.operator.text.SetTextRise
-Tw = org.apache.pdfbox.contentstream.operator.text.SetWordSpacing
-Tz = org.apache.pdfbox.contentstream.operator.text.SetTextHorizontalScaling
-\' = org.apache.pdfbox.contentstream.operator.text.ShowTextLine
-\" = org.apache.pdfbox.contentstream.operator.text.ShowTextLineAndSpace
+cm = org.apache.pdfbox.contentstream.operator.state.Concatenate
+gs = org.apache.pdfbox.contentstream.operator.state.SetGraphicsStateParameters
+q = org.apache.pdfbox.contentstream.operator.state.Save
+Q = org.apache.pdfbox.contentstream.operator.state.Restore
+Tm = org.apache.pdfbox.contentstream.operator.state.SetMatrix
+w = org.apache.pdfbox.contentstream.operator.state.SetLineWidth
+BT = org.apache.pdfbox.contentstream.operator.text.BeginText
+ET = org.apache.pdfbox.contentstream.operator.text.EndText
+T* = org.apache.pdfbox.contentstream.operator.text.NextLine
+Tc = org.apache.pdfbox.contentstream.operator.text.SetCharSpacing
+Td = org.apache.pdfbox.contentstream.operator.text.MoveText
+TD = org.apache.pdfbox.contentstream.operator.text.MoveTextSetLeading
+Tf = org.apache.pdfbox.contentstream.operator.text.SetFontAndSize
+Tj = org.apache.pdfbox.contentstream.operator.text.ShowText
+TJ = org.apache.pdfbox.contentstream.operator.text.ShowTextAdjusted
+TL = org.apache.pdfbox.contentstream.operator.text.SetTextLeading
+Tr = org.apache.pdfbox.contentstream.operator.text.SetTextRenderingMode
+Ts = org.apache.pdfbox.contentstream.operator.text.SetTextRise
+Tw = org.apache.pdfbox.contentstream.operator.text.SetWordSpacing
+Tz = org.apache.pdfbox.contentstream.operator.text.SetTextHorizontalScaling
+\' = org.apache.pdfbox.contentstream.operator.text.ShowTextLine
+\" = org.apache.pdfbox.contentstream.operator.text.ShowTextLineAndSpace
#Do = org.apache.pdfbox.contentstream.operator.graphics.DrawObject \ No newline at end of file
diff --git a/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader.properties b/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader.properties
deleted file mode 100644
index a3decc96..00000000
--- a/pdf-as-lib/src/main/resources/placeholder/pdfbox-reader.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-BT = org.apache.pdfbox.util.operator.BeginText
-cm = org.apache.pdfbox.util.operator.Concatenate
-Do = org.apache.pdfbox.util.operator.Invoke
-ET = org.apache.pdfbox.util.operator.EndText
-gs = org.apache.pdfbox.util.operator.SetGraphicsStateParameters
-q = org.apache.pdfbox.util.operator.GSave
-Q = org.apache.pdfbox.util.operator.GRestore
-T* = org.apache.pdfbox.util.operator.NextLine
-Tc = org.apache.pdfbox.util.operator.SetCharSpacing
-Td = org.apache.pdfbox.util.operator.MoveText
-TD = org.apache.pdfbox.util.operator.MoveTextSetLeading
-Tf = org.apache.pdfbox.util.operator.SetTextFont
-Tj = org.apache.pdfbox.util.operator.ShowText
-TJ = org.apache.pdfbox.util.operator.ShowTextGlyph
-TL = org.apache.pdfbox.util.operator.SetTextLeading
-Tm = org.apache.pdfbox.util.operator.SetMatrix
-Tr = org.apache.pdfbox.util.operator.SetTextRenderingMode
-Ts = org.apache.pdfbox.util.operator.SetTextRise
-Tw = org.apache.pdfbox.util.operator.SetWordSpacing
-Tz = org.apache.pdfbox.util.operator.SetHorizontalTextScaling
-w = org.apache.pdfbox.util.operator.SetLineWidth
-\' = org.apache.pdfbox.util.operator.MoveAndShow
-\" = org.apache.pdfbox.util.operator.SetMoveAndShow \ No newline at end of file
diff --git a/pdf-as-pdfbox-2/.gitignore b/pdf-as-pdfbox-2/.gitignore
deleted file mode 100644
index ae3c1726..00000000
--- a/pdf-as-pdfbox-2/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin/
diff --git a/pdf-as-pdfbox-2/build.gradle b/pdf-as-pdfbox-2/build.gradle
deleted file mode 100644
index f0bc9203..00000000
--- a/pdf-as-pdfbox-2/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-apply plugin: 'java-library'
-apply plugin: 'eclipse'
-
-jar {
- manifest {
- attributes 'Implementation-Title': 'PDF-AS-5 PDFBOX 2 Backend'
- }
-
-// from {
-// configurations.compile.collect{it}
-
-// }{
-// include "pdfbox*"
-// }
- }
-
-
-repositories {
- mavenLocal()
- mavenCentral()
-}
-
-tasks.register('releases', Copy) {
- from jar.outputs
- into rootDir.toString() + "/releases/" + version
-
-}
-
-releases.dependsOn jar
-releases.dependsOn sourcesJar
-
-dependencies {
- var pdfbox2Version = '2.0.35'
- implementation project (':pdf-as-lib')
- implementation group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
- implementation group: 'org.slf4j', name: 'jcl-over-slf4j', version: slf4jVersion
- api group: 'org.apache.pdfbox', name: 'pdfbox', version: pdfbox2Version
- api group: 'org.apache.pdfbox', name: 'pdfbox-tools', version: pdfbox2Version
- api group: 'org.apache.pdfbox', name: 'preflight', version: pdfbox2Version
- implementation group: 'commons-io', name: 'commons-io', version: commonsIoVersion
- implementation group: 'ognl', name: 'ognl', version: ognlVersion
- api group: 'com.github.jai-imageio', name: 'jai-imageio-jpeg2000', version: '1.4.0'
- api group: 'com.github.jai-imageio', name: 'jai-imageio-core', version: '1.4.0'
- api group: 'com.levigo.jbig2', name: 'levigo-jbig2-imageio', version: '2.0'
- implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: jakartaActivationVersion
- implementation group: 'javax.activation', name: 'activation', version: '1.1.1'
-
- testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
- testImplementation group: 'ch.qos.logback', name: 'logback-core', version: logbackVersion
-
-}
-
-test {
- systemProperties 'property': 'value'
-}
-
diff --git a/pdf-as-pdfbox-2/licenses/jai-imageio-core.txt b/pdf-as-pdfbox-2/licenses/jai-imageio-core.txt
deleted file mode 100644
index 88e09e0d..00000000
--- a/pdf-as-pdfbox-2/licenses/jai-imageio-core.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-Copyright (c) 2005 Sun Microsystems, Inc.
-Copyright © 2010-2014 University of Manchester
-Copyright © 2010-2015 Stian Soiland-Reyes
-Copyright © 2015 Peter Hull
-All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-- Redistribution of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-- Redistribution in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any
-kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
-WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
-EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
-NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
-USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
-DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
-ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
-CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
-REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
-INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-You acknowledge that this software is not designed or intended for
-use in the design, construction, operation or maintenance of any
-nuclear facility.
diff --git a/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.info.txt b/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.info.txt
deleted file mode 100644
index 2f958c7a..00000000
--- a/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.info.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-This software module was originally developed by Raphaël Grosbois and
-Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
-Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
-Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
-Centre France S.A) in the course of development of the JPEG2000
-standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
-software module is an implementation of a part of the JPEG 2000
-Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
-Systems AB and Canon Research Centre France S.A (collectively JJ2000
-Partners) agree not to assert against ISO/IEC and users of the JPEG
-2000 Standard (Users) any of their rights under the copyright, not
-including other intellectual property rights, for this software module
-with respect to the usage by ISO/IEC and Users of this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the JPEG 2000 Standard. Those intending to use
-this software module in hardware or software products are advised that
-their use may infringe existing patents. The original developers of
-this software module, JJ2000 Partners and ISO/IEC assume no liability
-for use of this software module or modifications thereof. No license
-or right to this software module is granted for non JPEG 2000 Standard
-conforming products. JJ2000 Partners have full right to use this
-software module for his/her own purpose, assign or donate this
-software module to any third party and to inhibit third parties from
-using this software module for non JPEG 2000 Standard conforming
-products. This copyright notice must be included in all copies or
-derivative works of this software module.
-
-Copyright (c) 1999/2000 JJ2000 Partners.
diff --git a/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.txt b/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.txt
deleted file mode 100644
index 827d4355..00000000
--- a/pdf-as-pdfbox-2/licenses/jai-imageio-jpeg2000.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-- Redistribution of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-- Redistribution in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any
-kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
-WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
-EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
-NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
-USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
-DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
-ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
-CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
-REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
-INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-You acknowledge that this software is not designed or intended for
-use in the design, construction, operation or maintenance of any
-nuclear facility.
-
diff --git a/pdf-as-pdfbox-2/licenses/levigo-jbig2-imageio.txt b/pdf-as-pdfbox-2/licenses/levigo-jbig2-imageio.txt
deleted file mode 100644
index 10926e87..00000000
--- a/pdf-as-pdfbox-2/licenses/levigo-jbig2-imageio.txt
+++ /dev/null
@@ -1,675 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
-
diff --git a/pdf-as-pdfbox-2/src/main/java/META-INF/MANIFEST.MF b/pdf-as-pdfbox-2/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e949512..00000000
--- a/pdf-as-pdfbox-2/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXBackend.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXBackend.java
deleted file mode 100644
index 4b4e1db9..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXBackend.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.lib.backend.PDFASBackend;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.PDFBoxPlaceholderExtractor;
-import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractor;
-import at.gv.egiz.pdfas.lib.impl.signing.IPdfSigner;
-import at.gv.egiz.pdfas.lib.impl.signing.pdfbox2.PADESPDFBOXSigner;
-import at.gv.egiz.pdfas.lib.impl.verify.VerifyBackend;
-import at.gv.egiz.pdfas.lib.impl.verify.pdfbox2.PDFBOXVerifier;
-
-public class PDFBOXBackend implements PDFASBackend {
-
- private static final String NAME = "PDFBOX_2_BACKEND";
-
- private static final Logger logger = LoggerFactory
- .getLogger(PDFBOXBackend.class);
-
- static {
- logger.info(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- logger.info(" + PDFBOX Backend created");
- logger.info(" + PDFBOX Version used: " + org.apache.pdfbox.util.Version.getVersion());
- logger.info(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public boolean usedAsDefault() {
- return false;
- }
-
- @Override
- public IPdfSigner getPdfSigner() {
- return new PADESPDFBOXSigner();
- }
-
- @Override
- public PlaceholderExtractor getPlaceholderExtractor() {
- return new PDFBoxPlaceholderExtractor();
- }
-
- @Override
- public VerifyBackend getVerifier() {
- return new PDFBOXVerifier();
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java
deleted file mode 100644
index e0947b46..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/PDFBOXObject.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2;
-
-import java.io.IOException;
-
-import jakarta.activation.DataSource;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-
-import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PDFAsFontCache;
-import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
-import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
-
-public class PDFBOXObject extends PDFObject {
-
- private PDDocument doc;
-
- private PDFAsFontCache sigBlockFontCache = new PDFAsFontCache();
-
- public PDFAsFontCache getSigBlockFontCache() {
- return sigBlockFontCache;
- }
-
- public void setSigBlockFontCache(PDFAsFontCache sigBlockFontCache) {
- this.sigBlockFontCache = sigBlockFontCache;
- }
-
- public PDFBOXObject(OperationStatus operationStatus) {
- super(operationStatus);
- }
-
- // Note: finalize() method removed as it's deprecated in Java 9+
- // Resource cleanup should be handled explicitly via close() method
-
- public void close() {
- if(doc != null) {
- try {
- doc.close();
- } catch(Throwable e) {
- // Ignore Throwables during close
- }
- doc = null;
- }
- }
-
- public void setOriginalDocument(DataSource originalDocument) throws IOException {
- this.originalDocument = originalDocument;
- if(doc != null) {
- doc.close();
- }
- synchronized(PDDocument.class) {
- this.doc = PDDocument.load(this.originalDocument.getInputStream());
- }
- if(this.doc != null) {
- this.doc.getDocument().setWarnMissingClose(false);
- }
- }
-
- public PDDocument getDocument() {
- return this.doc;
- }
-
- @Override
- public String getPDFVersion() {
- return String.valueOf(getDocument().getDocument().getVersion());
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/configuration/ProfileValidator.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/configuration/ProfileValidator.java
deleted file mode 100644
index aa90d6a7..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/configuration/ProfileValidator.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.configuration;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PDFASError;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
-import at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.status.ICertificateProvider;
-import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
-import iaik.asn1.ObjectID;
-import iaik.asn1.structures.Name;
-import iaik.x509.X509Certificate;
-
-public class ProfileValidator implements ConfigurationValidator{
-
- private static final String NAME = "PDFBOX_2_PROFILE_VALIDATOR";
-
- private static final Logger logger = LoggerFactory
- .getLogger(ProfileValidator.class);
-
- @Override
- public void validate(ISettings settings) throws PdfAsSettingsValidationException{
- Set<String> profileIds = new HashSet<String>();
-
- Iterator<String> itKeys = settings.getFirstLevelKeys("sig_obj.types.")
- .iterator();
- while (itKeys.hasNext()) {
- String key = itKeys.next();
- String profile = key.substring("sig_obj.types.".length());
-
- if (settings.getValue(key).equals("on")) {
- profileIds.add(profile);
- }
- }
- logger.debug("Validating "+profileIds.size()+ " Profiles.");
-
- ArrayList<SignatureProfileSettings> profileSettings = new ArrayList<SignatureProfileSettings>();
-
- OperationStatus opState = new OperationStatus(settings, null, null, null);
-
- X509Certificate dummyCert = new X509Certificate();
- dummyCert.setSerialNumber(new BigInteger("123"));
- Name n = new Name();
- n.addRDN(ObjectID.country, "AT");
- n.addRDN(ObjectID.locality, "Graz");
- n.addRDN(ObjectID.organization ,"test");
- n.addRDN(ObjectID.organizationalUnit ,"test");
- n.addRDN(ObjectID.commonName ,"testca");
- dummyCert.setIssuerDN(n);
- dummyCert.setSubjectDN(n);
-
- ICertificateProvider certProvider = new DummyCertificateProvider(dummyCert);
-
- PDFBOXObject pdfBoxObject = new PDFBOXObject(opState);
- PDDocument origDoc = new PDDocument();
- origDoc.addPage(new PDPage(PDRectangle.A4));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
-
- origDoc.save(baos);
- baos.close();
- origDoc.close();
-
- pdfBoxObject.setOriginalDocument(new ByteArrayDataSource(baos.toByteArray()));
- } catch (IOException e1) {
- logger.info("Configuration Validation failed!");
- throw new PdfAsSettingsValidationException("Configuration Validationfailed!", e1);
- }
-
-
- for(String id:profileIds){
- try {
- SignatureProfileSettings profileSetting = new SignatureProfileSettings(id, settings);
- profileSettings.add(profileSetting);
- if(profileSetting.getValue("isvisible")!=null){
- if(profileSetting.getValue("isvisible").equals("false")){
- continue;
- }
- }
- } catch (PDFASError e) {
- logger.error("Find suspect signature-profile configuration. Ignore it", e);
-
- }
- }
- }
-
- @Override
- public boolean usedAsDefault() {
- return false;
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- private class DummyCertificateProvider implements ICertificateProvider {
- private X509Certificate cert;
- public DummyCertificateProvider(X509Certificate cert) {
- this.cert = cert;
- }
- public X509Certificate getCertificate() {
- return cert;
- }
-
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/PDFBoxPlaceholderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/PDFBoxPlaceholderExtractor.java
deleted file mode 100644
index 414b8a31..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/PDFBoxPlaceholderExtractor.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractor;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
-
-public class PDFBoxPlaceholderExtractor implements PlaceholderExtractor {
-
-
- @Override
- public SignaturePlaceholderData extract(PDFObject doc, String placeholderId, int matchMode) throws PdfAsException {
- if (doc instanceof PDFBOXObject object) {
- try {
- SignaturePlaceholderExtractor extractor = new SignaturePlaceholderExtractor();
- return extractor.extract(object.getDocument(), placeholderId, matchMode);
- } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException |
- InvocationTargetException e2) {
- throw new PDFIOException("error.pdf.io.04", e2);
- }
- }
- throw new PdfAsException("INVALID STATE");
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java
deleted file mode 100644
index 8e5e5d4e..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
-import org.apache.pdfbox.pdmodel.interactive.form.PDField;
-import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
-
-import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-
-public class SignatureFieldsAndPlaceHolderExtractor {
-
- // Search for empty signature fields
- public static List<String> findEmptySignatureFields(PDDocument doc) {
- PDSignature signature;
- List<PDField> signatureField;
- final List<String> signatureFieldNames = new ArrayList<>();
- final PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
- if (acroForm != null) {
- signatureField = acroForm.getFields();
- for (final PDField pdField : signatureField) {
- if (pdField instanceof PDSignatureField && pdField.getPartialName() != null) {
- signature = ((PDSignatureField) pdField).getSignature();
- if (signature == null) {
- signatureFieldNames.add(pdField.getPartialName());
- }
- }
- }
- }
- return signatureFieldNames;
- }
- /*
- * Needed by PDF-OVER
- */
-
- /**
- * Returns the next unused signature placeholder
- *
- * @param doc The document to be searched for signature placeholders
- * @return The next unused signature placeholder or null in case there is none
- */
- public static SignaturePlaceholderData getNextUnusedSignaturePlaceHolder(PDDocument doc) {
- try {
- final String placeholderId = "1";
- final int mode = PlaceholderExtractorConstants.PLACEHOLDER_MATCH_MODE_SORTED;
- final SignaturePlaceholderExtractor signaturePlaceholderExtractor = new SignaturePlaceholderExtractor();
- return signaturePlaceholderExtractor.extract(doc, placeholderId, mode);
-
- } catch (final Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
deleted file mode 100644
index 372f6d70..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
+++ /dev/null
@@ -1,605 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder;
-
-import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-import java.util.HashSet;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-import org.apache.pdfbox.contentstream.PDFStreamEngine;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDPropBuild;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDPropBuildDataDict;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-import org.apache.pdfbox.util.Matrix;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.BinaryBitmap;
-import com.google.zxing.DecodeHintType;
-import com.google.zxing.LuminanceSource;
-import com.google.zxing.MultiFormatReader;
-import com.google.zxing.NotFoundException;
-import com.google.zxing.ReaderException;
-import com.google.zxing.Result;
-import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
-import com.google.zxing.common.HybridBinarizer;
-
-import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PlaceholderExtractionException;
-import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import javassist.bytecode.stackmap.TypeData.ClassName;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * Extract all relevant information from a placeholder image.
- *
- * @author exthex
- *
- */
-@Slf4j
-public class SignaturePlaceholderExtractor extends PDFStreamEngine implements PlaceholderExtractorConstants {
-
- public static final String PREFIX = "PDF-AS_";
-
- private final Set<String> placeholderNames = new HashSet<>();
- private final List<SignaturePlaceholderData> placeholders = new ArrayList<>();
- private int currentPage = 0;
-
- protected SignaturePlaceholderExtractor() throws IOException, ClassNotFoundException,
- InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
- super();
-
- final Properties properties = new Properties();
- properties.load(ClassName.class.getClassLoader().getResourceAsStream(
- "placeholder/pdfbox-reader-2.properties"));
-
- final Set<Entry<Object, Object>> entries = properties.entrySet();
- for (final Entry<Object, Object> entry : entries) {
- final String processorClassName = (String) entry.getValue();
- final Class<?> klass = Class.forName(processorClassName);
- final org.apache.pdfbox.contentstream.operator.OperatorProcessor processor =
- (OperatorProcessor) klass.getDeclaredConstructor().newInstance();
-
- addOperator(processor);
-
- }
- }
-
- /**
- * Search the document for placeholder images and possibly included additional
- * info.<br/>
- * Searches only for the first placeholder page after page from top.
- *
- * @return available info from the first found placeholder.
- * @throws PdfAsException if the document could not be read.
- * @throws PlaceholderExtractionException if STRICT matching mode was requested
- * and no suitable placeholder could be
- * found.
- */
- public SignaturePlaceholderData extract(PDDocument doc,
- String placeholderId, int matchMode) throws PdfAsException {
- List<String> extistingSignatureNames = existingExistingSignatureNames(doc);
- log.debug("Initial found #{} already used placeholders", extistingSignatureNames.size());
-
- SignaturePlaceholderData foundOnSinglePage =
- parseDocumentAndSearchOnSiglePages(doc, extistingSignatureNames, placeholderId, matchMode);
-
- if (foundOnSinglePage != null) {
- return foundOnSinglePage;
-
- } else {
- return searchOnAnyPage(extistingSignatureNames, matchMode);
-
- }
- }
-
- /**
- * Set a placeholderId into signature directory.
- *
- * @param signature Signature
- * @param placeholderId placeholderId
- */
- public static void setPlaceholderId(PDSignature signature, String placeholderId) {
- PDPropBuild sigProps = getOrNew(signature);
- PDPropBuildDataDict appProps = getOrNew(sigProps);
- appProps.setName(PREFIX + placeholderId);
- sigProps.setPDPropBuildApp(appProps);
- signature.setPropBuild(sigProps);
-
- }
-
- @Override
- protected void processOperator(Operator operator, List<COSBase> arguments)
- throws IOException {
- final String operation = operator.getName();
- if (operation.equals("Do")) {
- final COSName objectName = (COSName) arguments.get(0);
- final PDXObject xobject = getResources().getXObject(objectName);
- if (xobject instanceof PDImageXObject) {
- try {
- final PDImageXObject image = (PDImageXObject) xobject;
- final SignaturePlaceholderData data = checkImage(image);
- if (data != null) {
- final PDPage page = getCurrentPage();
- final Matrix ctm = getGraphicsState()
- .getCurrentTransformationMatrix();
- int pageRotation = page.getRotation();
- pageRotation = pageRotation % 360;
- final double rotationInRadians = Math.toRadians(pageRotation);// (page.findRotation() * Math.PI) /
- // 180;
-
- final AffineTransform rotation = new AffineTransform();
- rotation.setToRotation(rotationInRadians);
- final AffineTransform rotationInverse = rotation
- .createInverse();
- final Matrix rotationInverseMatrix = new Matrix(rotationInverse);
- final Matrix rotationMatrix = new Matrix(rotation);
-
- final Matrix unrotatedCTM = ctm
- .multiply(rotationInverseMatrix);
-
- float x = unrotatedCTM.getTranslateX();
- final float yPos = unrotatedCTM.getTranslateY();
- final float yScale = unrotatedCTM.getScaleY();
- float y = yPos + yScale;
- final float w = unrotatedCTM.getScaleX();
-
- log.debug("Page height: {}", page.getCropBox().getHeight());
- log.debug("Page width: {}", page.getCropBox().getWidth());
-
- if (pageRotation == 90) {
- y = page.getCropBox().getWidth() - y * -1;
- } else if (pageRotation == 180) {
- x = page.getCropBox().getWidth() + x;
- y = page.getCropBox().getHeight() - y * -1;
- } else if (pageRotation == 270) {
- x = page.getCropBox().getHeight() + x;
- }
-
- final String posString = "p:" + currentPage + ";x:" + Math.floor(x)
- + ";y:" + Math.ceil(y) + ";w:" + Math.ceil(w);
-
- try {
- data.setTablePos(new TablePos(posString));
-
- data.setPlaceholderName(buildUniqueObjectName(objectName));
- log.debug("Found Placeholder at: {}", data.toString());
- placeholders.add(data);
- placeholderNames.add(data.getPlaceholderName());
-
- } catch (final PdfAsException e) {
- throw new IOException();
-
- }
- }
- } catch (final NoninvertibleTransformException e) {
- throw new IOException(e);
- }
- }
- } else {
- super.processOperator(operator, arguments);
- }
- }
-
- private SignaturePlaceholderData searchOnAnyPage(List<String> extistingSignatureNames, int matchMode) throws PlaceholderExtractionException {
- if (placeholders.size() > 0) {
- final SignaturePlaceholderData ret = matchPlaceholderDocument(
- removeAlreadyUsePlaceholders(placeholders, extistingSignatureNames), matchMode);
- return ret;
-
- }
- // no placeholders found, apply strict mode if set
- if (matchMode == PLACEHOLDER_MATCH_MODE_STRICT) {
- throw new PlaceholderExtractionException("error.pdf.stamp.09");
-
- }
-
- return null;
-
- }
-
- private SignaturePlaceholderData parseDocumentAndSearchOnSiglePages(PDDocument doc, List<String> extistingSignatureNames,
- String placeholderId, int matchMode) throws PDFIOException {
- int pageNr = 0;
- for (final PDPage page : doc.getPages()) {
- pageNr++;
-
- SignaturePlaceholderData ret = processSinglePage(page, pageNr, extistingSignatureNames, placeholderId, matchMode);
- if (ret != null) {
- log.debug("Found placeholder to use on page: {}. Stopping further search ... ", this.currentPage);
- return ret;
-
- }
- }
-
- return null;
-
- }
-
- private SignaturePlaceholderData processSinglePage(PDPage page, int pageNr, List<String> extistingSignatureNames,
- String placeholderId, int matchMode) throws PDFIOException {
- try {
- this.currentPage = pageNr;
- if (page.getContents() != null && page.getResources() != null && page.getContentStreams() != null) {
- processPage(page); // TODO: pdfbox2 - right?
-
- }
-
- return matchPlaceholderOnSinglePage(
- removeAlreadyUsePlaceholders(placeholders, extistingSignatureNames), placeholderId, matchMode);
-
- } catch (final Throwable e) {
- throw new PDFIOException("error.pdf.io.04", e);
-
- }
- }
-
-
- /**
- * Builds unique placeholderId from PDF element.
- *
- * @param name PDF element name
- * @return unique identifier
- */
- private String buildUniqueObjectName(COSName name) {
- final String baseName = name.getName();
- int i = 0;
- String candidate = baseName;
- while (placeholderNames.contains(candidate)) {
- candidate = baseName + "_" + (++i);
- }
- return candidate;
- }
-
- private SignaturePlaceholderData matchPlaceholderOnSinglePage(
- List<SignaturePlaceholderData> placeholders, String placeholderId, int matchMode) {
- log.debug("Searching requested placeholder:{} with matchMode:{} in single page ... ", placeholderId, matchMode);
-
- if (placeholders.size() == 0) {
- return null;
-
- }
-
- for (final SignaturePlaceholderData data : placeholders) {
-
- /*
- * If specific placeholderId is requested and placeholder as an Id, check if it already matches
- */
- if (placeholderId != null && data.getId() != null
- && matchPlaceHolderId(placeholderId, data.getId())) {
- return data;
-
- }
-
- /*
- * If mode is not sorted and there is no specific placeholderId requested
- * and placeholder contains no Id use the first one found
- */
- if (matchMode != PLACEHOLDER_MATCH_MODE_SORTED
- && placeholderId == null && data.getId() == null) {
- return data;
-
- }
- }
-
- return null;
- }
-
- private SignaturePlaceholderData matchPlaceholderDocument(
- List<SignaturePlaceholderData> placeholders, int matchMode) throws PlaceholderExtractionException {
-
- log.debug("Searching requested placeholder with matchMode:{} on any page ... ", matchMode);
-
- if (matchMode == PLACEHOLDER_MATCH_MODE_STRICT) {
- throw new PlaceholderExtractionException("error.pdf.stamp.09");
- }
-
- if (placeholders.size() == 0) {
- return null;
- }
-
- if (matchMode == PLACEHOLDER_MATCH_MODE_SORTED) {
- // sort all placeholders by the id string if all ids are null do nothing
- SignaturePlaceholderData currentFirstSpd = null;
- for (final SignaturePlaceholderData spd : placeholders) {
- if (spd.getId() != null) {
- if (currentFirstSpd == null) {
- currentFirstSpd = spd;
- log.debug("Setting new current ID: {}",
- currentFirstSpd.getId());
- } else {
- currentFirstSpd = placeHolderIdMatcher(currentFirstSpd, spd);
-
- }
- }
- }
-
- if (currentFirstSpd != null) {
- log.info("Running Placeholder sorted mode: using id: {}", currentFirstSpd.getId());
- return currentFirstSpd;
-
- } else {
- log.info(
- "Running Placeholder sorted mode: no placeholder with id found, fallback to first placeholder");
- }
- }
-
- for (final SignaturePlaceholderData spd : placeholders) {
- if (spd.getId() == null) {
- return spd;
- }
- }
-
- if (matchMode == PLACEHOLDER_MATCH_MODE_LENIENT) {
- return placeholders.get(0);
- }
-
- return null;
- }
-
- private boolean matchPlaceHolderId(String first, String second) {
- try {
- Integer firstIdInt = Integer.valueOf(first);
- Integer secondIdInt = Integer.valueOf(second);
- return firstIdInt.equals(secondIdInt);
-
- } catch (NumberFormatException e) {
- log.trace("Can not compare placeholderId's on integer level. Using String compare ... ");
- return first.equalsIgnoreCase(second);
-
- }
-
- }
-
- private SignaturePlaceholderData placeHolderIdMatcher(SignaturePlaceholderData currentFirstSpd,
- SignaturePlaceholderData spd) {
- try {
- Integer currentIDInt = Integer.valueOf(currentFirstSpd.getId());
- Integer testIDInt = Integer.valueOf(spd.getId());
-
- if (testIDInt < currentIDInt) {
- log.debug("Setting new current ID: {}", testIDInt);
- return spd;
-
- } else {
- return currentFirstSpd;
-
- }
- } catch (NumberFormatException e) {
- log.trace("Can not compare placeholderId's on integer level. Using String compare ... ");
- final String currentID = currentFirstSpd.getId();
- final String testID = spd.getId();
- log.debug("Testing placeholder current: {} compare to {}",
- currentID, testID);
- if (testID.compareToIgnoreCase(currentID) < 0) {
- log.debug("Setting new current ID: {}",
- testID);
- return spd;
-
- } else {
- return currentFirstSpd;
-
- }
- }
- }
-
-
- private List<String> existingExistingSignatureNames(PDDocument doc) {
- try {
- final List<PDSignature> pdSignatureList = doc.getSignatureDictionaries();
- return pdSignatureList.stream()
- .map(el -> readPlaceHolderId(el))
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
-
- } catch (final IOException e) {
- log.warn("Can not parse signature dictionaries", e);
- return Collections.emptyList();
-
- }
- }
-
- private List<SignaturePlaceholderData> removeAlreadyUsePlaceholders(
- List<SignaturePlaceholderData> placeholders, List<String> existingPlaceholders) {
- if (placeholders != null) {
- List<SignaturePlaceholderData> result = placeholders.stream()
- .filter(el -> !existingPlaceholders.contains(el.getPlaceholderName()))
- .collect(Collectors.toList());
- log.trace("Initial found #{} placeholders, but #{} removed because already used.",
- placeholders.size(), placeholders.size() - result.size());
- return result;
-
- } else {
- return Collections.emptyList();
-
- }
- }
-
- /**
- * Checks an image if it is a placeholder for a signature.
- *
- * @param image
- * @return
- * @throws IOException
- */
- private SignaturePlaceholderData checkImage(PDImageXObject image)
- throws IOException {
- final BufferedImage bimg = image.getImage();
- if (bimg == null) {
- String type = image.getSuffix();
- if (type != null) {
- type = type.toUpperCase() + " images";
- } else {
- type = "Image type";
- }
- log.info("Unable to extract image for QRCode analysis. "
- + type
- + " not supported. Add additional JAI Image filters to your classpath. Refer to https://jai.dev.java.net. Skipping image.");
- return null;
-
- }
-
- if (bimg.getHeight() < 10 || bimg.getWidth() < 10) {
- log.debug("Image too small for QRCode. Skipping image.");
- return null;
- }
-
- final LuminanceSource source = new BufferedImageLuminanceSource(bimg);
- final BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
- Result result;
- final long before = System.currentTimeMillis();
- try {
- final Hashtable<DecodeHintType, Object> hints = new Hashtable<>();
- final Vector<BarcodeFormat> formats = new Vector<>();
- formats.add(BarcodeFormat.QR_CODE);
- hints.put(DecodeHintType.POSSIBLE_FORMATS, formats);
- result = new MultiFormatReader().decode(bitmap, hints);
-
- final String text = result.getText();
- String profile = null;
- String type = null;
- String sigKey = null;
- String id = null;
- if (text != null) {
- if (text.startsWith(QR_PLACEHOLDER_IDENTIFIER)) {
-
- final String[] data = text.split(";");
- if (data.length > 1) {
- for (int i = 1; i < data.length; i++) {
- final String kvPair = data[i];
- final String[] kv = kvPair.split("=");
- if (kv.length != 2) {
- log.debug("Invalid parameter in placeholder data: "
- + kvPair);
- } else {
- if (kv[0]
- .equalsIgnoreCase(SignaturePlaceholderData.ID_KEY)) {
- id = kv[1];
- } else if (kv[0]
- .equalsIgnoreCase(SignaturePlaceholderData.PROFILE_KEY)) {
- profile = kv[1];
- } else if (kv[0]
- .equalsIgnoreCase(SignaturePlaceholderData.SIG_KEY_KEY)) {
- sigKey = kv[1];
- } else if (kv[0]
- .equalsIgnoreCase(SignaturePlaceholderData.TYPE_KEY)) {
- type = kv[1];
- }
- }
- }
- }
- return new SignaturePlaceholderData(profile, type, sigKey,
- id);
- } else {
- log.warn("QR-Code found but does not start with \""
- + QR_PLACEHOLDER_IDENTIFIER
- + "\". Ignoring QR placeholder.");
- }
- }
- } catch (final ReaderException re) {
- if (log.isDebugEnabled()) {
- log.debug("Could not decode - not a placeholder. needed: "
- + (System.currentTimeMillis() - before));
- }
- if (!(re instanceof NotFoundException)) {
- if (log.isInfoEnabled()) {
- log.info("Failed to decode image", re);
- }
- }
- } catch (final ArrayIndexOutOfBoundsException e) {
- if (log.isInfoEnabled()) {
- log.info("Failed to decode image. Probably a zxing bug", e);
- }
- }
- return null;
- }
-
- /**
- * Read placeholderId from signature.
- *
- * @param signature Signature
- * @return placeholderId or <code>null</code> if there is no placeholderId.
- */
- private static String readPlaceHolderId(PDSignature signature) {
- PDPropBuild sigProps = getOrNew(signature);
- PDPropBuildDataDict appProps = getOrNew(sigProps);
- String newHolderId = appProps.getName() != null && appProps.getName().startsWith(PREFIX)
- ? appProps.getName().substring(PREFIX.length())
- : appProps.getName();
-
- // read placeHolderId from old location element as backup
- return newHolderId != null ? newHolderId : signature.getLocation();
-
- }
-
- private static final PDPropBuildDataDict getOrNew(PDPropBuild sigProps) {
- PDPropBuildDataDict props = sigProps.getApp();
- return props != null ? props : new PDPropBuildDataDict();
- }
-
- private static final PDPropBuild getOrNew(PDSignature signature) {
- PDPropBuild sigProps = signature.getPropBuild();
- return sigProps != null ? sigProps : new PDPropBuild();
-
- }
-}
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
deleted file mode 100644
index 7b18d2f1..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/Positioning.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
-
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.IProfileConstants;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.utils.PdfBoxUtils;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos.PAGE_MODE;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFUtilities;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * Created with IntelliJ IDEA. User: afitzek Date: 8/29/13 Time: 4:30 PM To
- * change this template use File | Settings | File Templates.
- */
-@Slf4j
-public class Positioning {
-
- /**
- * The left/right margin.
- */
- public static final float SIGNATURE_MARGIN_HORIZONTAL = 50f;
-
- /**
- * The top/bottom margin.
- */
- public static final float SIGNATURE_MARGIN_VERTICAL = 20f;
-
- /**
- * Evalutates absolute positioning and prepares the PositioningInstruction for
- * placing the table.
- *
- * @param pos The absolute positioning parameter. If null it is
- * sought in the profile definition.
- * @param pdfDataSource The pdf.
- * @param pdf_table The pdf table to be written.
- * @param settings
- * @param signatureProfileSettings Signature-block settings
- * @return Returns the PositioningInformation.
- * @throws PdfAsException F.e.
- */
- public static PositioningInstruction determineTablePositioning(
- TablePos pos, PDDocument pdfDataSource,
- IPDFVisualObject pdf_table, ISettings settings, SignatureProfileSettings signatureProfileSettings) throws PdfAsException {
- return adjustSignatureTableandCalculatePosition(pdfDataSource,
- pdf_table, pos, settings, signatureProfileSettings);
- }
-
- /**
- * Sets the width of the table according to the layout of the document and
- * calculates the y position where the PDFPTable should be placed.
- *
- * @param pdfDataSource The PDF document.
- * @param pdf_table The PDFPTable to be placed.
- * @param settings
- * @param profilConfig Signature-profile configuration
- * @return Returns the position where the PDFPTable should be placed.
- * @throws PdfAsException F.e.
- */
- public static PositioningInstruction adjustSignatureTableandCalculatePosition(
- final PDDocument pdfDataSource, IPDFVisualObject pdf_table,
- TablePos pos, ISettings settings, SignatureProfileSettings profilConfig) throws PdfAsException {
- PdfBoxUtils.checkPDFPermissions(pdfDataSource);
- final long numberOfExistingSignatures = getNumberOfExistingSignatures(pdfDataSource);
-
- // get pages of currentdocument
- final int doc_pages = pdfDataSource.getNumberOfPages();
- int page = doc_pages;
- boolean make_new_page = PAGE_MODE.NEW.equals(pos.getPageMode());
-
- if (PAGE_MODE.EXACT.equals(pos.getPageMode())) {
- // we should posit signaturtable on this page
- page = pos.getPage();
- if (page > doc_pages) {
- log.info("Document is shorter than requested page for signature block. Adding new page ...");
- make_new_page = true;
- page = doc_pages;
-
- }
- }
-
- make_new_page = checkIfNewPageIsAllowed(make_new_page, numberOfExistingSignatures, settings, profilConfig);
-
- final PDPage pdPage = pdfDataSource.getPage(page - 1);
- PDRectangle cropBox = pdPage.getCropBox();
- log.debug("Original CropBox: " + cropBox.toString());
-
- final int rotation = pdPage.getRotation();
- cropBox = rotateBox(cropBox, rotation);
- log.debug("Rotated CropBox: " + cropBox.toString());
-
- final float page_width = cropBox.getWidth();
- final float page_height = cropBox.getHeight();
- log.debug("CropBox width: " + page_width);
- log.debug("CropBox heigth: " + page_height);
-
- // now we can calculate x-position
- float pre_pos_x = SIGNATURE_MARGIN_HORIZONTAL;
- if (!pos.isXauto()) {
- // we do have absolute x
- pre_pos_x = pos.getPosX();
- }
- // calculate width
- // center
- float pre_width = page_width - 2 * pre_pos_x;
-
-
- if (!pos.isWauto()) {
- // we do have absolute width
- pre_width = pos.getWidth();
- if (pos.isXauto()) { // center x
- pre_pos_x = (page_width - pre_width) / 2;
-
- }
- }
-
- final float pos_x = pre_pos_x;
- final float width = pre_width;
-
- // Signatur table dimensions are complete
- pdf_table.setWidth(width);
- pdf_table.fixWidth();
-
- final float table_height = pdf_table.getHeight();
-
- // now check pos_y
-
- // last page was requested. Use all parameters as they was
- if (PAGE_MODE.LAST.equals(pos.getPageMode())) {
- log.debug("Positioning on last page was requested. Selecting this and use y-position as requested ... ");
- return new PositioningInstruction(make_new_page, page, pos_x,
- pos.isYauto() ? page_height - SIGNATURE_MARGIN_VERTICAL : pos.getPosY(),
- pos.getRotation());
-
- }
-
-
- // in case an absolute y position is already given OR
- // if the table is related to an invisible signature
- // there is no need for further calculations
- // (fixed adding new page in case of invisible signatures)
- if (!pos.isYauto() || table_height == 0) {
- // we do have y-position too --> all parameters but page ok
- if (make_new_page) {
- page++;
-
- }
-
- return new PositioningInstruction(make_new_page, page, pos_x, pos.getPosY(), pos.getRotation());
-
- }
-
- // pos_y is auto
- if (make_new_page) {
- // ignore footer in new page
- page++;
- return new PositioningInstruction(make_new_page, page, pos_x,
- page_height - SIGNATURE_MARGIN_VERTICAL, pos.getRotation());
-
- }
-
- // up to here no checks have to be made if Tablesize and Pagesize are
- // fit
- // Now we have to getfreespace in page and reguard footerline
- float pre_page_length = calculatePrePageLength(pdfDataSource, page, pdf_table, pos.getFooterLine(), settings);
-
- if (pre_page_length == Float.NEGATIVE_INFINITY) {
- // we do have an empty page or nothing in area above footerline
- return buildPostitionInfoOnSubpage(pdfDataSource, make_new_page, page, pos_x,
- page_height - SIGNATURE_MARGIN_VERTICAL, pos.getRotation(),
- pos.getFooterLine(), table_height, pos, page_height, numberOfExistingSignatures, settings, profilConfig);
-
- } else {
- // we do have text take SIGNATURE_MARGIN
- return buildPostitionInfoOnSubpage(pdfDataSource, make_new_page, page, pos_x,
- page_height - pre_page_length - SIGNATURE_MARGIN_VERTICAL,
- pos.getRotation(), pos.getFooterLine(), table_height, pos, page_height, numberOfExistingSignatures, settings, profilConfig);
-
- }
- }
-
- private static float calculatePrePageLength(PDDocument pdfDataSource, int page, IPDFVisualObject pdf_table, float footer_line, ISettings settings) {
- try {
- return PDFUtilities.getMaxYPosition(pdfDataSource, page - 1, pdf_table,
- SIGNATURE_MARGIN_VERTICAL, footer_line, settings);
-
- } catch (final IOException e) {
- log.warn("Could not determine page length, using -INFINITY");
- return Float.NEGATIVE_INFINITY;
-
- }
- }
-
- private static boolean isFailOnLessSpaceEnabled(ISettings settings) {
- String value = settings.getValue(IConfigurationConstants.SIG_BLOCK_LESS_SPACE_STOPPING_WITH_ERROR);
- return Boolean.valueOf(value);
-
- }
-
- private static boolean isNewPageOnSignedDocumentsEnabled(SignatureProfileSettings profilConfig) {
- String value = profilConfig.getValue(IProfileConstants.SIG_NEWPAGE_FORCE);
- return Boolean.valueOf(value);
-
- }
-
- private static boolean checkIfNewPageIsAllowed(boolean make_new_page, long numberOfExistingSignatures, ISettings settings,
- SignatureProfileSettings profilConfig) throws PdfAsException {
- if(make_new_page && numberOfExistingSignatures !=0 ) {
- log.debug("Signature-block would be need a new page, but new pages are not allowed on already signed documents.");
- if (isNewPageOnSignedDocumentsEnabled(profilConfig)) {
- log.info("New pages not allowed on already signed documents, but force new page by configuration");
- return make_new_page;
-
- } else if (isFailOnLessSpaceEnabled(settings)) {
- throw new PdfAsException("error.pdf.stamp.12");
-
- } else {
- log.info("Placing signature-block on last page without free-space checks ... ");
- return false;
-
- }
-
- } else {
- return make_new_page;
-
- }
- }
-
- private static PositioningInstruction buildPostitionInfoOnSubpage(PDDocument pdfDataSource, boolean make_new_page, int page, float pos_x,
- float pos_y, float rotation, float footer_line, float table_height, TablePos pos, float page_height,
- long numberOfExistingSignatures, ISettings settings, SignatureProfileSettings profilConfig) throws PdfAsException {
-
- if (pos_y - footer_line <= table_height) {
- boolean isPageModeAuto = PAGE_MODE.AUTO.equals(pos.getPageMode());
-
- make_new_page = checkIfNewPageIsAllowed(isPageModeAuto, numberOfExistingSignatures, settings, profilConfig);
- if (make_new_page) {
- page++;
-
- }
-
- if (!isPageModeAuto) {
- // we have to correct pagenumber
- page = pdfDataSource.getNumberOfPages();
-
- }
- // no text --> SIGNATURE_BORDER
- pos_y = page_height - SIGNATURE_MARGIN_VERTICAL;
-
- }
-
- return new PositioningInstruction(make_new_page, page, pos_x, pos_y, pos.getRotation());
-
- }
-
- private static long getNumberOfExistingSignatures(PDDocument pdfDataSource) {
- try {
- return pdfDataSource.getSignatureFields().stream()
- .filter(el -> el.getSignature() != null)
- .count();
-
- } catch (final IOException e) {
- log.warn("Can not extract existing Signatures from PDF. Use it as 0", e);
- return 0;
-
- }
- }
-
- private static PDRectangle rotateBox(PDRectangle cropBox, int rotation) {
- if (rotation != 0) {
- final Point2D upSrc = new Point2D.Float();
-
- upSrc.setLocation(cropBox.getUpperRightX(),
- cropBox.getUpperRightY());
-
- final Point2D llSrc = new Point2D.Float();
- llSrc.setLocation(cropBox.getLowerLeftX(), cropBox.getLowerLeftY());
- final AffineTransform transform = new AffineTransform();
- transform.setToIdentity();
- if (rotation % 360 != 0) {
- transform.setToRotation(Math.toRadians(rotation * -1), llSrc.getX(),
- llSrc.getY());
- }
- final Point2D upDst = new Point2D.Float();
- transform.transform(upSrc, upDst);
-
- final Point2D llDst = new Point2D.Float();
- transform.transform(llSrc, llDst);
-
- float y1 = (float) upDst.getY();
- float y2 = (float) llDst.getY();
-
- if (y1 > y2) {
- final float t = y1;
- y1 = y2;
- y2 = t;
- }
-
- if (y1 < 0) {
- y2 = y2 + -1 * y1;
- y1 = 0;
- }
-
- float x1 = (float) upDst.getX();
- float x2 = (float) llDst.getX();
-
- if (x1 > x2) {
- final float t = x1;
- x1 = x2;
- x2 = t;
- }
-
- if (x1 < 0) {
- x2 = x2 + -1 * x1;
- x1 = 0;
- }
-
- cropBox.setUpperRightX(x2);
- cropBox.setUpperRightY(y2);
- cropBox.setLowerLeftY(y1);
- cropBox.setLowerLeftX(x1);
- }
- return cropBox;
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java
deleted file mode 100644
index 72c333b7..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningPageDrawer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
-
-import java.awt.Color;
-import java.awt.Paint;
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
-import org.apache.pdfbox.rendering.PageDrawer;
-import org.apache.pdfbox.rendering.PageDrawerParameters;
-
-public class PositioningPageDrawer extends PageDrawer{
-
- public PositioningPageDrawer(PageDrawerParameters parameters)
- throws IOException {
- super(parameters);
- // TODO Auto-generated constructor stub
- }
-
- private static final Color POSCOLOR = new Color(234, 14, 184, 211);
-
- @Override
- protected Paint getPaint(PDColor color){
- return POSCOLOR;
- }
-
-// @Override
-// protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode,Vector displacement) throws IOException{
-// // bbox in EM -> user units
-// Shape bbox = new Rectangle2D.Float(0, 0, font.getWidth(code) / 1000, 1);
-// AffineTransform at = textRenderingMatrix.createAffineTransform();
-// bbox = at.createTransformedShape(bbox);
-//
-// // save
-// Graphics2D graphics = getGraphics();
-//
-// // draw
-// graphics.setClip(graphics.getDeviceConfiguration().getBounds());
-// graphics.setColor(POSCOLOR);
-// graphics.setStroke(new BasicStroke(.5f));
-// graphics.draw(bbox);
-//
-// // restore
-// }
-//
-// @Override
-// public void fillPath(int windingRule) throws IOException
-// {
-// // bbox in user units
-// Shape bbox = getLinePath().getBounds2D();
-//
-// // draw path (note that getLinePath() is now reset)
-// //super.fillPath(windingRule);
-//
-// // save
-// Graphics2D graphics = getGraphics();
-//
-//
-// // draw
-// graphics.setClip(graphics.getDeviceConfiguration().getBounds());
-// graphics.setColor(POSCOLOR);
-// graphics.setStroke(new BasicStroke(.5f));
-// graphics.draw(bbox);
-//
-// }
-
-
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java
deleted file mode 100644
index 64e8fd17..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/positioning/PositioningRenderer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning;
-
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.pdfbox.rendering.PageDrawer;
-import org.apache.pdfbox.rendering.PageDrawerParameters;
-
-public class PositioningRenderer extends PDFRenderer{
-
- public PositioningRenderer(PDDocument document) {
- super(document);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- protected PageDrawer createPageDrawer(PageDrawerParameters params) throws IOException{
- return new PositioningPageDrawer(params);
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java
deleted file mode 100644
index 112d9a86..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/utils/PdfBoxUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.pdfbox2.utils;
-
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsValidationException;
-
-public class PdfBoxUtils {
- private static final Logger logger = LoggerFactory
- .getLogger(PdfBoxUtils.class);
-
- public static void checkPDFPermissions(PDDocument doc)
- throws PdfAsValidationException {
- AccessPermission accessPermission = doc.getCurrentAccessPermission();
- if (doc.isEncrypted() || !accessPermission.isOwnerPermission()) {
- //canFillInForm()
- //This will tell if the user can fill in interactive form fields (including signature fields) even if
- // canModifyAnnotations() returns false.
-
- //canModifyAnnotations()
- //This will tell if the user can add or modify text annotations and fill in interactive forms fields and, if
- // canModify() returns true, create or modify interactive form fields (including signature fields).
- if ((accessPermission.canModify() && accessPermission.canModifyAnnotations())
- || accessPermission.canFillInForm()) {
- logger.debug("Document is protected, but Signing is allowed");
-
- } else {
- throw new PdfAsValidationException("error.pdf.sig.12", null);
-
- }
- }
-
-
- }
-
- public static int countSignatures(PDDocument doc, String sigName) {
- int count = 0;
- COSDictionary trailer = doc.getDocument().getTrailer();
- COSDictionary root = (COSDictionary) trailer
- .getDictionaryObject(COSName.ROOT);
- COSDictionary acroForm = (COSDictionary) root
- .getDictionaryObject(COSName.ACRO_FORM);
- COSArray fields = (COSArray) acroForm
- .getDictionaryObject(COSName.FIELDS);
- for (int i = 0; i < fields.size(); i++) {
- COSDictionary field = (COSDictionary) fields.getObject(i);
- String type = field.getNameAsString("FT");
- if ("Sig".equals(type)) {
- String name = field.getString(COSName.T);
- if (name != null) {
- logger.debug("Found Sig: " + name);
- try {
- if (name.startsWith(sigName)) {
- String numberString = name.replace(sigName, "");
-
- logger.debug("Found Number: " + numberString);
-
- int SigIDX = Integer.parseInt(numberString);
- if (SigIDX > count) {
- count = SigIDX;
- }
- }
- } catch (Throwable e) {
- logger.info("Found a different Signature, we do not need to count this.");
- }
- }
- }
-
- }
-
- count++;
- logger.debug("Returning sig number: " + count);
- return count;
- }
-
-}
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
deleted file mode 100644
index db899ee8..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
+++ /dev/null
@@ -1,900 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.signing.pdfbox2;
-
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.security.Signature;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.activation.DataSource;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSInteger;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.common.COSObjectable;
-import org.apache.pdfbox.pdmodel.common.PDMetadata;
-import org.apache.pdfbox.pdmodel.common.PDNumberTreeNode;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
-import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot;
-import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions;
-import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
-import org.apache.pdfbox.pdmodel.interactive.form.PDField;
-import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
-import org.apache.pdfbox.preflight.PreflightDocument;
-import org.apache.pdfbox.preflight.ValidationResult;
-import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
-import org.apache.pdfbox.preflight.exception.ValidationException;
-import org.apache.pdfbox.preflight.parser.PreflightParser;
-import org.apache.pdfbox.rendering.ImageType;
-import org.apache.pdfbox.rendering.PDFRenderer;
-import org.apache.xmpbox.XMPMetadata;
-import org.apache.xmpbox.schema.PDFAIdentificationSchema;
-import org.apache.xmpbox.xml.DomXmpParser;
-
-import at.gv.egiz.pdfas.common.exceptions.PDFASError;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
-import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
-import at.gv.egiz.pdfas.common.messages.MessageResolver;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
-import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
-import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.pdfas.lib.impl.ErrorExtractor;
-import at.gv.egiz.pdfas.lib.impl.SignaturePositionImpl;
-import at.gv.egiz.pdfas.lib.impl.configuration.SignatureProfileConfiguration;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignaturePlaceholderExtractor;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning.Positioning;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.utils.PdfBoxUtils;
-import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderFilter;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-import at.gv.egiz.pdfas.lib.impl.signing.IPdfSigner;
-import at.gv.egiz.pdfas.lib.impl.signing.PDFASSignatureExtractor;
-import at.gv.egiz.pdfas.lib.impl.signing.PDFASSignatureInterface;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFStamper;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
-import at.gv.egiz.pdfas.lib.impl.stamping.TableFactory;
-import at.gv.egiz.pdfas.lib.impl.stamping.ValueResolver;
-import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PDFAsVisualSignatureProperties;
-import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PdfBoxVisualObject;
-import at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.StamperFactory;
-import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
-import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
-import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.table.Table;
-import iaik.x509.X509Certificate;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class PADESPDFBOXSigner implements IPdfSigner<PDFBOXObject, SignatureDataExtractor>, IConfigurationConstants {
-
-
-
- @Override
- public void signPDF(PDFBOXObject pdfObject, RequestedSignature requestedSignature,
- SignatureDataExtractor signer) throws PdfAsException {
-
-
- boolean isAdobeSigForm = false;
-
- PDDocument doc = null;
- SignatureOptions options = new SignatureOptions();
- try {
- doc = pdfObject.getDocument();
-
-
- // sign a PDF with an existing empty signature, as created by the
- // CreateEmptySignatureForm example.
- PDSignature signature = findExistingSignature(doc, getSignatureFieldNameConfig(pdfObject));
- if (signature == null) {
- // create signature dictionary
- signature = new PDSignature();
-
- } else {
- isAdobeSigForm = true;
-
- }
-
- // set basic signature parameters
- signature.setFilter(COSName.getPDFName(signer.getPDFFilter()));
- signature.setSubFilter(COSName.getPDFName(signer.getPDFSubFilter()));
- signature.setSignDate(Calendar.getInstance());
- log.debug("Signing @ " + signature.getSignDate().getTime().toString());
-
- // extract next QR-code placeholder, if exists
- SignaturePlaceholderData nextPlaceholderData = PlaceholderFilter.checkPlaceholderSignatureLocation(
- pdfObject.getStatus(), pdfObject.getStatus().getSettings(),
- pdfObject.getStatus().getSignParameter().getPlaceHolderId());
-
- if (nextPlaceholderData != null) {
- log.info("Placeholder data found. Injection placeholderId ...");
- SignaturePlaceholderExtractor.setPlaceholderId(signature, nextPlaceholderData.getPlaceholderName());
-
- if (nextPlaceholderData.getProfile() != null) {
- if (pdfObject.getStatus().getSettings().isValue(IConfigurationConstants.PLACEHOLDER_PROFILE_OVERWRITE, true)) {
- log.debug("Placeholder Profile set to: {}", nextPlaceholderData.getProfile());
- requestedSignature.setSignatureProfileID(nextPlaceholderData.getProfile());
-
- } else {
- log.debug("Placeholder profile over-write is disabled. Using profile from request ... ");
-
- }
- }
- }
-
-
- final SignatureProfileSettings signatureProfileSettings =
- TableFactory.createProfile(requestedSignature.getSignatureProfileID(), pdfObject.getStatus().getSettings());
-
- // set signature name
- final ValueResolver resolver = new ValueResolver(requestedSignature, pdfObject.getStatus());
- final String signerName = resolver.resolve("SIG_SUBJECT",
- signatureProfileSettings.getValue("SIG_SUBJECT"), signatureProfileSettings);
- signature.setName(signerName);
-
- // set signature reason
- String signerReason = signatureProfileSettings.getSigningReason() != null
- ? signatureProfileSettings.getSigningReason() : "PAdES Signature";
- signature.setReason(signerReason);
- log.debug("Signing reason: " + signerReason);
-
- signer.setPDSignature(signature);
-
-
- if (signatureProfileSettings.isPDFA() || signatureProfileSettings.isPDFA3()) {
- signatureProfileSettings.setPDFAVersion(getPDFAVersion(doc));
-
- }
-
- // prepare basic signature options
- options.setPreferredSignatureSize(calculateBlankAreaForSignature(signatureProfileSettings));
-
-
- PDFAsVisualSignatureProperties properties = null;
- if (requestedSignature.isVisual()) {
- log.info("Creating visual siganture block");
-
- final SignatureProfileConfiguration signatureProfileConfiguration =
- pdfObject.getStatus().getSignatureProfileConfiguration(requestedSignature.getSignatureProfileID());
- final TablePos tablePos = prepareTablePosition(nextPlaceholderData, signatureProfileConfiguration,
- pdfObject.getStatus().getSignParameter().getSignaturePosition());
- final Table main = TableFactory.createSigTable(signatureProfileSettings, MAIN, pdfObject.getStatus(),
- requestedSignature);
-
- final IPDFStamper stamper = StamperFactory.createDefaultStamper(pdfObject.getStatus().getSettings());
- final IPDFVisualObject visualObject = stamper.createVisualPDFObject(pdfObject, main);
-
- final PositioningInstruction positioningInstruction = Positioning.determineTablePositioning(tablePos,
- doc, visualObject, pdfObject.getStatus().getSettings(), signatureProfileSettings);
- log.debug("Positioning: {}", positioningInstruction.toString());
-
- if (!isAdobeSigForm) {
- if (positioningInstruction.isMakeNewPage()) {
- final int last = doc.getNumberOfPages() - 1;
- final PDDocumentCatalog root = doc.getDocumentCatalog();
- final PDPage lastPage = root.getPages().get(last);
- root.getPages().getCOSObject().setNeedToBeUpdated(true);
- final PDPage p = new PDPage(lastPage.getMediaBox());
- p.setResources(new PDResources());
- p.setRotation(lastPage.getRotation());
- doc.addPage(p);
- }
-
- // handle rotated page
- final int targetPageNumber = positioningInstruction.getPage();
- log.debug("Target Page: " + targetPageNumber);
- final PDPage targetPage = doc.getPages().get(targetPageNumber - 1);
- final int rot = targetPage.getRotation();
- log.debug("Page rotation: " + rot);
- log.debug("resulting Sign rotation: " + positioningInstruction.getRotation());
-
- final SignaturePositionImpl position = new SignaturePositionImpl();
- position.setX(positioningInstruction.getX());
- position.setY(positioningInstruction.getY());
- position.setPage(positioningInstruction.getPage());
- position.setHeight(visualObject.getHeight());
- position.setWidth(visualObject.getWidth());
- requestedSignature.setSignaturePosition(position);
- }
-
- properties = new PDFAsVisualSignatureProperties(pdfObject.getStatus().getSettings(), pdfObject,
- (PdfBoxVisualObject) visualObject, positioningInstruction, signatureProfileSettings, false);
- properties.buildSignature();
-
- if (signatureProfileSettings.isPDFA() || signatureProfileSettings.isPDFA3()) {
- final PDDocumentCatalog root = doc.getDocumentCatalog();
-
- InputStream colorProfile = null;
- // colorProfile = this.getClass().getResourceAsStream("/icm/sRGB.icm");
- colorProfile = this.getClass().getResourceAsStream("/icm/sRGB Color Space Profile.icm");
- // Set output intents for PDF/A conformity//
- try {
- final PDOutputIntent intent = new PDOutputIntent(doc, colorProfile);
-
- intent.setInfo("sRGB IEC61966-2.1");
- intent.setOutputCondition("sRGB IEC61966-2.1");
- intent.setOutputConditionIdentifier("sRGB IEC61966-2.1");
- intent.setRegistryName("http://www.color.org");
- final List<PDOutputIntent> oi = new ArrayList<>();
- oi.add(intent);
- root.setOutputIntents(oi);
- root.getCOSObject().setNeedToBeUpdated(true);
-
- log.info("added Output Intent");
- } catch (final Throwable e) {
- e.printStackTrace();
- throw new PdfAsException("Failed to add Output Intent", e);
-
- } finally {
- IOUtils.closeQuietly(colorProfile);
-
- }
- }
-
- options.setPage(positioningInstruction.getPage() - 1);
- options.setVisualSignature(properties.getVisibleSignature());
-
- }
-
- doc.addSignature(signature, signer, options);
-
- String sigFieldName = buildNextSignatureFieldName(doc, pdfObject);
-
- // this is not used for Adobe signature fields
- if (!isAdobeSigForm) {
- PDSignatureField signatureField = null;
- final PDAcroForm acroFormm = doc.getDocumentCatalog().getAcroForm();
- if (acroFormm != null) {
- @SuppressWarnings("unchecked")
- final List<PDField> fields = acroFormm.getFields();
-
- if (fields != null) {
- for (final PDField pdField : fields) {
- if (pdField != null) {
- if (pdField instanceof PDSignatureField) {
- final PDSignatureField tmpSigField = (PDSignatureField) pdField;
-
- if (tmpSigField.getSignature() != null
- && tmpSigField.getSignature().getCOSObject() != null) {
- if (tmpSigField.getSignature().getCOSObject()
- .equals(signature.getCOSObject())) {
- signatureField = (PDSignatureField) pdField;
-
- }
- }
- }
- }
- }
- } else {
- log.warn("Failed to name Signature Field! [Cannot find Field list in acroForm!]");
- }
-
- if (signatureField != null) {
- signatureField.setPartialName(sigFieldName);
- }
- if (properties != null) {
- signatureField.setAlternateFieldName(properties.getAlternativeTableCaption());
- } else {
- signatureField.setAlternateFieldName(sigFieldName);
- }
- } else {
- log.warn("Failed to name Signature Field! [Cannot find acroForm!]");
-
- }
- }
-
- PDSignatureField signatureField = null;
- final PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
- if (acroForm != null) {
- signatureField = (PDSignatureField) acroForm.getField(sigFieldName);
-
- }
-
-
- injectPdfUaContent(doc, signatureField, sigFieldName, signatureProfileSettings);
-
- performTechnicalSignature(doc, pdfObject, signatureProfileSettings);
-
-
- log.debug("Signature done!");
-
- } catch (final IOException e) {
- log.warn(MessageResolver.resolveMessage("error.pdf.sig.01"), e);
- throw new PdfAsException("error.pdf.sig.01", e);
-
- } catch (PDFASError e2) {
- log.warn(e2.getInfo());
- throw new PdfAsException("error.pdf.sig.01", e2);
-
- } finally {
- if (options != null) {
- if (options.getVisualSignature() != null) {
- try {
- options.getVisualSignature().close();
- options.close();
- } catch (IOException e) {
- log.debug("Failed to close VisualSignature!", e);
- }
- }
- }
-
- if (doc != null) {
- try {
- doc.close();
- // SignaturePlaceholderExtractor.getPlaceholders().clear();
- } catch (final IOException e) {
- log.debug("Failed to close COS Doc!", e);
- // Ignore
- }
- }
- }
- }
-
- private void performTechnicalSignature(PDDocument doc, PDFBOXObject pdfObject,
- SignatureProfileSettings signatureProfileSettings) throws PdfAsException {
- try {
- final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- synchronized (doc) {
- doc.saveIncremental(bos);
- final byte[] outputDocument = bos.toByteArray();
- pdfObject.setSignedDocument(outputDocument);
- }
- /* Check if resulting pdf is PDF-A conform */
- if (signatureProfileSettings.isPDFA()) {
- runPDFAPreflight(new ByteArrayDataSource(pdfObject.getSignedDocument()));
- }
-
- } catch (PdfAsWrappedIOException e) {
- logPdfUpdateError(e.getDecoratedException());
- throw e.getDecoratedException();
-
- } catch (final IOException e) {
- logPdfUpdateError(e);
- throw new PdfAsException("error.pdf.sig.06", e);
-
- }
-
- System.gc();
-
- }
-
- private void logPdfUpdateError(Throwable e) {
- if (e instanceof SLPdfAsException && !((SLPdfAsException) e).isCriticalError()) {
- log.info("Can not save incremental update", e);
-
- } else {
- log.error("Can not save incremental update", e);
-
- }
- }
-
- private void injectPdfUaContent(PDDocument doc, PDSignatureField signatureField, String sigFieldName,
- SignatureProfileSettings signatureProfileSettings) throws PdfAsException {
- try {
- log.info("Adding pdf/ua content .... ");
- final PDDocumentCatalog root = doc.getDocumentCatalog();
- final PDStructureTreeRoot structureTreeRoot = root.getStructureTreeRoot();
- if (structureTreeRoot != null) {
- log.debug("Tree Root: {}", structureTreeRoot.toString());
- final List<Object> kids = structureTreeRoot.getKids();
-
- if (kids == null || kids.isEmpty()) {
- log.info("No kid-elements in structure tree Root, maybe not PDF/UA document. Skipping PDF/UA injection ... ");
- return;
-
- }
-
- PDStructureElement docElement = null;
- for (final Object k : kids) {
- if (k instanceof PDStructureElement) {
- docElement = (PDStructureElement) k;
- break;
-
- }
- }
-
- final PDStructureElement sigBlock = new PDStructureElement("Form", docElement);
-
- // create object dictionary and add as child element
- final COSDictionary objectDic = new COSDictionary();
- objectDic.setName("Type", "OBJR");
-
- objectDic.setItem("Pg", signatureField.getWidgets().get(0).getPage());
- objectDic.setItem("Obj", signatureField.getWidgets().get(0));
-
- final List<Object> l = new ArrayList<>();
- l.add(objectDic);
- sigBlock.setKids(l);
- sigBlock.setPage(signatureField.getWidgets().get(0).getPage());
-
- sigBlock.setTitle("Signature Table");
- sigBlock.setParent(docElement);
- docElement.appendKid(sigBlock);
-
- // Create and add Attribute dictionary to mitigate PAC
- // warning
- final COSDictionary sigBlockDic = sigBlock.getCOSObject();
- final COSDictionary sub = new COSDictionary();
-
- sub.setName("O", "Layout");
- sub.setName("Placement", "Block");
- sigBlockDic.setItem(COSName.A, sub);
- sigBlockDic.setNeedToBeUpdated(true);
-
- // Modify number tree
- PDNumberTreeNode ntn = structureTreeRoot.getParentTree();
- if (ntn == null) {
- ntn = new PDNumberTreeNode(objectDic, null);
- log.info("No number-tree-node found!");
- }
-
- final COSArray ntnKids = (COSArray) ntn.getCOSObject().getDictionaryObject(COSName.KIDS);
- final COSArray ntnNumbers = (COSArray) ntn.getCOSObject().getDictionaryObject(COSName.NUMS);
-
- final int parentTreeNextKey = getParentTreeNextKey(structureTreeRoot);
-
- if (ntnNumbers == null && ntnKids != null) {// no number array, so continue with the kids array
- // create dictionary with limits and nums array
- final COSDictionary pTreeEntry = new COSDictionary();
- final COSArray limitsArray = new COSArray();
- // limits for exact one entry
- limitsArray.add(COSInteger.get(parentTreeNextKey));
- limitsArray.add(COSInteger.get(parentTreeNextKey));
-
- final COSArray numsArray = new COSArray();
- numsArray.add(COSInteger.get(parentTreeNextKey));
- numsArray.add(sigBlock);
-
- pTreeEntry.setItem(COSName.NUMS, numsArray);
- pTreeEntry.setItem(COSName.LIMITS, limitsArray);
-
- final PDNumberTreeNode newKidsElement = new PDNumberTreeNode(pTreeEntry, PDNumberTreeNode.class);
-
- ntnKids.add(newKidsElement);
- ntnKids.setNeedToBeUpdated(true);
-
- } else if (ntnNumbers != null && ntnKids == null) {
-
- final int arrindex = ntnNumbers.size();
-
- ntnNumbers.add(arrindex, COSInteger.get(parentTreeNextKey));
- ntnNumbers.add(arrindex + 1, sigBlock.getCOSObject());
-
- ntnNumbers.setNeedToBeUpdated(true);
-
- structureTreeRoot.setParentTree(ntn);
-
- } else if (ntnNumbers == null && ntnKids == null) {
- // document is not pdfua conform before signature creation
- throw new PdfAsException("error.pdf.sig.pdfua.1");
- } else {
- // this is not allowed
- throw new PdfAsException("error.pdf.sig.pdfua.1");
- }
-
- // set StructureParent for signature field annotation
- signatureField.getWidgets().get(0).setStructParent(parentTreeNextKey);
-
- // Increase the next Key value in the structure tree root
- structureTreeRoot.setParentTreeNextKey(parentTreeNextKey + 1);
-
- // add the Tabs /S Element for Tabbing through annots
- final PDPage p = signatureField.getWidgets().get(0).getPage();
- p.getCOSObject().setName("Tabs", "S");
- p.getCOSObject().setNeedToBeUpdated(true);
-
- // check alternative signature field name
- if (signatureField != null) {
- if (signatureField.getAlternateFieldName().equals("")) {
- signatureField.setAlternateFieldName(sigFieldName);
- }
- }
-
- ntn.getCOSObject().setNeedToBeUpdated(true);
- sigBlock.getCOSObject().setNeedToBeUpdated(true);
- structureTreeRoot.getCOSObject().setNeedToBeUpdated(true);
- objectDic.setNeedToBeUpdated(true);
- docElement.getCOSObject().setNeedToBeUpdated(true);
- }
- } catch (final Throwable e) {
- if (signatureProfileSettings.isPDFUA()) {
- log.error("Could not create PDF-UA conform document!");
- throw new PdfAsException("error.pdf.sig.pdfua.1", e);
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Could not create PDF-UA conform signature. Reason: {}", e.getMessage(), e);
-
- } else {
- log.info("Could not create PDF-UA conform signature. Reason: {}", e.getMessage());
- }
- }
- }
-
- }
-
- private String buildNextSignatureFieldName(PDDocument doc, PDFBOXObject pdfObject) {
- String sigFieldName = getSignatureFieldNameConfig(pdfObject);
- if (sigFieldName == null) {
- sigFieldName = "PDF-AS Signatur";
-
- }
- return sigFieldName + PdfBoxUtils.countSignatures(doc, sigFieldName);
-
- }
-
- private int calculateBlankAreaForSignature(SignatureProfileSettings signatureProfileSettings) {
- int signatureSize = 0x1000;
- try {
- final String reservedSignatureSizeString = signatureProfileSettings.getValue(SIG_RESERVED_SIZE);
- if (reservedSignatureSizeString != null) {
- signatureSize = Integer.parseInt(reservedSignatureSizeString);
- }
- log.debug("Reserving {} bytes for signature", signatureSize);
-
- } catch (final NumberFormatException e) {
- log.warn("Invalid configuration value: {} should be a number using 0x1000", SIG_RESERVED_SIZE);
-
- }
-
- return signatureSize;
- }
-
- private TablePos prepareTablePosition(SignaturePlaceholderData nextPlaceholderData,
- SignatureProfileConfiguration signatureProfileConfiguration, String profilePosParam) throws PdfAsException {
-
-
- if (nextPlaceholderData != null && nextPlaceholderData.getTablePos() != null) {
- final float minWidth = signatureProfileConfiguration.getMinWidth();
- TablePos tablePos = nextPlaceholderData.getTablePos();
- if (minWidth > 0) {
- if (tablePos.getWidth() < minWidth) {
- tablePos.setWidth(minWidth);
- log.debug("Correcting placeholder with to minimum width {}", minWidth);
- }
- }
- log.debug("Placeholder Position set to: " + tablePos.toString());
- return tablePos;
-
- } else {
- TablePos defaultSignaturePos = null;
- final String defaultPosString = signatureProfileConfiguration.getDefaultPositioning();
-
-
- if (defaultPosString != null) {
- log.debug("Default signature positioning is: {}", defaultPosString);
- defaultSignaturePos = new TablePos(defaultPosString);
-
- }
-
- if (profilePosParam != null) {
- log.debug("Find positioning parameter: {} Merge it with default ...", profilePosParam);
- // Merge Signature Position
- return new TablePos(profilePosParam, defaultSignaturePos);
-
- } else if (defaultSignaturePos != null){
- // Fallback to signature Position!
- return defaultSignaturePos;
-
- } else {
- return new TablePos();
-
- }
- }
- }
-
- private String getSignatureFieldNameConfig(PDFBOXObject pdfObject) {
- return pdfObject.getStatus().getSettings().getValue(SIGNATURE_FIELD_NAME);
- }
-
- private int getParentTreeNextKey(PDStructureTreeRoot structureTreeRoot) throws IOException {
- int nextKey = structureTreeRoot.getParentTreeNextKey();
- if (nextKey < 0) {
- final Map<Integer, COSObjectable> destNumberTreeAsMap = getNumberTreeAsMap(structureTreeRoot
- .getParentTree());
- if (destNumberTreeAsMap.isEmpty()) {
- nextKey = 0;
-
- } else {
- nextKey = Collections.max(destNumberTreeAsMap.keySet()) + 1;
-
- }
- }
-
- return nextKey;
- }
-
- /**
- * Check via PreFlightParser if PDF-Document is a valid PDFA1
- *
- * @param signedDocument: signed Document
- * @throws PdfAsException
- */
- private void runPDFAPreflight(final DataSource signedDocument) throws PdfAsException {
- PreflightDocument document = null;
- ValidationResult result = null;
- try {
- final PreflightParser parser = new PreflightParser(new javax.activation.DataSource() {
- @Override public InputStream getInputStream() throws IOException { return signedDocument.getInputStream(); }
- @Override public OutputStream getOutputStream() throws IOException { return signedDocument.getOutputStream(); }
- @Override public String getContentType() { return signedDocument.getContentType(); }
- @Override public String getName() { return signedDocument.getName(); }
- });
- //
- // parser.parse(Format.PDF_A1B);
- parser.parse();
- document = parser.getPreflightDocument();
- document.validate();
-
- document.close();
- result = document.getResult();
- log.info("PDF-A Validation Result: " + result.isValid());
-
- if (result.getErrorsList().size() > 0) {
- log.error("The following validation errors occured for PDF-A validation");
- }
-
- for (final ValidationResult.ValidationError ve : result.getErrorsList()) {
- log.error("\t" + ve.getErrorCode() + ": " + ve.getDetails());
- }
-
- if (!result.isValid()) {
- log.info("The file is not a valid PDF-A document");
- }
-
- } catch (final SyntaxValidationException e) {
- log.error("The file is syntactically invalid.", e);
- throw new PdfAsException("Resulting PDF Document is syntactically invalid.");
- } catch (final ValidationException e) {
- log.error("The file is not a valid PDF-A document.", e);
- } catch (final IOException e) {
- log.error("An IOException (" + e.getMessage()
- + ") occurred, while validating the PDF-A conformance", e);
- throw new PdfAsException("Failed validating PDF Document IOException.");
- } catch (final RuntimeException e) {
- log.debug("An RuntimeException (" + e.getMessage()
- + ") occurred, while validating the PDF-A conformance", e);
- throw new PdfAsException("Failed validating PDF Document RuntimeException.");
- } finally {
- if (document != null) {
- IOUtils.closeQuietly(document);
- }
- }
- }
-
- @Override
- public PDFBOXObject buildPDFObject(OperationStatus operationStatus) {
- return new PDFBOXObject(operationStatus);
- }
-
- @Override
- public SignatureDataExtractor buildBlindSignaturInterface(X509Certificate certificate, String filter,
- String subfilter, Calendar date) {
- return new SignatureDataExtractor(certificate, filter, subfilter, date);
- }
-
- @Override
- public void checkPDFPermissions(PDFBOXObject pdfObject) throws PdfAsException {
- PdfBoxUtils.checkPDFPermissions(pdfObject.getDocument());
- }
-
- @Override
- public byte[] rewritePlainSignature(byte[] plainSignature) {
- final String signature = new COSString(plainSignature).toHexString();
- final byte[] pdfSignature = signature.getBytes();
- return pdfSignature;
- }
-
- @Override
- public Image generateVisibleSignaturePreview(SignParameter parameter,
- java.security.cert.X509Certificate cert,
- int resolution, OperationStatus status, RequestedSignature requestedSignature) throws PDFASError {
- try {
-
- final PDFBOXObject pdfObject = (PDFBOXObject)(PDFBOXObject) status.getPdfObject();
- final PDDocument origDoc = new PDDocument();
-
- origDoc.addPage(new PDPage(PDRectangle.A4));
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- origDoc.save(baos);
- baos.close();
-
- pdfObject.setOriginalDocument(new ByteArrayDataSource(baos.toByteArray()));
-
- final SignatureProfileSettings signatureProfileSettings = TableFactory
- .createProfile(requestedSignature.getSignatureProfileID(), pdfObject.getStatus().getSettings());
-
- // create Table describtion
- final Table main = TableFactory.createSigTable(signatureProfileSettings, MAIN, pdfObject.getStatus(),
- requestedSignature);
-
- final IPDFStamper stamper = StamperFactory.createDefaultStamper(pdfObject.getStatus().getSettings());
-
- final IPDFVisualObject visualObject = stamper.createVisualPDFObject(pdfObject, main);
-
- final SignatureProfileConfiguration signatureProfileConfiguration = pdfObject.getStatus()
- .getSignatureProfileConfiguration(requestedSignature.getSignatureProfileID());
-
- final String signaturePosString = signatureProfileConfiguration.getDefaultPositioning();
- PositioningInstruction positioningInstruction;
- if (signaturePosString != null) {
- positioningInstruction = Positioning.determineTablePositioning(new TablePos(signaturePosString),
- origDoc, visualObject, pdfObject.getStatus().getSettings(), signatureProfileSettings);
- } else {
- positioningInstruction = Positioning.determineTablePositioning(new TablePos(), origDoc,
- visualObject, pdfObject.getStatus().getSettings(), signatureProfileSettings);
- }
-
- origDoc.close();
-
- final SignaturePositionImpl position = new SignaturePositionImpl();
- position.setX(positioningInstruction.getX());
- position.setY(positioningInstruction.getY());
- position.setPage(positioningInstruction.getPage());
- position.setHeight(visualObject.getHeight());
- position.setWidth(visualObject.getWidth());
-
- requestedSignature.setSignaturePosition(position);
-
- final PDFAsVisualSignatureProperties properties = new PDFAsVisualSignatureProperties(
- pdfObject.getStatus().getSettings(), pdfObject, (PdfBoxVisualObject) visualObject,
- positioningInstruction, signatureProfileSettings, true);
-
- // build visual-signature form
- properties.buildSignature();
-
- PDDocument visualDoc;
- synchronized (PDDocument.class) {
- visualDoc = PDDocument.load(properties.getVisibleSignature());
- }
-
- final float stdRes = 72;
- final float targetRes = resolution;
- final float factor = targetRes / stdRes;
-
- final int targetPageNumber = 0;// TODO: is this always the case
- PDFRenderer pdfRenderer = new PDFRenderer(visualDoc);
- final BufferedImage outputImage = pdfRenderer.renderImageWithDPI(targetPageNumber, targetRes,
- ImageType.ARGB);
-
- visualDoc.close();
- pdfRenderer = null;
-
- final BufferedImage cutOut = new BufferedImage(
- (int) (position.getWidth() * factor),
- (int) (position.getHeight() * factor),
- BufferedImage.TYPE_4BYTE_ABGR);
-
- final Graphics2D graphics = (Graphics2D) cutOut.getGraphics();
-
- graphics.drawImage(outputImage, 0, 0, cutOut.getWidth(), cutOut.getHeight(),
- (int) (0 * factor),
- (int) (outputImage.getHeight() - (position.getHeight() + 1) * factor),
- (int) ((position.getWidth() + 2) * factor),
- (int) (outputImage.getHeight() - (position.getHeight()) * factor + position.getHeight() * factor),
- null);
- return cutOut;
-
- } catch (final PdfAsException e) {
- log.warn("PDF-AS Exception", e);
- throw ErrorExtractor.searchPdfAsError(e, status);
- } catch (final Throwable e) {
- log.warn("Unexpected Throwable Exception", e);
- throw ErrorExtractor.searchPdfAsError(e, status);
- }
- }
-
- private String getPDFAVersion(PDDocument doc) {
- try {
- final PDDocumentCatalog cat = doc.getDocumentCatalog();
- final PDMetadata metadata = cat.getMetadata();
-
- if (metadata != null) {
- final DomXmpParser xmpParser = new DomXmpParser();
- final XMPMetadata xmpMetadata = xmpParser.parse(metadata.exportXMPMetadata());
- if (xmpMetadata != null) {
- final PDFAIdentificationSchema pdfaIdentificationSchema = xmpMetadata.getPDFIdentificationSchema();
- if (pdfaIdentificationSchema != null) {
- final Integer pdfaversion = pdfaIdentificationSchema.getPart();
- final String conformance = pdfaIdentificationSchema.getConformance();
- log.info("Detected PDF/A Version: {} - {}", pdfaversion, conformance);
-
- if (pdfaversion != null) {
- return String.valueOf(pdfaversion);
- }
- }
- }
- }
- } catch (final Throwable e) {
- log.warn("Failed to determine PDF/A Version!", e);
- }
- return null;
- }
-
- // Find an existing signature.
- private PDSignature findExistingSignature(PDDocument doc, String sigFieldName) {
- PDSignature signature = null;
- PDSignatureField signatureField;
- final PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
- if (acroForm != null) {
- signatureField = (PDSignatureField) acroForm.getField(sigFieldName);
- if (signatureField != null) {
- // retrieve signature dictionary
- signature = signatureField.getSignature();
- if (signature == null) {
- signature = new PDSignature();
- signatureField.getCOSObject().setItem(COSName.V, signature);
- } else {
- throw new IllegalStateException("The signature field " + sigFieldName + " is already signed.");
- }
- }
- }
- return signature;
-
- }
-
- static Map<Integer, COSObjectable> getNumberTreeAsMap(PDNumberTreeNode tree)
- throws IOException {
- Map<Integer, COSObjectable> numbers = tree.getNumbers();
- if (numbers == null) {
- numbers = new LinkedHashMap<>();
- } else {
- // must copy because the map is read only
- numbers = new LinkedHashMap<>(numbers);
- }
- final List<PDNumberTreeNode> kids = tree.getKids();
- if (kids != null) {
- for (final PDNumberTreeNode kid : kids) {
- numbers.putAll(getNumberTreeAsMap(kid));
- }
- }
- return numbers;
- }
-
-} \ No newline at end of file
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/SignatureDataExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/SignatureDataExtractor.java
deleted file mode 100644
index 41ff38aa..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/SignatureDataExtractor.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.signing.pdfbox2;
-
-import at.gv.egiz.pdfas.lib.impl.signing.PDFASSignatureExtractor;
-import at.gv.egiz.pdfas.lib.impl.signing.PDFASSignatureInterface;
-import iaik.x509.X509Certificate;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.SignatureException;
-import java.util.Calendar;
-
-import lombok.Getter;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-
-import at.gv.egiz.pdfas.common.utils.StreamUtils;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface;
-
-public class SignatureDataExtractor implements PDFASSignatureExtractor, PDFASSignatureInterface, SignatureInterface {
-
- @Getter
- protected X509Certificate certificate;
- @Getter
- protected byte[] signatureData;
-
- protected String pdfSubFilter;
- protected String pdfFilter;
- @Getter
- protected int[] byteRange;
- protected Calendar date;
-
- public SignatureDataExtractor(X509Certificate certificate,
- String filter, String subfilter, Calendar date) {
- this.certificate = certificate;
- this.pdfFilter = filter;
- this.pdfSubFilter = subfilter;
- this.date = date;
- }
-
- public String getPDFSubFilter() {
- return this.pdfSubFilter;
- }
-
- public String getPDFFilter() {
- return this.pdfFilter;
- }
-
- /** Called by PDFBox.
- * We save the data to be signed and return an all-zeros signature (padded by pdfbox).
- * We splice the actual signature in at a later point.
- */
- public byte[] sign(InputStream content) throws IOException {
- this.signatureData = StreamUtils.inputStreamToByteArray(content);
- return new byte[] { 0 };
- }
-
- public void setPDSignature(PDSignature signature) {
- this.byteRange = signature.getByteRange();
- }
-
- public Calendar getSigningDate() {
- return this.date;
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/FontInfoCache.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/FontInfoCache.java
deleted file mode 100644
index c208820e..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/FontInfoCache.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-public class FontInfoCache {
- String filename;
- String fontName;
- String fontFamily;
- String fontPath;
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/IDGenerator.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/IDGenerator.java
deleted file mode 100644
index ef898d74..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/IDGenerator.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-public interface IDGenerator {
- public String createHashedId(String value);
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/ImageObject.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/ImageObject.java
deleted file mode 100644
index 16af5cfb..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/ImageObject.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-
-
-public class ImageObject {
- private PDImageXObject image;
- private float width;
- private float height;
-
- public ImageObject(PDImageXObject image, float width, float height) {
- this.image = image;
- this.width = width;
- this.height = height;
- }
-
- public PDImageXObject getImage() {
- return image;
- }
-
- public void setImage(PDImageXObject image) {
- this.image = image;
- }
-
- public float getWidth() {
- return width;
- }
-
- public void setWidth(float width) {
- this.width = width;
- }
-
- public float getHeight() {
- return height;
- }
-
- public void setHeight(float height) {
- this.height = height;
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsFontCache.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsFontCache.java
deleted file mode 100644
index 97dcf551..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsFontCache.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.font.PDType1Font;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PDFAsFontCache {
-
- private static final Logger logger = LoggerFactory
- .getLogger(PDFAsFontCache.class);
-
- private static final String HELVETICA = "HELVETICA";
- private static final String COURIER = "COURIER";
- private static final String TIMES_ROMAN = "TIMES_ROMAN";
- private static final String BOLD = "BOLD";
- private static final String NORMAL = "NORMAL";
- private static final String ITALIC = "ITALIC";
- private static final String SEP = ":";
-
- public static PDFont defaultFont = PDType1Font.HELVETICA;
- public static float defaultFontSize = 8;
-
- private Map<String, PDFont> fonts;
-
- private static Map<String, PDFont> defaultFonts = new HashMap<String, PDFont>();
- static {
- defaultFonts.put(HELVETICA + SEP + NORMAL, PDType1Font.HELVETICA);
- defaultFonts.put(HELVETICA + SEP + BOLD, PDType1Font.HELVETICA_BOLD);
-
- defaultFonts.put(COURIER + SEP + NORMAL, PDType1Font.COURIER);
- defaultFonts.put(COURIER + SEP + BOLD, PDType1Font.COURIER_BOLD);
-
- defaultFonts.put(TIMES_ROMAN + SEP + NORMAL, PDType1Font.TIMES_ROMAN);
- defaultFonts.put(TIMES_ROMAN + SEP + BOLD, PDType1Font.TIMES_BOLD);
- defaultFonts.put(TIMES_ROMAN + SEP + ITALIC, PDType1Font.TIMES_ITALIC);
- }
-
- public PDFAsFontCache(){
- fonts = new HashMap<String, PDFont>(defaultFonts);
- }
-
- public boolean contains(String fontPath) {
- return fonts.containsKey(fontPath);
- }
-
- public void addFont(String fontPath, PDFont font) {
- fonts.put(fontPath, font);
- }
-
- public PDFont getFont(String fontPath) {
- return fonts.get(fontPath);
- }
-
- public void showAvailableFonts() {
- Iterator<String> it = fonts.keySet().iterator();
- logger.info("Available Fonts:");
- while (it.hasNext()) {
- logger.info(it.next());
- }
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsTemplateCreator.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsTemplateCreator.java
deleted file mode 100644
index 62ad4dbf..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsTemplateCreator.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDFTemplateCreator;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDFTemplateStructure;
-import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
-import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-
-public class PDFAsTemplateCreator extends PDFTemplateCreator {
-
- PDFAsVisualSignatureBuilder pdfBuilder;
- private static final Logger logger = LoggerFactory.getLogger(PDFAsTemplateCreator.class);
-
- public PDFAsTemplateCreator(PDFAsVisualSignatureBuilder bookBuilder) {
- super(bookBuilder);
- this.pdfBuilder = bookBuilder;
- }
-
-
- public InputStream buildPDF(PDFAsVisualSignatureDesigner properties, PDDocument originalDocument, boolean buildPreviewOnly)
- throws IOException, PdfAsException {
- logger.debug("pdf building has been started");
- PDFTemplateStructure pdfStructure = pdfBuilder.getStructure();
-
- // we create array of [Text, ImageB, ImageC, ImageI]
- this.pdfBuilder.createProcSetArray();
-
- //create page
- this.pdfBuilder.createPage(properties);
- PDPage page = pdfStructure.getPage();
-
- //create template
- this.pdfBuilder.createTemplate(page);
- PDDocument template = pdfStructure.getTemplate();
-
- //create /AcroForm
- this.pdfBuilder.createAcroForm(template);
- PDAcroForm acroForm = pdfStructure.getAcroForm();
-
- // AcroForm contains singature fields
- this.pdfBuilder.createSignatureField(acroForm);
- PDSignatureField pdSignatureField = pdfStructure.getSignatureField();
-
- // create signature
- this.pdfBuilder.createSignature(pdSignatureField, page, properties.getSignatureFieldName());
-
- // that is /AcroForm/DR entry
- this.pdfBuilder.createAcroFormDictionary(acroForm, pdSignatureField);
-
- // create AffineTransform
- this.pdfBuilder.createAffineTransform(properties.getAffineTransformParams());
- //AffineTransform transform = pdfStructure.getAffineTransform();
-
- // rectangle, formatter, image. /AcroForm/DR/XObject contains that form
- this.pdfBuilder.createSignatureRectangle(pdSignatureField, properties, properties.getRotation() + properties.getPageRotation());
- this.pdfBuilder.createFormaterRectangle(properties.getFormaterRectangleParams());
- PDRectangle formater = pdfStructure.getFormatterRectangle();
-
-
-
- //this.pdfBuilder.createSignatureImage(template, properties.getImageStream());
-
- // create form stream, form and resource.
- this.pdfBuilder.createHolderFormStream(template);
- PDStream holderFormStream = pdfStructure.getHolderFormStream();
- this.pdfBuilder.createHolderFormResources();
- PDResources holderFormResources = pdfStructure.getHolderFormResources();
- this.pdfBuilder.createHolderForm(holderFormResources, holderFormStream, formater);
-
- // that is /AP entry the appearance dictionary.
- this.pdfBuilder.createAppearanceDictionary(pdfStructure.getHolderForm(), pdSignatureField,
- properties.getRotation() + properties.getPageRotation());
-
- // inner formstream, form and resource (hlder form containts inner form)
- this.pdfBuilder.createInnerFormStreamPdfAs(template, originalDocument);
-
- this.pdfBuilder.createInnerFormResource();
- PDResources innerFormResource = pdfStructure.getInnerFormResources();
-
- this.pdfBuilder.createInnerForm(innerFormResource, pdfStructure.getInnerFormStream(), formater);
- PDFormXObject innerForm = pdfStructure.getInnerForm();
-
- // inner form must be in the holder form as we wrote
- this.pdfBuilder.insertInnerFormToHolerResources(innerForm, holderFormResources);
-
- // Image form is in this structure: /AcroForm/DR/FRM0/Resources/XObject/n0
- //this.pdfBuilder.createImageFormStream(template);
- //PDStream imageFormStream = pdfStructure.getImageFormStream();
- //this.pdfBuilder.createImageFormResources();
- //PDResources imageFormResources = pdfStructure.getImageFormResources();
- //this.pdfBuilder.createImageForm(imageFormResources, innerFormResource, imageFormStream, formater, transform,
- // pdfStructure.getJpedImage());
-
- // now inject procSetArray
- /*this.pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources, holderFormResources,
- pdfStructure.getProcSet());*/
-
- this.pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, null, holderFormResources,
- pdfStructure.getProcSet());
-
- /*String imgFormName = pdfStructure.getImageFormName();
- String imgName = pdfStructure.getImageName();*/
- String innerFormName = pdfStructure.getInnerFormName().getName();
-
- // now create Streams of AP
- /*this.pdfBuilder.injectAppearanceStreams(holderFormStream, imageFormStream, imageFormStream, imgFormName,
- imgName, innerFormName, properties);*/
-
- if (!buildPreviewOnly) {
- this.pdfBuilder.injectAppearanceStreams(holderFormStream, null, null, null,
- null, innerFormName, properties);
-
- }
-
- this.pdfBuilder.createVisualSignature(template);
- this.pdfBuilder.createWidgetDictionary(pdSignatureField, holderFormResources);
-
- ByteArrayInputStream in = null;
-
- //COSDocument doc = pdfStructure.getVisualSignature();
- //doc.
- //in = pdfStructure.getTemplateAppearanceStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- template.save(baos);
- baos.close();
-
- SignatureProfileSettings signatureProfileSettings =
- this.pdfBuilder.signatureProfileSettings;
-
- boolean requirePDFA3 = signatureProfileSettings.isPDFA3();
-
- if(requirePDFA3) {
-
- //FileOutputStream fos = new FileOutputStream("/tmp/signature.pdf");
- //fos.write(baos.toByteArray());
- //fos.close();
-
- PDDocument cidSetRemoved = PDDocument.load(baos.toByteArray());
- try {
- this.pdfBuilder.removeCidSet(cidSetRemoved);
- baos.reset();
- baos = new ByteArrayOutputStream();
- cidSetRemoved.save(baos);
- baos.close();
- } finally {
- cidSetRemoved.close();
- }
- }
-
- in = new ByteArrayInputStream(baos.toByteArray());
-
-
- logger.debug("stream returning started, size= " + in.available());
-
- // we must close the document
- this.pdfBuilder.closeTemplate(template);
-
- // return result of the stream
- return in;
- }
-
-// @SneakyThrows
-// private void saveDebuggingSnapshot(PDDocument template, String fileName) {
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// template.save(baos);
-// baos.close();
-//
-// FileOutputStream fos = new FileOutputStream("/home/tlenz/Projekte/pdfas4/source/pdf-as-cli/build/" + fileName + ".pdf");
-// fos.write(baos.toByteArray());
-// fos.close();
-//
-// }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java
deleted file mode 100644
index f1b735be..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDPageContentStream;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.font.PDType0Font;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory;
-import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigBuilder;
-import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
-import org.apache.pdfbox.pdmodel.interactive.form.PDField;
-import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.common.utils.ImageUtils;
-import at.knowcenter.wag.egov.egiz.table.Entry;
-
-public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder implements
- IDGenerator {
-
- private static final Logger logger = LoggerFactory
- .getLogger(PDFAsVisualSignatureBuilder.class);
-
- private PDFAsVisualSignatureProperties properties;
- private PDFAsVisualSignatureDesigner designer;
- private ISettings settings;
- public SignatureProfileSettings signatureProfileSettings;
- private PDResources innerFormResources;
- private Map<String, ImageObject> images = new HashMap<String, ImageObject>();
-
- public PDFAsVisualSignatureBuilder(
- PDFAsVisualSignatureProperties properties, ISettings settings,
- PDFAsVisualSignatureDesigner designer,
- SignatureProfileSettings signatureProfileSettings) {
- this.properties = properties;
- this.settings = settings;
- this.designer = designer;
- this.signatureProfileSettings = signatureProfileSettings;
- }
-
- @Override
- public void createProcSetArray() {
- COSArray procSetArr = new COSArray();
- procSetArr.add(COSName.getPDFName("PDF"));
- procSetArr.add(COSName.getPDFName("Text"));
- procSetArr.add(COSName.getPDFName("ImageC"));
- procSetArr.add(COSName.getPDFName("ImageB"));
- procSetArr.add(COSName.getPDFName("ImageI"));
- getStructure().setProcSet(procSetArr);
- logger.debug("ProcSet array has been created");
- }
-
- public void createMyPage(PDFAsVisualSignatureDesigner properties) {
- PDPage page = properties.getSignaturePage();
- if (page == null) {
- page = new PDPage();
- page.setMediaBox(new PDRectangle(properties.getPageWidth(),
- properties.getPageHeight()));
-
- }
- getStructure().setPage(page);
- logger.info("PDF page has been created");
- }
-
- @Override
- public void createTemplate(PDPage page) throws IOException {
- PDDocument template = new PDDocument();
-
- template.addPage(page);
- getStructure().setTemplate(template);
- }
-
- public String createHashedId(String value) {
- try {
- MessageDigest md = MessageDigest.getInstance("SHA-256");
- md.reset();
- return Hex.encodeHexString(md.digest(value.getBytes(StandardCharsets.UTF_8)));
- } catch (Throwable e) {
- logger.warn("Failed to generate ID for Image using value", e);
- return value;
- }
- }
-
- private void readTableResources(PDFBoxTable table, PDDocument template)
- throws PdfAsException, IOException {
-
- float[] colsSizes = table.getColsRelativeWith();
- int max_cols = table.getColCount();
- float padding = table.getPadding();
- if (colsSizes == null) {
- colsSizes = new float[max_cols];
- // set the column ratio for all columns to 1
- for (int cols_idx = 0; cols_idx < colsSizes.length; cols_idx++) {
- colsSizes[cols_idx] = 1;
- }
- }
-
- logger.debug("TOTAL Width: " + table.getWidth());
-
- float total = 0;
-
- for (int cols_idx = 0; cols_idx < colsSizes.length; cols_idx++) {
- total += colsSizes[cols_idx];
- }
-
- for (int cols_idx = 0; cols_idx < colsSizes.length; cols_idx++) {
- colsSizes[cols_idx] = (colsSizes[cols_idx] / total)
- * table.getWidth();
- }
-
- for (int cols_idx = 0; cols_idx < colsSizes.length; cols_idx++) {
- logger.debug("Col: " + cols_idx + " : " + colsSizes[cols_idx]);
- }
-
- /*
- * if(!addedFonts.contains(table.getFont().getFont(null))) { PDFont font
- * = table.getFont().getFont(template); addedFonts.add(font);
- * innerFormResources.addFont(font); }
- *
- * if(!addedFonts.contains(table.getValueFont().getFont(null))) { PDFont
- * font = table.getValueFont().getFont(template); addedFonts.add(font);
- * innerFormResources.addFont(font); }
- */
-
- for (int i = 0; i < table.getRowCount(); i++) {
- ArrayList<Entry> row = table.getRow(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
- if (cell.getType() == Entry.TYPE_IMAGE) {
- String img_value = (String) cell.getValue();
- String img_ref = createHashedId(img_value);
- if (!images.containsKey(img_ref)) {
- BufferedImage img = ImageUtils.getImage(img_value,
- settings);
-
- float width = colsSizes[j];
- float height = table.getRowHeights()[i] + padding * 2;
-
- float iwidth = (int) Math.floor((double) width);
- iwidth -= 2 * padding;
-
- float iheight = (int) Math.floor((double) height);
- iheight -= 2 * padding;
-
- float origWidth = (float) img.getWidth();
- float origHeight = (float) img.getHeight();
-
- if (table.style != null) {
- if (table.style.getImageScaleToFit() != null) {
- iwidth = table.style.getImageScaleToFit()
- .getWidth();
- iheight = table.style.getImageScaleToFit()
- .getHeight();
- }
- }
-
- float wfactor = iwidth / origWidth;
- float hfactor = iheight / origHeight;
- float scaleFactor = wfactor;
- if (hfactor < wfactor) {
- scaleFactor = hfactor;
- }
-
- iwidth = (float) Math
- .floor((double) (scaleFactor * origWidth));
- iheight = (float) Math
- .floor((double) (scaleFactor * origHeight));
-
- logger.debug("Scaling image to: " + iwidth + " x "
- + iheight);
-
- if (this.designer.properties
- .getSignatureProfileSettings().isPDFA()) {
- img = ImageUtils.removeAlphaChannel(img);
- } else {
- if (img.getAlphaRaster() == null
- && img.getColorModel().hasAlpha()) {
- img = ImageUtils.removeAlphaChannel(img);
- }
- }
- // img = ImageUtils.convertRGBAToIndexed(img);
-
- PDImageXObject pdImage = LosslessFactory.createFromImage(template, img);
-
-
- ImageObject image = new ImageObject(pdImage, iwidth,
- iheight);
- images.put(img_ref, image);
- innerFormResources.add(pdImage, "Im");
- }
- } else if (cell.getType() == Entry.TYPE_TABLE) {
- PDFBoxTable tbl_value = (PDFBoxTable) cell.getValue();
- readTableResources(tbl_value, template);
- }
- }
- }
- }
-
- public void createInnerFormStreamPdfAs(PDDocument template, PDDocument origDoc)
- throws PdfAsException {
- try {
-
- // Hint we have to create all PDXObjectImages before creating the
- // PDPageContentStream
- // only PDFbox developers know why ...
- // if (getStructure().getPage().getResources() != null) {
- // innerFormResources = getStructure().getPage().getResources();
- // } else {
- innerFormResources = new PDResources();
- getStructure().getPage().setResources(innerFormResources);
- // }
- readTableResources(properties.getMainTable(), template);
-
- PDPageContentStream stream = new PDPageContentStream(template,
- getStructure().getPage());
- // stream.setFont(PDType1Font.COURIER, 5);
- TableDrawUtils.drawTable(getStructure().getPage(), stream, 0, 1,
- designer.getWidth(), designer.getHeight(),
- properties.getMainTable(), template, false,
- innerFormResources, images, settings, this, properties);
- stream.close();
- PDStream innterFormStream = new PDStream(template,getStructure().getPage().getContents());
-
- getStructure().setInnterFormStream(innterFormStream);
- logger.debug("Strean of another form (inner form - it would be inside holder form) has been created");
-
- } catch (Throwable e) {
- logger.warn("Failed to create visual signature block", e);
- throw new PdfAsException("Failed to create visual signature block",
- e);
- }
- }
-
- @Override
- public void injectProcSetArray(PDFormXObject innerForm, PDPage page,
- PDResources innerFormResources, PDResources imageFormResources,
- PDResources holderFormResources, COSArray procSet) {
- innerForm.getResources().getCOSObject()
- .setItem(COSName.PROC_SET, procSet); //
- page.getCOSObject().setItem(COSName.PROC_SET, procSet);
- innerFormResources.getCOSObject()
- .setItem(COSName.PROC_SET, procSet);
- /*
- * imageFormResources.getCOSDictionary() .setItem(COSName.PROC_SET,
- * procSet);
- */
- holderFormResources.getCOSObject().setItem(COSName.PROC_SET,
- procSet);
- logger.debug("inserted ProcSet to PDF");
- }
-
- public void injectAppearanceStreams(PDStream holderFormStream,
- PDStream innterFormStream, PDStream imageFormStream,
- String imageObjectName, String imageName, String innerFormName,
- PDFAsVisualSignatureDesigner properties) throws IOException {
-
- // 100 means that document width is 100% via the rectangle. if rectangle
- // is 500px, images 100% is 500px.
- // String imgFormComment = "q "+imageWidthSize+ " 0 0 50 0 0 cm /" +
- // imageName + " Do Q\n" + builder.toString();
- /*
- * String imgFormComment = "q " + 100 + " 0 0 50 0 0 cm /" + imageName +
- * " Do Q\n";
- */
- double m00 = getStructure().getAffineTransform().getScaleX();
- double m10 = getStructure().getAffineTransform().getShearY();
- double m01 = getStructure().getAffineTransform().getShearX();
- double m11 = getStructure().getAffineTransform().getScaleY();
- double m02 = getStructure().getAffineTransform().getTranslateX();
- double m12 = getStructure().getAffineTransform().getTranslateY();
-
- String holderFormComment = "q " + m00 + " " + m10 + " " + m01 + " "
- + m11 + " " + m02 + " " + m12 + " cm /" + innerFormName
- + " Do Q";
-
- logger.debug("Holder Form Stream: " + holderFormComment);
-
- // String innerFormComment = "q 1 0 0 1 0 0 cm /" + imageObjectName +
- // " Do Q\n";
-
- //String innerFormComment = new String(getStructure().getInnerFormStream().toByteArray(), "ISO-8859-1");
- String innerFormComment = new String(getStructure().getInnerFormStream().toByteArray(), StandardCharsets.UTF_8);
-
- // .getInputStreamAsString();//TODO: pdfbox2 - get the string from the stream
-
- // logger.debug("Inner Form Stream: " + innerFormComment);
-
- // appendRawCommands(getStructure().getInnterFormStream().createOutputStream(),
- // getStructure().getInnterFormStream().getInputStreamAsString());
-
- appendRawCommands(getStructure().getHolderFormStream()
- .createOutputStream(), holderFormComment.trim().replace("\n", "").replace("\r", ""));
- appendRawCommands(getStructure().getInnerFormStream()
- .createOutputStream(), innerFormComment/*.trim().replace("\n", "").replace("\r", "")*/);
- // appendRawCommands(getStructure().getImageFormStream().createOutputStream(),
- // imgFormComment);
- logger.debug("Injected apereance stream to pdf");
-
- }
-
- public void createPage(PDFAsVisualSignatureDesigner properties) {
- PDPage page = new PDPage();
- page.setMediaBox(new PDRectangle(properties.getPageWidth(), properties
- .getPageHeight()));
- page.setRotation(properties.getPageRotation());
- getStructure().setPage(page);
- logger.debug("PDF page has been created");
- }
-
- public void createAcroForm(PDDocument template) {
- PDAcroForm theAcroForm = new PDAcroForm(template);
- template.getDocumentCatalog().setAcroForm(theAcroForm);
- getStructure().setAcroForm(theAcroForm);
- logger.debug("Acro form page has been created");
- }
-
- public void createSignatureField(PDAcroForm acroForm) throws IOException {
- PDSignatureField sf = new PDSignatureField(acroForm);
- getStructure().setSignatureField(sf);
- logger.debug("Signature field has been created");
- }
-
- public void createSignature(PDSignatureField pdSignatureField, PDPage page,
- String signatureName) throws IOException {
- PDSignature pdSignature = new PDSignature();
- pdSignatureField.setValue(pdSignature);
- pdSignatureField.getWidgets().get(0).setPage(page);
- page.getAnnotations().add(pdSignatureField.getWidgets().get(0));
- pdSignature.setName(signatureName);
- pdSignature.setByteRange(new int[] { 0, 0, 0, 0 });
- pdSignature.setContents(new byte[4096]);
- getStructure().setPdSignature(pdSignature);
- logger.debug("PDSignatur has been created");
- }
-
- public void createAcroFormDictionary(PDAcroForm acroForm,
- PDSignatureField signatureField) throws IOException {
- List<PDField> acroFormFields = acroForm.getFields();
- COSDictionary acroFormDict = acroForm.getCOSObject();
- acroFormDict.setDirect(true);
- acroFormDict.setInt(COSName.SIG_FLAGS, 3);
- acroFormFields.add(signatureField);
- acroFormDict.setString(COSName.DA, "/sylfaen 0 Tf 0 g");
- getStructure().setAcroFormFields(acroFormFields);
- getStructure().setAcroFormDictionary(acroFormDict);
- logger.debug("AcroForm dictionary has been created");
- }
-
- public void createSignatureRectangle(PDSignatureField signatureField,
- PDFAsVisualSignatureDesigner properties, float degrees)
- throws IOException {
-
- PDRectangle rect = new PDRectangle();
-
- Point2D upSrc = new Point2D.Float();
- upSrc.setLocation(properties.getxAxis() + properties.getWidth(),
- properties.getPageHeight() - properties.getyAxis());
-
- Point2D llSrc = new Point2D.Float();
- llSrc.setLocation(properties.getxAxis(), properties.getPageHeight()
- - properties.getyAxis() - properties.getHeight());
-
- rect.setUpperRightX((float) upSrc.getX());
- rect.setUpperRightY((float) upSrc.getY());
- rect.setLowerLeftY((float) llSrc.getY());
- rect.setLowerLeftX((float) llSrc.getX());
- logger.debug("orig rectangle of signature has been created: {}",
- rect.toString());
-
- AffineTransform transform = new AffineTransform();
- transform.setToIdentity();
- if (degrees % 360 != 0) {
- transform.setToRotation(Math.toRadians(degrees), llSrc.getX(),
- llSrc.getY());
- }
-
- Point2D upDst = new Point2D.Float();
- transform.transform(upSrc, upDst);
-
- Point2D llDst = new Point2D.Float();
- transform.transform(llSrc, llDst);
-
- float xPos = properties.getxAxis();
- float yPos = properties.getPageHeight() - properties.getyAxis();
- logger.debug("POS {} x {}", xPos, yPos);
- logger.debug("SIZE {} x {}", properties.getWidth(),
- properties.getHeight());
- // translate according to page! rotation
- int pageRotation = properties.getPageRotation();
- AffineTransform translate = new AffineTransform();
- switch (pageRotation) {
- case 90:
- translate.setToTranslation(
- properties.getPageHeight()
- - (properties.getPageHeight() - properties
- .getyAxis()) - properties.getxAxis()
- + properties.getHeight(),
- properties.getxAxis()
- + properties.getHeight()
- - (properties.getPageHeight() - properties
- .getyAxis()));
- break;
- case 180:
- // translate.setToTranslation(properties.getPageWidth() -
- // properties.getxAxis() - properties.getxAxis(),
- // properties.getPageHeight() - properties.getyAxis() +
- // properties.getHeight());
- translate.setToTranslation(
- properties.getPageWidth() - 2 * xPos,
- properties.getPageHeight() - 2
- * (yPos - properties.getHeight()));
- break;
- case 270:
- translate.setToTranslation(-properties.getHeight() + yPos - xPos,
- properties.getPageWidth() - (yPos - properties.getHeight())
- - xPos);
- break;
- }
-
- translate.transform(upDst, upDst);
- translate.transform(llDst, llDst);
-
- rect.setUpperRightX((float) upDst.getX());
- rect.setUpperRightY((float) upDst.getY());
- rect.setLowerLeftY((float) llDst.getY());
- rect.setLowerLeftX((float) llDst.getX());
- logger.debug("rectangle of signature has been created: {}",
- rect.toString());
- signatureField.getWidgets().get(0).setRectangle(rect);
- getStructure().setSignatureRectangle(rect);
- logger.debug("rectangle of signature has been created");
- }
-
- public void createAffineTransform(float[] params) {
- AffineTransform transform = new AffineTransform(params[0], params[1],
- params[2], params[3], params[4], params[5]);
- // transform.rotate(90);
- getStructure().setAffineTransform(transform);
- logger.debug("Matrix has been added");
- }
-
- public void createSignatureImage(PDDocument template,
- InputStream inputStream) throws IOException {
- PDImageXObject img = JPEGFactory.createFromStream(template, inputStream);
- getStructure().setImage(img);
- logger.debug("Visible Signature Image has been created");
- // pdfStructure.setTemplate(template);
- inputStream.close();
-
- }
-
- public void createFormaterRectangle(float[] params) {
-
- PDRectangle formrect = new PDRectangle();
- float[] translated = new float[4];
- getStructure().getAffineTransform().transform(params, 0, translated, 0,
- 2);
-
- formrect.setUpperRightX(translated[0]);
- formrect.setUpperRightY(translated[1]);
- formrect.setLowerLeftX(translated[2]);
- formrect.setLowerLeftY(translated[3]);
-
- getStructure().setFormatterRectangle(formrect);
- logger.debug("Formater rectangle has been created");
-
- }
-
- public void createHolderFormStream(PDDocument template) {
- PDStream holderForm = new PDStream(template);
- getStructure().setHolderFormStream(holderForm);
- logger.debug("Holder form Stream has been created");
- }
-
- public void createHolderFormResources() {
- PDResources holderFormResources = new PDResources();
- getStructure().setHolderFormResources(holderFormResources);
- logger.debug("Holder form resources have been created");
-
- }
-
- public void createHolderForm(PDResources holderFormResources,
- PDStream holderFormStream, PDRectangle formrect) {
-
- PDFormXObject holderForm = new PDFormXObject(holderFormStream);
- holderForm.setResources(holderFormResources);
- holderForm.setBBox(formrect);
- holderForm.setFormType(1);
- getStructure().setHolderForm(holderForm);
- logger.debug("Holder form has been created");
-
- }
-
- public void createAppearanceDictionary(PDFormXObject holderForml,
- PDSignatureField signatureField, float degrees) throws IOException {
-
- PDAppearanceDictionary appearance = new PDAppearanceDictionary();
- appearance.getCOSObject().setDirect(true);
-
- PDAppearanceStream appearanceStream = new PDAppearanceStream(
- holderForml.getCOSObject());
- AffineTransform transform = new AffineTransform();
- transform.setToIdentity();
- transform.rotate(Math.toRadians(degrees));
- appearanceStream.setMatrix(transform);
- appearance.setNormalAppearance(appearanceStream);
- signatureField.getWidgets().get(0).setAppearance(appearance);
-
- getStructure().setAppearanceDictionary(appearance);
- logger.debug("PDF appereance Dictionary has been created");
-
- }
-
- public void createInnerFormResource() {
- getStructure().setInnerFormResources(innerFormResources);
- logger.debug("Resources of another form (inner form - it would be inside holder form) have been created");
- }
-
- public void createInnerForm(PDResources innerFormResources,
- PDStream innerFormStream, PDRectangle formrect) {
- PDFormXObject innerForm = new PDFormXObject(innerFormStream);
- innerForm.setResources(innerFormResources);
- innerForm.setBBox(formrect);
- innerForm.setFormType(1);
- getStructure().setInnerForm(innerForm);
- logger.debug("Another form (inner form - it would be inside holder form) have been created");
-
- }
-
- public void insertInnerFormToHolerResources(PDFormXObject innerForm,
- PDResources holderFormResources) {
- COSName name = holderFormResources.add(innerForm, "FRM");//TODO: pdfbox2 - is this right?
- getStructure().setInnerFormName(name);
- logger.debug("Already inserted inner form inside holder form");
- }
-
- public void createImageFormStream(PDDocument template) {
- PDStream imageFormStream = new PDStream(template);
- getStructure().setImageFormStream(imageFormStream);
- logger.debug("Created image form Stream");
- }
-
- public void createImageFormResources() {
- PDResources imageFormResources = new PDResources();
- getStructure().setImageFormResources(imageFormResources);
- logger.debug("Created image form Resources");
- }
-
- public void createImageForm(PDResources imageFormResources,
- PDResources innerFormResource, PDStream imageFormStream,
- PDRectangle formrect, AffineTransform affineTransform, PDFormXObject img)
- throws IOException {
-
- /*
- * if you need text on the visible signature
- *
- * PDFont font = PDTrueTypeFont.loadTTF(this.pdfStructure.getTemplate(),
- * new File("D:\\arial.ttf")); font.setFontEncoding(new
- * WinAnsiEncoding());
- *
- * Map<String, PDFont> fonts = new HashMap<String, PDFont>();
- * fonts.put("arial", font);
- */
- PDFormXObject imageForm = new PDFormXObject(imageFormStream);
- imageForm.setBBox(formrect);
- imageForm.setMatrix(affineTransform);
- imageForm.setResources(imageFormResources);
- imageForm.setFormType(1);
- /*
- * imageForm.getResources().addFont(font);
- * imageForm.getResources().setFonts(fonts);
- */
-
- imageFormResources.getCOSObject().setDirect(true);
- COSName imageFormName = innerFormResource.add(imageForm, "n");//TODO: pdfbox2 - is this right?
- COSName imageName = imageFormResources.add(img, "img");
- this.getStructure().setImageForm(imageForm);
- this.getStructure().setImageFormName(imageFormName);
- this.getStructure().setImageName(imageName);
- logger.debug("Created image form");
- }
-
- public void appendRawCommands(OutputStream os, String commands)
- throws IOException {
- os.write(commands.getBytes(StandardCharsets.UTF_8));
- os.close();
- }
-
- public void createVisualSignature(PDDocument template) {
- this.getStructure().setVisualSignature(template.getDocument());
- logger.debug("Visible signature has been created");
-
- }
-
- public void createWidgetDictionary(PDSignatureField signatureField,
- PDResources holderFormResources) throws IOException {
-
- COSDictionary widgetDict = signatureField.getWidgets().get(0).getCOSObject();//TODO: pdfbox2 - is this right was getWidget before?
- widgetDict.setNeedToBeUpdated(true);
- widgetDict.setItem(COSName.DR, holderFormResources.getCOSObject());
-
- getStructure().setWidgetDictionary(widgetDict);
- logger.debug("WidgetDictionary has been crated");
- }
-
- public void closeTemplate(PDDocument template) throws IOException {
- template.close();
- this.getStructure().getTemplate().close();
- }
-
- public void removeCidSet(PDDocument document) throws IOException {
-
- PDDocumentCatalog catalog = document.getDocumentCatalog();
- COSName cidSet = COSName.getPDFName("CIDSet");
-
- Iterator<PDPage> pdPageIterator = catalog.getPages().iterator();
- while(pdPageIterator.hasNext()) {
-
- PDPage page = pdPageIterator.next();
-
- Iterator<COSName> cosNameIterator = page.getResources().getFontNames().iterator();
- while (cosNameIterator.hasNext()) {
- COSName fontName = cosNameIterator.next();
- PDFont pdFont = page.getResources().getFont(fontName);
-
- if (pdFont instanceof PDType0Font typedFont) {
-
- if (typedFont.getDescendantFont() != null) {
- if (typedFont.getDescendantFont().getFontDescriptor() != null) {
- typedFont.getDescendantFont().getFontDescriptor().getCOSObject().removeItem(cidSet);
- }
- }
- }
- }
- }
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureDesigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureDesigner.java
deleted file mode 100644
index 6e198bba..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureDesigner.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDPageTree;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-
-public class PDFAsVisualSignatureDesigner {
-
-// private static final Logger logger = LoggerFactory.getLogger(PDFAsVisualSignatureDesigner.class);
-
- private Float sigImgWidth;
- private Float sigImgHeight;
- private float xAxis;
- private float yAxis;
- private float pageHeight;
- private float pageWidth;
- private InputStream imgageStream;
- private String signatureFieldName = "sig"; // default
- private float[] formaterRectangleParams = { 0, 0, 100, 50 }; // default
- //private float[] AffineTransformParams = { 0, 1, -1, 0, 0, 0 }; // default
- private float[] AffineTransformParams = { 1, 0, 0, 1, 0, 0 }; // default
- private float imageSizeInPercents;
- private PDDocument document = null;
- private int page = 0;
- private int pageRotation = 0;
- private boolean newpage = false;
- PDFAsVisualSignatureProperties properties;
-
- /**
- *
- * @param doc
- * - Already created PDDocument of your PDF document
- * @param imageStream
- * @param page
- * @throws IOException
- * - If we can't read, flush, or can't close stream
- */
- public PDFAsVisualSignatureDesigner(PDDocument doc, int page,
- PDFAsVisualSignatureProperties properties, boolean newpage) throws IOException {
- this.properties = properties;
- calculatePageSize(doc, page, newpage);
- document = doc;
- this.page = page;
- this.newpage = newpage;
- }
-
- /**
- * Each page of document can be different sizes.
- *
- * @param document
- * @param page
- */
- private void calculatePageSize(PDDocument document, int page, boolean newpage) {
-
- if (page < 1) {
- throw new IllegalArgumentException("First page of pdf is 1, not "
- + page);
- }
-
- PDPageTree pages = document.getDocumentCatalog().getPages();
- if(newpage) {
- PDPage lastPage = (PDPage) pages.get(pages.getCount()-1);
- PDRectangle mediaBox = lastPage.getMediaBox();
- pageRotation = lastPage.getRotation() % 360;
- if(pageRotation == 90 || pageRotation == 270) {
- this.pageHeight(mediaBox.getWidth());
- this.pageWidth = mediaBox.getHeight();
- } else {
- this.pageHeight(mediaBox.getHeight());
- this.pageWidth = mediaBox.getWidth();
- }
- } else {
- PDPage firstPage = (PDPage) pages.get(page - 1);
- PDRectangle mediaBox = firstPage.getMediaBox();
- pageRotation = firstPage.getRotation() % 360;
- if(pageRotation == 90 || pageRotation == 270) {
- this.pageHeight(mediaBox.getWidth());
- this.pageWidth = mediaBox.getHeight();
- } else {
- this.pageHeight(mediaBox.getHeight());
- this.pageWidth = mediaBox.getWidth();
- }
- }
- float x = this.pageWidth;
- float y = 0;
- this.pageWidth = this.pageWidth + y;
- float tPercent = (100 * y / (x + y));
- this.imageSizeInPercents = 100 - tPercent;
- }
-
- /**
- *
- * @param path
- * of image location
- * @return image Stream
- * @throws IOException
- */
- public PDFAsVisualSignatureDesigner signatureImage(String path)
- throws IOException {
- InputStream fin = new FileInputStream(path);
- return signatureImageStream(fin);
- }
-
- /**
- * zoom signature image with some percent.
- *
- * @param percent
- * - x % increase image with x percent.
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner zoom(float percent) {
- sigImgHeight = sigImgHeight + (sigImgHeight * percent) / 100;
- sigImgWidth = sigImgWidth + (sigImgWidth * percent) / 100;
- return this;
- }
-
- /**
- *
- * @param xAxis
- * - x coordinate
- * @param yAxis
- * - y coordinate
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner coordinates(float x, float y) {
- xAxis(x);
- yAxis(y);
- return this;
- }
-
- /**
- *
- * @return xAxis - gets x coordinates
- */
- public float getxAxis() {
- return xAxis;
- }
-
- /**
- *
- * @param xAxis
- * - x coordinate
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner xAxis(float xAxis) {
- this.xAxis = xAxis;
- return this;
- }
-
- /**
- *
- * @return yAxis
- */
- public float getyAxis() {
- return yAxis;
- }
-
- /**
- *
- * @param yAxis
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner yAxis(float yAxis) {
- this.yAxis = yAxis;
- return this;
- }
-
- /**
- *
- * @return signature image width
- */
- public float getWidth() {
- return this.properties.getMainTable().getWidth();
- }
-
- /**
- *
- * @param sets
- * signature image width
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner width(float signatureImgWidth) {
- this.sigImgWidth = signatureImgWidth;
- return this;
- }
-
- /**
- *
- * @return signature image height
- */
- public float getHeight() {
- return this.properties.getMainTable().getHeight();
- }
-
- /**
- *
- * @param set
- * signature image Height
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner height(float signatureImgHeight) {
- this.sigImgHeight = signatureImgHeight;
- return this;
- }
-
- /**
- *
- * @return template height
- */
- protected float getTemplateHeight() {
- return getPageHeight();
- }
-
- /**
- *
- * @param templateHeight
- * @return Visible Signature Configuration Object
- */
- private PDFAsVisualSignatureDesigner pageHeight(float templateHeight) {
- this.pageHeight = templateHeight;
- return this;
- }
-
- /**
- *
- * @return signature field name
- */
- public String getSignatureFieldName() {
- return signatureFieldName;
- }
-
- /**
- *
- * @param signatureFieldName
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner signatureFieldName(
- String signatureFieldName) {
- this.signatureFieldName = signatureFieldName;
- return this;
- }
-
- /**
- *
- * @return image Stream
- */
- public InputStream getImageStream() {
- return imgageStream;
- }
-
- /**
- *
- * @param imageStream
- * - stream of your visible signature image
- * @return Visible Signature Configuration Object
- * @throws IOException
- * - If we can't read, flush, or close stream of image
- */
- private PDFAsVisualSignatureDesigner signatureImageStream(
- InputStream imageStream) throws IOException {
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int len;
- while ((len = imageStream.read(buffer)) > -1) {
- baos.write(buffer, 0, len);
- }
- baos.flush();
- baos.close();
-
- byte[] byteArray = baos.toByteArray();
- byte[] byteArraySecond = byteArray.clone();
-
- InputStream inputForBufferedImage = new ByteArrayInputStream(byteArray);
- InputStream revertInputStream = new ByteArrayInputStream(
- byteArraySecond);
-
- if (sigImgHeight == null || sigImgWidth == null) {
- calcualteImageSize(inputForBufferedImage);
- }
-
- this.imgageStream = revertInputStream;
-
- return this;
- }
-
- /**
- * calculates image width and height. sported formats: all
- *
- * @param fis
- * - input stream of image
- * @throws IOException
- * - if can't read input stream
- */
- private void calcualteImageSize(InputStream fis) throws IOException {
-
- BufferedImage bimg = ImageIO.read(fis);
- int width = bimg.getWidth();
- int height = bimg.getHeight();
-
- sigImgHeight = (float) height;
- sigImgWidth = (float) width;
-
- }
-
- /**
- *
- * @return Affine Transform parameters of for PDF Matrix
- */
- public float[] getAffineTransformParams() {
- return AffineTransformParams;
- }
-
- /**
- *
- * @param affineTransformParams
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner affineTransformParams(
- float[] affineTransformParams) {
- AffineTransformParams = affineTransformParams;
- return this;
- }
-
- /**
- *
- * @return formatter PDRectanle parameters
- */
- public float[] getFormaterRectangleParams() {
- return formaterRectangleParams;
- }
-
- /**
- * sets formatter PDRectangle;
- *
- * @param formaterRectangleParams
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner formaterRectangleParams(
- float[] formaterRectangleParams) {
- this.formaterRectangleParams = formaterRectangleParams;
- return this;
- }
-
- /**
- *
- * @return page width
- */
- public float getPageWidth() {
- return pageWidth;
- }
-
- public PDPage getSignaturePage() {
- if (page < 1) {
- throw new IllegalArgumentException("First page of pdf is 1, not "
- + page);
- }
- PDPage pdPage = null;
- PDPageTree pages = document.getDocumentCatalog().getPages();
- if(newpage) {
- pdPage = new PDPage();
- } else {
- pdPage = (PDPage) pages.get(page - 1);
- }
-
- return pdPage;
- }
-
- /**
- *
- * @param sets
- * pageWidth
- * @return Visible Signature Configuration Object
- */
- public PDFAsVisualSignatureDesigner pageWidth(float pageWidth) {
- this.pageWidth = pageWidth;
- return this;
- }
-
- /**
- *
- * @return page height
- */
- public float getPageHeight() {
- return pageHeight;
- }
-
- /**
- *
- * @return page height
- */
- public int getPageRotation() {
- return pageRotation;
- }
-
- /**
- * get image size in percents
- *
- * @return
- */
- public float getImageSizeInPercents() {
- return imageSizeInPercents;
- }
-
- /**
- *
- * @param imageSizeInPercents
- */
- public void imageSizeInPercents(float imageSizeInPercents) {
- this.imageSizeInPercents = imageSizeInPercents;
- }
-
- /**
- * returns visible signature text
- *
- * @return
- */
- public String getSignatureText() {
- throw new UnsupportedOperationException(
- "That method is not yet implemented");
- }
-
- /**
- *
- * @param signatureText
- * - adds the text on visible signature
- * @return
- */
- public PDFAsVisualSignatureDesigner signatureText(String signatureText) {
- throw new UnsupportedOperationException(
- "That method is not yet implemented");
- }
-
- public float getRotation() {
- return this.properties.getRotation();
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java
deleted file mode 100644
index 623347ff..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDPageTree;
-import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleSigProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-
-public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties {
-
- private static final Logger logger = LoggerFactory.getLogger(PDFAsVisualSignatureProperties.class);
-
- private ISettings settings;
-
- private PDFBoxTable main;
-
- private PDFAsVisualSignatureDesigner designer;
-
- private float rotationAngle = 0;
-
- private PDDocument origDoc;
-
- private SignatureProfileSettings signatureProfileSettings;
-
- private String alternativeTableCaption="";
-
- private boolean buildPreviewOnly;
-
- public PDFAsVisualSignatureProperties(ISettings settings, PDFBOXObject object,
- PdfBoxVisualObject visObj, PositioningInstruction pos, SignatureProfileSettings signatureProfileSettings,
- boolean buildPreviewOnly) {
- this.buildPreviewOnly = buildPreviewOnly;
- this.settings = settings;
- this.signatureProfileSettings = signatureProfileSettings;
- try {
- main = visObj.getTable();
- } catch (Throwable e) {
- e.printStackTrace();
- }
- this.rotationAngle = pos.getRotation();
- try {
- origDoc = object.getDocument();
-
- designer = new PDFAsVisualSignatureDesigner(origDoc, pos.getPage(), this, pos.isMakeNewPage());
- PDPageTree pages = origDoc.getDocumentCatalog().getPages();
- PDPage page = null;
- if(pos.isMakeNewPage()) {
- page = (PDPage) pages.get(pages.getCount()-1);
- } else {
- page = (PDPage) pages.get(pos.getPage() - 1);
- }
- logger.debug("PAGE width {} HEIGHT {}", designer.getPageWidth(), designer.getPageHeight());
- logger.debug("POS X {} Y {}", pos.getX(), pos.getY());
- int rot = page.getRotation();
- float posy = designer.getPageHeight() - pos.getY();
- float posx = pos.getX();
- /*switch (rot) {
- case 90: // CW
- posx = designer.getPageHeight() - pos.getY();
- posy = designer.getPageWidth() - main.getWidth();
- break;
- case 180:
- posy = pos.getY();
- posx = designer.getPageWidth() - pos.getX();
- break;
- case 270: // CCW
- posx = pos.getY();
- posy = designer.getPageWidth() - pos.getX();
- break;
- }*/
- logger.debug("ROT {}", rot);
- logger.debug("COORD X {} Y {}", posx, posy);
- designer.coordinates(posx, posy);
- float[] form_rect = new float[] {0,0, main.getWidth() + 1, main.getHeight() + 1};
- logger.debug("AP Rect: {} {} {} {}", form_rect[0], form_rect[1], form_rect[2], form_rect[3]);
- designer.formaterRectangleParams(form_rect);
- //this.setPdVisibleSignature(designer);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void buildSignature() throws IOException {
- PDFAsVisualSignatureBuilder builder = new PDFAsVisualSignatureBuilder(this, this.settings, designer, this.signatureProfileSettings);
- PDFAsTemplateCreator creator = new PDFAsTemplateCreator(builder);
- try {
- setVisibleSignature(creator.buildPDF(designer, this.origDoc, buildPreviewOnly));
- } catch (PdfAsException e) {
- throw new PdfAsWrappedIOException(e);
- }
- }
-
- public PDFBoxTable getMainTable() {
- return main;
- }
-
- public float getRotation() {
- return this.rotationAngle;
- }
-
- public PDFAsVisualSignatureDesigner getDesigner() {
- return designer;
- }
-
- public SignatureProfileSettings getSignatureProfileSettings() {
- return signatureProfileSettings;
- }
-
- public String getAlternativeTableCaption() {
- return alternativeTableCaption;
- }
-
- public void setAlternativeTableCaption(String alternativeTableCaption) {
- this.alternativeTableCaption = alternativeTableCaption;
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java
deleted file mode 100644
index 58779f09..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxFont.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.font.PDType0Font;
-import org.apache.pdfbox.pdmodel.font.PDType1Font;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-
-public class PDFBoxFont {
-
- private static final Logger logger = LoggerFactory
- .getLogger(PDFBoxFont.class);
-
-
- private static final String NORMAL = "NORMAL";
- private static final String SEP = ":";
-
- public static PDFont defaultFont = PDType1Font.HELVETICA;
- public static float defaultFontSize = 8;
-
- //private static Map<String, FontInfoCache> fontInfoCache = new HashMap<String, FontInfoCache>();
-
-
-
-
- PDFont font;
- PDFont cachedfont = null;
- float fontSize;
- String fontDesc;
- String ttfFontDesc;
- ISettings settings;
-
-// private FontInfoCache getFontInfo(String pathName) {
-// synchronized (fontInfoCache) {
-//
-// if (fontInfoCache.containsKey(pathName)) {
-// return fontInfoCache.get(pathName);
-// } else {
-// try {
-// String fontNameToLoad = null;
-// String fontFamilyToLoad = null;
-// InputStream ttfData = new FileInputStream(pathName);
-// try {
-// TrueTypeFont ttf = null;
-// TTFParser parser = new TTFParser();
-// ttf = parser.parse(ttfData);
-// NamingTable naming = ttf.getNaming();
-// List<NameRecord> records = naming.getNameRecords();
-// for (int i = 0; i < records.size(); i++) {
-// NameRecord nr = records.get(i);
-// if (nr.getNameId() == NameRecord.NAME_POSTSCRIPT_NAME) {
-// fontNameToLoad = nr.getString();
-// } else if (nr.getNameId() == NameRecord.NAME_FONT_FAMILY_NAME) {
-// fontFamilyToLoad = nr.getString();
-// }
-// }
-// } finally {
-// ttfData.close();
-// }
-// FontInfoCache fontInfo = new FontInfoCache();
-// fontInfo.filename = pathName;
-// fontInfo.fontFamily = fontFamilyToLoad;
-// fontInfo.fontName = fontNameToLoad;
-// fontInfo.fontPath = pathName;
-// fontInfoCache.put(pathName, fontInfo);
-// return fontInfo;
-// } catch (Throwable e) {
-// logger.warn("Failed to generate FontInfo from file: {}", pathName);
-// }
-// return null;
-// }
-// }
-// }
-
- //we are not using this method, because we create subsets of ttf fonts, so we do not reuse
- // them by doing PDTrueTypeFont(fontDictionary).
-// private PDFont findCachedFont(PDFBOXObject pdfObject, FontInfoCache fontInfo) {
-// try {
-// if(pdfObject.getSigBlockFontCache().contains(fontInfo.fontPath)) {
-// return pdfObject.getSigBlockFontCache().getFont(fontInfo.fontPath);
-// }
-//
-// List<COSObject> cosObjects = pdfObject.getDocument().getDocument().getObjectsByType(
-// COSName.FONT);
-//
-// //COSName cosFontName = COSName.getPDFName(fontInfo.fontName);
-// //COSName cosFontFamily = COSName.getPDFName(fontInfo.fontFamily);
-//
-// Iterator<COSObject> cosObjectIt = cosObjects.iterator();
-//
-// while (cosObjectIt.hasNext()) {
-// COSObject cosObject = cosObjectIt.next();
-// COSDictionary baseObject = (COSDictionary) cosObject
-// .getObject();
-// if (baseObject instanceof COSDictionary) {
-// COSDictionary fontDictionary = (COSDictionary) baseObject;
-// COSBase subType = cosObject.getItem(COSName.SUBTYPE);
-//
-// if (COSName.TRUE_TYPE.equals(subType)) {
-// COSDictionary fontDescriptor = (COSDictionary)cosObject.getDictionaryObject(COSName.FONT_DESC);
-// String fontName = fontDescriptor.getNameAsString(COSName.FONT_NAME);
-// String fontFamily = fontDescriptor.getNameAsString(COSName.FONT_FAMILY);
-// logger.debug("Checking Font {} - {}", fontFamily, fontName);
-// if (fontInfo.fontName != null && fontInfo.fontName.equals(fontName) &&
-// fontInfo.fontFamily != null && fontInfo.fontFamily.equals(fontFamily)) {
-// // Found it! :)
-// logger.info("Found Font {}", fontInfo.fontName);
-// return new PDTrueTypeFont(fontDictionary);
-// } else {
-// logger.debug("Font not found: {} is {}",
-// fontInfo.fontName, fontName);
-// }
-// }else if(COSName.TYPE0.equals(subType)){
-//
-// }
-// else {
-// logger.debug("Font not a TTF");
-// }
-// } else {
-// logger.debug("Font not a COSDictionary");
-// }
-// }
-// } catch (Throwable e) {
-// logger.info("Failed to find existing TTF fonts!", e);
-// }
-// return null;
-// }
-
- private PDFont generateTTF(String fonttype, PDFBOXObject pdfObject) throws IOException {
- ttfFontDesc = fonttype;
- String fontName = fonttype.replaceFirst("TTF:", "");
- String fontPath = this.settings.getWorkingDirectory() + File.separator + "fonts" + File.separator + fontName;
-
- logger.debug("Font from: \"{}\".", fontPath);
- PDFAsFontCache fontCache = pdfObject.getSigBlockFontCache();
- if(fontCache.contains(fontPath)){
- logger.debug("Using cached font.");
- return fontCache.getFont(fontPath);
-
- }
-
-
-// FontInfoCache fontInfo = getFontInfo(fontPath);
-//
-// if(fontInfo != null) {
-//
-// PDFont font = findCachedFont(pdfObject, fontInfo);
-//
-// if (font != null) {
-// return font;
-// }
-// }
-
- logger.debug("Instantiating new font.");
-
-/*
- SignatureProfileSettings signatureProfileSettings = TableFactory
- .createProfile(pdfObject.getStatus().getRequestedSignature().getSignatureProfileID(), pdfObject.getStatus().getSettings());
-
- boolean requirePDFA3 = signatureProfileSettings.isPDFA3();
-*/
- PDType0Font font;
- try (FileInputStream fontStream = new FileInputStream(fontPath)) {
- font = PDType0Font.load(pdfObject.getDocument(), fontStream);
- }
- fontCache.addFont(fontPath, font);
-
- return font;
-
- }
-
- private PDFont generateFont(String fonttype, String fontder,
- PDFBOXObject pdfObject) throws IOException {
- if (fonttype.startsWith("TTF:")) {
- // Load TTF Font
- return generateTTF(fonttype, pdfObject);
-
- } else {
- if (fontder == null) {
- fontder = NORMAL;
- }
-
- String fontDesc = fonttype + SEP + fontder;
- PDFont font = pdfObject.getSigBlockFontCache().getFont(fontDesc);
- if (font == null) {
- pdfObject.getSigBlockFontCache().showAvailableFonts();
- throw new IOException("Invalid font descriptor \"" + fontDesc + "\"");
-
- }
- return font;
-
- }
- }
-
- private void setFont(String desc, PDFBOXObject pdfObject)
- throws IOException {
- String[] fontArr = desc.split(",");
-
- if (fontArr.length == 3) {
- font = generateFont(fontArr[0], fontArr[2], pdfObject);
- fontSize = Float.parseFloat(fontArr[1]);
- } else if (fontArr.length == 2 && fontArr[0].startsWith("TTF:")) {
- font = generateFont(fontArr[0], null, pdfObject);
- fontSize = Float.parseFloat(fontArr[1]);
- } else {
- logger.warn(
- "Using default font because: {} is not a valid font descriptor.",
- desc);
- this.font = defaultFont;
- this.fontSize = defaultFontSize;
- }
- }
-
- public PDFBoxFont(String fontDesc, ISettings settings,
- PDFBOXObject pdfObject) throws IOException {
- this.settings = settings;
- this.fontDesc = fontDesc;
- logger.debug("Creating Font: {}", fontDesc);
- this.setFont(fontDesc, pdfObject);
- }
-
- public PDFont getFont(/*PDFBOXObject pdfObject*/) throws IOException {
- if (cachedfont != null) {
- return cachedfont;
- }
- return font;
- /*
- if (font instanceof PDTrueTypeFont && pdfObject != null) {
- return generateTTF(ttfFontDesc, pdfObject);
- } else {
- return font;
- }*/
- }
-
- public float getFontSize() {
- return fontSize;
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java
deleted file mode 100644
index 4d8050b5..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFBoxTable.java
+++ /dev/null
@@ -1,741 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.common.utils.ImageUtils;
-import at.gv.egiz.pdfas.common.utils.StringUtils;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.knowcenter.wag.egov.egiz.table.Entry;
-import at.knowcenter.wag.egov.egiz.table.Style;
-import at.knowcenter.wag.egov.egiz.table.Table;
-
-public class PDFBoxTable {
-
- private static final Logger logger = LoggerFactory
- .getLogger(PDFBoxTable.class);
-
- private static final String NBSPACE = '\u00A0'+"";
-
- Table table;
- Style style;
- PDFBoxFont font;
- PDFBoxFont valueFont;
- ISettings settings;
-
- float padding;
- int positionX = 0;
- int positionY = 0;
- float tableWidth;
- float tableHeight;
- Color bgColor;
-
- float[] rowHeights;
- float[] colWidths;
-
- PDDocument originalDoc;
-
- PDFBOXObject pdfBoxObject;
-
- private void normalizeContent(Table abstractTable) throws PdfAsException {
- try {
- int rows = abstractTable.getRows().size();
- for (int i = 0; i < rows; i++) {
- ArrayList<Entry> row = this.table.getRows().get(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
-
- switch (cell.getType()) {
- case Entry.TYPE_CAPTION:
- case Entry.TYPE_VALUE:
- String value = (String) cell.getValue();
- //Check if the used value font supports all characters in string
- PDFont f = null;
- try{
- if(valueFont != null){
- f = valueFont.getFont();
- f.getStringWidth(value);
- }
- }catch(IllegalArgumentException | IOException e){
- if(f!=null){
- logger.warn("Font "+f.getName()+" doesnt support a character in the value "+value);
- }
- value = StringUtils.convertStringToPDFFormat(value);
- cell.setValue(value);
- }
-
- break;
- }
- }
- }
- } catch (UnsupportedEncodingException e) {
- throw new PdfAsException("Unsupported Encoding", e);
- }
- }
-
- private void initializeStyle(Table abstractTable, PDFBoxTable parent,
- PDFBOXObject pdfBoxObject) throws IOException {
- this.table = abstractTable;
-
- if (parent != null) {
- style = Style.doInherit(abstractTable.getStyle(), parent.style);
- } else {
- style = abstractTable.getStyle();
- }
-
- if (style == null) {
- throw new IOException("Failed to determine Table style, for table "
- + abstractTable.getName());
- }
-
- String fontString = style.getFont();
-
- String vfontString = style.getValueFont();
-
- if (parent != null && style == parent.style) {
- font = parent.getFont();
-
- valueFont = parent.getValueFont();
- } else {
- if (fontString == null && parent != null && parent.style != null) {
- fontString = parent.style.getFont();
- } else if (fontString == null) {
- throw new IOException(
- "Failed to determine Table font style, for table "
- + abstractTable.getName());
- }
-
- font = new PDFBoxFont(fontString, settings, pdfBoxObject);
-
- if (vfontString == null && parent != null && parent.style != null) {
- vfontString = parent.style.getValueFont();
- } else if (fontString == null) {
- throw new IOException(
- "Failed to determine value Table font style, for table "
- + abstractTable.getName());
- }
-
- valueFont = new PDFBoxFont(vfontString, settings, pdfBoxObject);
- }
- padding = style.getPadding();
-
- bgColor = style.getBgColor();
-
- try {
- normalizeContent(abstractTable);
- } catch (PdfAsException e) {
- throw new PdfAsWrappedIOException(e);
- }
- }
-
- public PDFBoxTable(Table abstractTable, PDFBoxTable parent, float fixSize,
- ISettings settings, PDFBOXObject pdfBoxObject) throws IOException,
- PdfAsException {
- this.settings = settings;
- this.pdfBoxObject = pdfBoxObject;
- this.originalDoc = pdfBoxObject.getDocument();
- initializeStyle(abstractTable, parent, pdfBoxObject);
- float[] relativSizes = abstractTable.getColsRelativeWith();
- if (relativSizes != null) {
- colWidths = new float[relativSizes.length];
- float totalrel = 0;
-
- for (int i = 0; i < relativSizes.length; i++) {
- totalrel += relativSizes[i];
- }
-
- float unit = (fixSize / totalrel);
-
- for (int i = 0; i < relativSizes.length; i++) {
-
- colWidths[i] = unit * relativSizes[i];
- }
- } else {
- colWidths = new float[abstractTable.getMaxCols()];
- float totalrel = abstractTable.getMaxCols();
- float unit = (fixSize / totalrel);
- for (int i = 0; i < colWidths.length; i++) {
-
- colWidths[i] = unit;
- }
- }
- calculateHeightsBasedOnWidths();
-
- logger.debug("Generating Table with fixed With {} got width {}",
- fixSize, getWidth());
- }
-
- public PDFBoxTable(Table abstractTable, PDFBoxTable parent,
- ISettings settings, PDFBOXObject pdfBoxObject) throws IOException,
- PdfAsException {
- this.settings = settings;
- this.pdfBoxObject = pdfBoxObject;
- this.originalDoc = pdfBoxObject.getDocument();
- initializeStyle(abstractTable, parent, pdfBoxObject);
- this.calculateWidthHeight();
- }
-
- private void calculateHeightsBasedOnWidths() throws IOException,
- PdfAsException {
- int rows = this.table.getRows().size();
- rowHeights = new float[rows];
-
- for (int i = 0; i < rows; i++) {
- rowHeights[i] = 0;
- }
-
- for (int i = 0; i < rows; i++) {
- ArrayList<Entry> row = this.table.getRows().get(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
-
- float colWidth = 0;// colWidths[j];
-
- int colsleft = cell.getColSpan();
-
- if (j + colsleft > colWidths.length) {
- throw new IOException(
- "Configuration is wrong. Cannot determine column width!");
- }
-
- for (int k = 0; k < colsleft; k++) {
- colWidth = colWidth + colWidths[j + k];
- }
-
- float cellheight = getCellHeight(cell, colWidth);
-
- if (rowHeights[i] < cellheight) {
- rowHeights[i] = cellheight;
- }
-
- logger.debug("ROW: {} COL: {} Width: {} Height: {}", i, j,
- colWidth, cellheight);
-
- int span = cell.getColSpan() - 1;
- j += span;
- }
- }
-
- calcTotals();
- }
-
- private void calculateWidthHeight() throws IOException, PdfAsException {
- int cols = this.table.getMaxCols();
- colWidths = new float[cols];
-
- for (int i = 0; i < cols; i++) {
- colWidths[i] = 0;
- }
-
- int rows = this.table.getRows().size();
- rowHeights = new float[rows];
-
- for (int i = 0; i < rows; i++) {
- rowHeights[i] = 0;
- }
-
- for (int i = 0; i < rows; i++) {
- ArrayList<Entry> row = this.table.getRows().get(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
- float cellWidth = getCellWidth(cell);
-
- if (colWidths[j] < cellWidth) {
- colWidths[j] = cellWidth;
- }
-
- float cellheight = getCellHeight(cell);
-
- if (rowHeights[i] < cellheight) {
- rowHeights[i] = cellheight;
- }
-
- logger.debug("ROW: {} COL: {} Width: {} Height: {}", i, j,
- cellWidth, cellheight);
-
- int span = cell.getColSpan() - 1;
- j += span;
- }
- }
-
- calcTotals();
- }
-
- private void calcTotals() {
-
- this.tableHeight = 0;
-
- for (int i = 0; i < rowHeights.length; i++) {
- this.tableHeight += rowHeights[i];
- }
-
- // Post Process heights for inner Tables ...
- for (int i = 0; i < rowHeights.length; i++) {
- ArrayList<Entry> row = this.table.getRows().get(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
- if (cell.getType() == Entry.TYPE_TABLE) {
- PDFBoxTable tbl = (PDFBoxTable) cell.getValue();
- if (rowHeights[i] != tbl.getHeight()) {
- tbl.setHeight(rowHeights[i]);
- }
- }
- }
- }
-
- this.tableWidth = 0;
-
- for (int i = 0; i < colWidths.length; i++) {
- this.tableWidth += colWidths[i];
- }
- }
-
- private float getCellWidth(Entry cell) throws IOException, PdfAsException {
- boolean isValue = true;
- switch (cell.getType()) {
- case Entry.TYPE_CAPTION:
- isValue = false;
- case Entry.TYPE_VALUE:
- PDFont c = null;
- float fontSize;
- String string = (String) cell.getValue();
- if (isValue) {
- c = valueFont.getFont();//null
- fontSize = valueFont.getFontSize();
- } else {
- c = font.getFont();//null
- fontSize = font.getFontSize();
- }
- if (string == null) {
- string = "";
- cell.setValue(string);
- }
- if (string.contains(NBSPACE) || string.contains("\n")) {
- float maxWidth = 0;
- string = string.replace(NBSPACE, " ");
- String[] lines = string.split("\n");
-
- for (int i = 0; i < lines.length; i++) {
- float w = c.getStringWidth(lines[i]) / 1000 * fontSize;
- if (maxWidth < w) {
- maxWidth = w;
- }
- }
- }
- else{
- return c.getStringWidth(string) / 1000 * fontSize;
- }
- case Entry.TYPE_IMAGE:
- if (style != null && style.getImageScaleToFit() != null) {
- return style.getImageScaleToFit().getWidth();
- }
- return 80.f;
- case Entry.TYPE_TABLE:
- PDFBoxTable pdfBoxTable = null;
- if (cell.getValue() instanceof Table) {
- pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this,
- this.settings, pdfBoxObject);
- cell.setValue(pdfBoxTable);
- } else if (cell.getValue() instanceof PDFBoxTable) {
- pdfBoxTable = (PDFBoxTable) cell.getValue();
- } else {
- throw new IOException("Failed to build PDFBox Table");
- }
- return pdfBoxTable.getWidth();
- default:
- logger.warn("Invalid Cell Entry Type: " + cell.getType());
- }
- return 0;
- }
-
- private String concatLines(String[] lines) {
- String v = "";
- for (int i = 0; i < lines.length; i++) {
- v += lines[i];
- if (i + 1 < lines.length) {
- v += "\n";
- }
- }
- return v;
- }
-
- private String[] breakString(String value, float maxwidth, PDFont font,
- float fontSize) throws IOException {
- String[] words = value.split(" ");
- List<String> lines = new ArrayList<String>();
- String cLineValue = "";
- for (int i = 0; i < words.length; i++) {
- String word = words[i];
- String[] lineBreaks = word.split("\n");
- if (lineBreaks.length > 1) {
- for (int j = 0; j < lineBreaks.length; j++) {
- String subword = lineBreaks[j];
- // if (cLine + subword.length() > maxline) {
- if (j == 0 && word.startsWith("\n")) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- } else if (j != 0) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- }
- // }
- String tmpLine = cLineValue + subword;
- tmpLine = tmpLine.replace(NBSPACE, " ");
-
- float size = font.getStringWidth(tmpLine) / 1000.0f
- * fontSize;
- if (size > maxwidth && cLineValue.length() != 0) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- }
- cLineValue += subword + " ";
- }
- } else {
- String tmpLine = cLineValue + word;
- tmpLine = tmpLine.replace(NBSPACE, " ");
-
- float size = font.getStringWidth(tmpLine) / 1000.0f * fontSize;
- if (size > maxwidth && cLineValue.length() != 0) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- }
- cLineValue += word + " ";
- }
- }
- lines.add(cLineValue.trim());
- for(int i=0;i<lines.size();i++){
- lines.set(i, lines.get(i).replace(NBSPACE, " "));
- }
- return lines.toArray(new String[0]);
- }
-
- private String[] breakString(String value, int maxline) {
- String[] words = value.split(" ");
- List<String> lines = new ArrayList<String>();
- int cLine = 0;
- String cLineValue = "";
- for (int i = 0; i < words.length; i++) {
- String word = words[i];
- String[] lineBreaks = word.split("\n");
- if (lineBreaks.length > 1) {
- for (int j = 0; j < lineBreaks.length; j++) {
- String subword = lineBreaks[j];
- // if (cLine + subword.length() > maxline) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- cLine = 0;
- // }
- cLineValue += subword + " ";
- cLine += subword.length();
- }
- } else {
- if (cLine + word.length() > maxline && cLineValue.length() != 0) {
- lines.add(cLineValue.trim());
- cLineValue = "";
- cLine = 0;
- }
- cLineValue += word + " ";
- cLine += word.length();
- }
- }
- lines.add(cLineValue.trim());
- return lines.toArray(new String[0]);
- }
-
- // private String[] breakString(String value, PDFont f, float maxwidth)
- // throws IOException {
- // String[] words = value.split(" ");
- // List<String> lines = new ArrayList<String>();
- // int cLine = 0;
- // String cLineValue = "";
- // for (int i = 0; i < words.length; i++) {
- // String word = words[i];
- // String[] lineBreaks = word.split("\n");
- // if (lineBreaks.length > 1) {
- // for (int j = 0; j < lineBreaks.length; j++) {
- // String subword = lineBreaks[j];
- // // if (cLine + subword.length() > maxline) {
- // lines.add(cLineValue.trim());
- // cLineValue = "";
- // cLine = 0;
- // // }
- // cLineValue += subword + " ";
- // cLine += subword.length();
- // }
- // } else {
- // if (f.getStringWidth(cLineValue + word) > maxwidth && cLineValue.length()
- // != 0) {
- // lines.add(cLineValue.trim());
- // cLineValue = "";
- // cLine = 0;
- // }
- // cLineValue += word + " ";
- // cLine += word.length();
- // }
- // }
- // lines.add(cLineValue.trim());
- // return lines.toArray(new String[0]);
- // }
-
- private float[] getStringHeights(String[] lines, PDFont c, float fontSize) {
- float[] heights = new float[lines.length];
- for (int i = 0; i < lines.length; i++) {
- float maxLineHeight = 0;
- try {
- byte[] linebytes = StringUtils.applyWinAnsiEncoding(lines[i]);
- for (int j = 0; j < linebytes.length; j++) {
- float he = c.getBoundingBox().getHeight() / 1000
- * fontSize;
- if (he > maxLineHeight) {
- maxLineHeight = he;
- }
- }
- } catch (IOException e) {
- logger.warn("failed to determine String height", e);
- maxLineHeight = c.getFontDescriptor().getCapHeight() / 1000
- * fontSize;
- }
-
- heights[i] = maxLineHeight;
- }
-
- return heights;
- }
-
- private float getCellHeight(Entry cell, float width) throws IOException,
- PdfAsException {
- boolean isValue = true;
- switch (cell.getType()) {
- case Entry.TYPE_CAPTION:
- isValue = false;
- case Entry.TYPE_VALUE:
- PDFont c = null;
- float fontSize;
- String string = (String) cell.getValue();
- if (isValue) {
- c = valueFont.getFont();//null
- fontSize = valueFont.getFontSize();
- } else {
- c = font.getFont();//null
- fontSize = font.getFontSize();
- }
-
- String[] lines = breakString(string, (width - padding * 2.0f), c,
- fontSize);
- cell.setValue(concatLines(lines));
- float[] heights = getStringHeights(lines, c, fontSize);
- return fontSize * heights.length + padding * 2;
- case Entry.TYPE_IMAGE:
- String imageFile = (String) cell.getValue();
- if (style != null && style.getImageScaleToFit() != null) {
- // if (style.getImageScaleToFit().getHeight() < width) {
- return style.getImageScaleToFit().getHeight() + padding * 2;
- // }
- }
- Dimension dim = ImageUtils.getImageDimensions(imageFile, settings);
- float wfactor = (float) ((width - padding * 2.0f) / dim.getWidth());
- float scaleFactor = wfactor;
- float iheight = (float) Math
- .floor((double) (scaleFactor * dim.getHeight()));
- //if (dim.getHeight() > 80.0f) {
- // return width + padding * 2;
- //}
- return (float) iheight + padding * 2;
- case Entry.TYPE_TABLE:
- PDFBoxTable pdfBoxTable = null;
- if (cell.getValue() instanceof Table) {
- pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this,
- width, this.settings, this.pdfBoxObject);
- cell.setValue(pdfBoxTable);
- } else if (cell.getValue() instanceof PDFBoxTable) {
- // recreate here beacuse of fixed width!
- pdfBoxTable = (PDFBoxTable) cell.getValue();
- pdfBoxTable = new PDFBoxTable(pdfBoxTable.table, this, width,
- this.settings, this.pdfBoxObject);
- cell.setValue(pdfBoxTable);
- } else {
- throw new IOException("Failed to build PDFBox Table");
- }
- return pdfBoxTable.getHeight();
- default:
- logger.warn("Invalid Cell Entry Type: " + cell.getType());
- }
- return 0;
- }
-
- private float getCellHeight(Entry cell) throws IOException, PdfAsException {
- boolean isValue = true;
- switch (cell.getType()) {
- case Entry.TYPE_CAPTION:
- isValue = false;
- case Entry.TYPE_VALUE:
- PDFont c = null;
- float fontSize;
- String string = (String) cell.getValue();
- if (isValue) {
- c = valueFont.getFont();//null
- fontSize = valueFont.getFontSize();
- } else {
- c = font.getFont();//null
- fontSize = font.getFontSize();
- }
-
- if (string.contains("\n")) {
- String[] lines = string.split("\n");
-
- return fontSize * lines.length + padding * 2;
- } else {
- return fontSize + padding * 2;
- }
- case Entry.TYPE_IMAGE:
- String imageFile = (String) cell.getValue();
- if (style != null && style.getImageScaleToFit() != null) {
- return style.getImageScaleToFit().getHeight() + padding * 2;
- }
- Dimension dim = ImageUtils.getImageDimensions(imageFile, settings);
- if (dim.getHeight() > 80.0f) {
- return 80.0f + padding * 2;
- }
- return (float) dim.getHeight() + padding * 2;
-
- case Entry.TYPE_TABLE:
- PDFBoxTable pdfBoxTable = null;
- if (cell.getValue() instanceof Table) {
- pdfBoxTable = new PDFBoxTable((Table) cell.getValue(), this,
- this.settings, pdfBoxObject);
- cell.setValue(pdfBoxTable);
- } else if (cell.getValue() instanceof PDFBoxTable) {
- pdfBoxTable = (PDFBoxTable) cell.getValue();
- } else {
- throw new IOException("Failed to build PDFBox Table");
- }
- return pdfBoxTable.getHeight();
- default:
- logger.warn("Invalid Cell Entry Type: " + cell.getType());
- }
- return 0;
- }
-
- public int getX() {
- return this.positionX;
- }
-
- public int getY() {
- return this.positionY;
- }
-
- public float getWidth() {
- return tableWidth;
- }
-
- public float getHeight() {
- return tableHeight;
- }
-
- public void setHeight(float height) {
- float diff = height - this.getHeight();
- if (diff > 0) {
- this.rowHeights[rowHeights.length - 1] += diff;
- calcTotals();
- } else {
- logger.warn("Table cannot be this small!");
- }
- }
-
- public float[] getRowHeights() {
- return rowHeights;
- }
-
- public int getRowCount() {
- return this.table.getRows().size();
- }
-
- public int getColCount() {
- return this.table.getMaxCols();// .getColsRelativeWith().length;
- }
-
- public float[] getColsRelativeWith() {
- return this.table.getColsRelativeWith();
- }
-
- public float getPadding() {
- return this.padding;
- }
-
- public void dumpTable() {
- logger.debug("=====================================================================");
- logger.debug("Information about: " + this.table.getName());
- logger.debug("\tDimensions: {} x {} (W x H)", this.tableWidth,
- this.tableHeight);
- logger.debug("\tPadding: {}", padding);
- logger.debug("\t================================");
- logger.debug("\tRow Heights:");
- for (int i = 0; i < rowHeights.length; i++) {
- logger.debug("\t[{}] : {}", i, this.rowHeights[i]);
- }
- logger.debug("\t================================");
- logger.debug("\tCol Widths:");
- for (int i = 0; i < colWidths.length; i++) {
- logger.debug("\t[{}] : {}", i, this.colWidths[i]);
- }
- logger.debug("\t================================");
- logger.debug("\tTable:");
- logger.debug("\t" + this.table.toString());
- logger.debug("=====================================================================");
- }
-
- public Table getOrigTable() {
- return this.table;
- }
-
- public ArrayList<Entry> getRow(int i) {
- return this.table.getRows().get(i);
- }
-
- public PDFBoxFont getFont() {
- return font;
- }
-
- public PDFBoxFont getValueFont() {
- return valueFont;
- }
-
- public Color getBGColor() {
- return this.bgColor;
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxStamper.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxStamper.java
deleted file mode 100644
index acb75560..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxStamper.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.io.IOException;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFStamper;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
-import at.gv.egiz.pdfas.lib.impl.status.PDFObject;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-import at.knowcenter.wag.egov.egiz.table.Table;
-
-public class PdfBoxStamper implements IPDFStamper<PDFBOXObject> {
-
-// private static final Logger logger = LoggerFactory.getLogger(PdfBoxStamper.class);
-
-// private PDFTemplateBuilder pdfBuilder;
-
- public PdfBoxStamper() {
-// this.pdfBuilder = new PDVisibleSigBuilder();
- }
-
- public IPDFVisualObject createVisualPDFObject(PDFBOXObject pdfboxObject, Table table) throws IOException {
- try {
- return new PdfBoxVisualObject(table, pdfboxObject.getStatus().getSettings(), pdfboxObject);
- } catch (PdfAsException e) {
- throw new PdfAsWrappedIOException(e);
- }
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxVisualObject.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxVisualObject.java
deleted file mode 100644
index 3a4c3957..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PdfBoxVisualObject.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
-import at.knowcenter.wag.egov.egiz.table.Table;
-
-public class PdfBoxVisualObject implements IPDFVisualObject {
-
- private static final Logger logger = LoggerFactory
- .getLogger(PdfBoxVisualObject.class);
-
- private Table abstractTable;
- private PDFBoxTable table;
- private float width;
- private float x;
- private float y;
- private int page;
- private ISettings settings;
- private PDFBOXObject pdfBoxObject;
-
- public PdfBoxVisualObject(Table table, ISettings settings, PDFBOXObject pdfBoxObject)
- throws IOException, PdfAsException {
- this.abstractTable = table;
- this.pdfBoxObject = pdfBoxObject;
- this.table = new PDFBoxTable(table, null, settings, pdfBoxObject);
- this.settings = settings;
- }
-
- public void setWidth(float width) {
- this.width = width;
- }
-
- public void fixWidth() {
- try {
- table = new PDFBoxTable(abstractTable, null, this.width, settings, this.pdfBoxObject);
- } catch (IOException e) {
- logger.warn("Failed to fix width of Table!", e);
- } catch (PdfAsException e) {
- logger.warn("Failed to fix width of Table!", e);
- }
- }
-
- public float getHeight() {
- return table.getHeight();
- }
-
- public float getWidth() {
- return table.getWidth();
- }
-
- public void setXPos(float x) {
- this.x = x;
- }
-
- public void setYPos(float y) {
- this.y = y;
- }
-
- public float getX() {
- return x;
- }
-
- public float getY() {
- return y;
- }
-
- public int getPage() {
- return page;
- }
-
- public void setPage(int page) {
- this.page = page;
- }
-
- public PDFBoxTable getTable() {
- return this.table;
- }
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/StamperFactory.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/StamperFactory.java
deleted file mode 100644
index 88a21c36..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/StamperFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFStamper;
-
-public class StamperFactory {
-
- //public static final String DEFAULT_STAMPER_CLASS = "at.gv.egiz.pdfas.stmp.itext.ITextStamper";
- public static final String DEFAULT_STAMPER_CLASS = "at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PdfBoxStamper";
-
- public static IPDFStamper<PDFBOXObject> createDefaultStamper(ISettings settings) throws PdfAsException {
- try {
- Class<?> cls = Class.forName(DEFAULT_STAMPER_CLASS);
- Object st = cls.getDeclaredConstructor().newInstance();
- if (!(st instanceof IPDFStamper))
- throw new ClassCastException();
- @SuppressWarnings("unchecked")
- IPDFStamper<PDFBOXObject> stamper = (IPDFStamper<PDFBOXObject>) st;
- return stamper;
- } catch (Throwable e) {
- throw new PdfAsException("error.pdf.stamp.10", e);
- }
- }
-} \ No newline at end of file
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/TableDrawUtils.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/TableDrawUtils.java
deleted file mode 100644
index 8df2ca59..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/TableDrawUtils.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDPageContentStream;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.knowcenter.wag.egov.egiz.table.Entry;
-import at.knowcenter.wag.egov.egiz.table.Style;
-
-public class TableDrawUtils {
-
- private static final Logger logger = LoggerFactory
- .getLogger(TableDrawUtils.class);
-
- public static final String TABLE_DEBUG = "debug.table";
-
- public static void drawTable(PDPage page,
- PDPageContentStream contentStream, float x, float y, float width,
- float height, PDFBoxTable abstractTable, PDDocument doc,
- boolean subtable, PDResources formResources,
- Map<String, ImageObject> images, ISettings settings, IDGenerator generator, PDFAsVisualSignatureProperties properties)
- throws PdfAsException {
-
- logger.debug("Drawing Table: X {} Y {} WIDTH {} HEIGHT {} \n{}", x, y,
- width, height, abstractTable.getOrigTable().toString());
-
- abstractTable.getOrigTable().setWidth(width);
-
- drawTableBackground(page, contentStream, x, y, width, height,
- abstractTable, settings);
-
- drawBorder(page, contentStream, x, y, width, height, abstractTable,
- doc, subtable, settings);
-//append strings
- drawContent(page, contentStream, x, y, width, height, abstractTable,
- doc, subtable, formResources, images, settings, generator, properties);
- }
-
- public static void drawContent(PDPage page,
- PDPageContentStream contentStream, float x, float y, float width,
- float height, PDFBoxTable abstractTable, PDDocument doc,
- boolean subtable, PDResources formResources,
- Map<String, ImageObject> images, ISettings settings, IDGenerator generator, PDFAsVisualSignatureProperties properties)
- throws PdfAsException {
-
- float contentx = x;
- float contenty = y + height;
- float padding = abstractTable.getPadding();
- float[] colsSizes = getColSizes(abstractTable);
- StringBuilder alternateTableCaption = new StringBuilder();
- for (int i = 0; i < abstractTable.getRowCount(); i++) {
- ArrayList<Entry> row = abstractTable.getRow(i);
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
-
- // Cell only contains default values so table style is the primary style
- Style inherit_style = Style.doInherit(abstractTable.style, cell.getStyle());
- cell.setStyle(inherit_style);
-
- float colWidth = 0;//colWidths[j];
-
- int colsleft = cell.getColSpan();
-
- if (j + colsleft > colsSizes.length) {
- throw new PdfAsException(
- "Configuration is wrong. Cannot determine column width!");
- }
-
- for (int k = 0; k < colsleft; k++) {
- colWidth = colWidth + colsSizes[j + k];
- }
-
- drawDebugPadding(contentStream, contentx, contenty, padding,
- colWidth, abstractTable.getRowHeights()[i], settings);
-
- switch (cell.getType()) {
- case Entry.TYPE_CAPTION:
- drawCaption(page, contentStream, contentx, contenty,
- colWidth, abstractTable.getRowHeights()[i],
- padding, abstractTable, doc, cell, formResources, settings);
- addToAlternateTableCaption(cell, alternateTableCaption);
- break;
- case Entry.TYPE_VALUE:
- drawValue(page, contentStream, contentx, contenty,
- colWidth, abstractTable.getRowHeights()[i],
- padding, abstractTable, doc, cell, formResources, settings);
- addToAlternateTableCaption(cell, alternateTableCaption);
- break;
- case Entry.TYPE_IMAGE:
- drawImage(page, contentStream, contentx, contenty,
- colWidth, abstractTable.getRowHeights()[i],
- padding, abstractTable, doc, cell, formResources,
- images, settings, generator);
- break;
- case Entry.TYPE_TABLE:
-
- PDFBoxTable tbl_value = (PDFBoxTable) cell.getValue();
-
- Style inherit_styletab = Style.doInherit(
- abstractTable.style, cell.getStyle());
- tbl_value.table.setStyle(inherit_styletab);
-
- drawTable(page, contentStream, contentx, contenty
- - abstractTable.getRowHeights()[i], colWidth,
- abstractTable.getRowHeights()[i], tbl_value, doc,
- true, formResources, images, settings, generator,properties);
- break;
- default:
- logger.warn("Unknown Cell entry type: " + cell.getType());
- break;
- }
-
- // Move content pointer
- contentx += colWidth;
-
- int span = cell.getColSpan() - 1;
- j += span;
- }
-
- // Move content pointer
- contenty -= abstractTable.getRowHeights()[i];
- contentx = x;
- }
- properties.setAlternativeTableCaption(alternateTableCaption.toString());
- }
-
- private static void drawString(PDPage page,
- PDPageContentStream contentStream, float contentx, float contenty,
- float width, float height, float padding,
- PDFBoxTable abstractTable, PDDocument doc, Entry cell,
- float fontSize, float textHeight, String valign, String halign,
- String[] tlines, PDFont textFont, PDResources formResources,
- ISettings settings) throws PdfAsException {
- try {
- float ty = contenty - padding;
- float tx = contentx + padding;
- float innerHeight = height - (2 * padding);
- float innerWidth = width - (2 * padding);
- if (Style.BOTTOM.equals(valign)) {
- float bottom_offset = innerHeight - textHeight;
- ty -= bottom_offset;
- } else if (Style.MIDDLE.equals(valign)) {
- float bottom_offset = innerHeight - textHeight;
- bottom_offset = bottom_offset / 2.0f;
- ty -= bottom_offset;
- }
-
- float descent=0;
- float ascent;
- float lineWidth=0;
- float txNew=0;
-
-
- if (tlines.length>1&&Style.LINECENTER.equals(halign)) {
-
- //Calculate TXs
- ArrayList<Float> calculatedTXs = new ArrayList<>();
- for (int k = 0; k < tlines.length; k++) {
-
-
-
- // if (textFont instanceof PDType1Font) {
- lineWidth = textFont.getStringWidth(tlines[k]) / 1000.0f
- * fontSize;
- txNew = (innerWidth-lineWidth)/2.0f;
- logger.debug("calculatedTXNew in k-Loop: {} {}", k, txNew);
- calculatedTXs.add(tx+txNew);
-
- logger.debug("INNERWIDTH in drawString: "+innerWidth);
- logger.debug("TX in drawString: "+tx);
-
- ascent = textFont.getFontDescriptor().getAscent();
- descent = textFont.getFontDescriptor().getDescent();
- ascent = ascent / 1000.0f * fontSize;
- descent = descent / 1000.0f * fontSize;
-
- //ty = ty + (descent * (-1));
-
- logger.debug("Text txNew {} ty {} lineWidth {} textHeight {}", txNew, ty,
- lineWidth, textHeight);
- logger.debug("Text ASCENT {} DESCENT {}", ascent, descent);
-
- logger.debug("Text TRANSFORMED ASCENT {} DESCENT {}", ascent, descent);
- drawDebugLineString(contentStream, txNew, ty, lineWidth, textHeight, descent, settings);
- }
-
-
- contentStream.beginText();
- contentStream.setFont(textFont, fontSize);
- txNew=tx+calculatedTXs.get(0);
- logger.debug("Calculated TX0: "+txNew);
- //contentStream.newLineAtOffset(txNew, (ty - fontSize + (descent * (-1))));
-
- /*
- if (formResources.getFont(COSName.getPDFName(textFont.getName())) != null) {
- String fontID = getFontID(textFont, formResources);
- logger.debug("Using Font: " + fontID);
- contentStream.appendRawCommands("/" + fontID + " " + fontSize
- + " Tf\n");
- } else {
- contentStream.setFont(textFont, fontSize);
- }
-
- logger.debug("Writing: " + tx + " : " + (ty - fontSize + (descent * (-1))) + " as "
- + cell.getType());
- contentStream.moveTextPositionByAmount(tx, (ty - fontSize + (descent * (-1))));
-
- contentStream.appendRawCommands(fontSize + " TL\n");
- */
-
-
- for (int k = 0; k < tlines.length; k++) {
- float offset = calculatedTXs.get(k);
- if (k==0)
- {
- contentStream.newLineAtOffset(offset, (ty - fontSize + (descent * (-1))));
-
- }else {
- logger.debug("Calculated TX: {} {} ", k, offset);
- contentStream.newLineAtOffset(offset, -1 * fontSize);
- } //contentStream.appendRawCommands("T*\n");
-
- contentStream.showText(tlines[k]);
-
-
- contentStream.newLineAtOffset(-1 * offset, 0);
- }
- contentStream.endText();
-
- }else
- {
- // calculate the max with of the text content
- float maxWidth = 0;
- for (int k = 0; k < tlines.length; k++) {
-
- // if (textFont instanceof PDType1Font) {
- lineWidth = textFont.getStringWidth(tlines[k]) / 1000.0f
- * fontSize;
- /*
- * } else { float fwidth = textFont
- * .getStringWidth("abcdefghijklmnopqrstuvwxyz ") / 1000.0f *
- * fontSize; fwidth = fwidth / (float)
- * "abcdefghijklmnopqrstuvwxyz" .length(); lineWidth =
- * tlines[k].length() * fwidth; }
- */
- if (maxWidth < lineWidth) {
- maxWidth = lineWidth;
- }
- }
-
- if (Style.CENTER.equals(halign)||Style.LINECENTER.equals(halign)) {
- float offset = innerWidth - maxWidth;
- if (offset > 0) {
- offset = offset / 2.0f;
- tx += offset;
- }
- } else if (Style.RIGHT.equals(halign)) {
- float offset = innerWidth - maxWidth;
- if (offset > 0) {
- tx += offset;
- }
- }
- ascent = textFont.getFontDescriptor().getAscent();
- descent = textFont.getFontDescriptor().getDescent();
-
- ascent = ascent / 1000.0f * fontSize;
- descent = descent / 1000.0f * fontSize;
-
- //ty = ty + (descent * (-1));
-
- logger.debug("Text tx {} ty {} maxWidth {} textHeight {}", tx, ty,
- maxWidth, textHeight);
- logger.debug("Text ASCENT {} DESCENT {}", ascent, descent);
-
- logger.debug("Text TRANSFORMED ASCENT {} DESCENT {}", ascent, descent);
-
- drawDebugLineString(contentStream, tx, ty, maxWidth, textHeight, descent, settings);
-
- contentStream.beginText();
-
- contentStream.setFont(textFont, fontSize);
- contentStream.newLineAtOffset(tx, (ty - fontSize + (descent * (-1))));
- /*
- if (formResources.getFont(COSName.getPDFName(textFont.getName())) != null) {
- String fontID = getFontID(textFont, formResources);
- logger.debug("Using Font: " + fontID);
- contentStream.appendRawCommands("/" + fontID + " " + fontSize
- + " Tf\n");
- } else {
- contentStream.setFont(textFont, fontSize);
- }
-
- logger.debug("Writing: " + tx + " : " + (ty - fontSize + (descent * (-1))) + " as "
- + cell.getType());
- contentStream.moveTextPositionByAmount(tx, (ty - fontSize + (descent * (-1))));
-
- contentStream.appendRawCommands(fontSize + " TL\n");
- */
-
- if(textFont.willBeSubset()) {
- logger.debug("Font will be subset!");
- }
-
- for (int k = 0; k < tlines.length; k++) {
- contentStream.showText(tlines[k]);
- if (k < tlines.length - 1) {
- contentStream.newLineAtOffset(0, -1 * fontSize );
- //contentStream.appendRawCommands("T*\n");
- }
- }
-
- contentStream.endText();}
-
- } catch (IOException e) {
- logger.warn("IO Exception", e);
- throw new PdfAsException("Error", e);
- }
- }
-
- public static void drawCaption(PDPage page,
- PDPageContentStream contentStream, float contentx, float contenty,
- float width, float height, float padding,
- PDFBoxTable abstractTable, PDDocument doc, Entry cell,
- PDResources formResources, ISettings settings)
- throws PdfAsException {
-
- logger.debug("Drawing Caption @ X: {} Y: {}", contentx, contenty);
-
- try {
- float fontSize = PDFBoxFont.defaultFontSize;
- PDFont textFont = PDFBoxFont.defaultFont;
-
- textFont = abstractTable.getFont().getFont();//doc);
- fontSize = abstractTable.getFont().getFontSize();
-
- // get the cell Text
- String text = (String) cell.getValue();
- String[] tlines = text.split("\n");
- float textHeight = fontSize * tlines.length;
-
- Style cellStyle = cell.getStyle();
- String valign = cellStyle.getVAlign();
- String halign = cellStyle.getHAlign();
-
- drawString(page, contentStream, contentx, contenty, width, height,
- padding, abstractTable, doc, cell, fontSize, textHeight,
- valign, halign, tlines, textFont, formResources, settings);
- } catch (IOException e) {
- logger.warn("IO Exception", e);
- throw new PdfAsException("Error", e);
- }
- }
-
- public static void drawValue(PDPage page,
- PDPageContentStream contentStream, float contentx, float contenty,
- float width, float height, float padding,
- PDFBoxTable abstractTable, PDDocument doc, Entry cell,
- PDResources formResources, ISettings settings)
- throws PdfAsException {
-
- logger.debug("Drawing Value @ X: {} Y: {}", contentx, contenty);
-
- try {
- float fontSize = PDFBoxFont.defaultFontSize;
- PDFont textFont = PDFBoxFont.defaultFont;
-
- textFont = abstractTable.getValueFont().getFont();//doc);
- fontSize = abstractTable.getValueFont().getFontSize();
-
- // get the cell Text
- String text = (String) cell.getValue();
- String[] tlines = text.split("\n");
- float textHeight = fontSize * tlines.length;
-
- Style cellStyle = cell.getStyle();
- String valign = cellStyle.getValueVAlign();
- String halign = cellStyle.getValueHAlign();
-
- drawString(page, contentStream, contentx, contenty, width, height,
- padding, abstractTable, doc, cell, fontSize, textHeight,
- valign, halign, tlines, textFont, formResources, settings);
- } catch (IOException e) {
- logger.warn("IO Exception", e);
- throw new PdfAsException("Error", e);
- }
- }
-
- public static void drawImage(PDPage page,
- PDPageContentStream contentStream, float contentx, float contenty,
- float width, float height, float padding,
- PDFBoxTable abstractTable, PDDocument doc, Entry cell,
- PDResources formResources, Map<String, ImageObject> images,
- ISettings settings, IDGenerator generator) throws PdfAsException {
- try {
- float innerHeight = height;
- float innerWidth = width;
-
- String img_ref = generator.createHashedId((String) cell.getValue());
- if (!images.containsKey(img_ref)) {
- logger.warn("Image not prepared! : " + img_ref);
- throw new PdfAsException("Image not prepared! : " + img_ref);
- }
- ImageObject image = images.get(img_ref);
- PDImageXObject pdImage = image.getImage();
-
-
- float imgx = contentx;
- float hoffset = innerWidth - image.getWidth();
- if (cell.getStyle().getImageHAlign() != null
- && cell.getStyle().getImageHAlign().equals(Style.LEFT)) {
- hoffset = hoffset / 2.0f;
- imgx += hoffset;
- } else if (cell.getStyle().getImageHAlign() != null
- && cell.getStyle().getImageHAlign().equals(Style.RIGHT)) {
- imgx += hoffset;
- } else {
- hoffset = hoffset / 2.0f;
- imgx += hoffset;
- }
-
- float imgy = contenty;
- float voffset = innerHeight - image.getHeight();
- if (cell.getStyle().getImageVAlign() != null
- && cell.getStyle().getImageVAlign().equals(Style.MIDDLE)) {
- voffset = voffset / 2.0f;
- imgy -= voffset;
- } else if (cell.getStyle().getImageVAlign() != null
- && cell.getStyle().getImageVAlign().equals(Style.BOTTOM)) {
- imgy -= voffset;
- }
-
- drawDebugLine(contentStream, imgx, imgy, image.getWidth(),
- image.getHeight(), settings);
-
- // logger.debug("Image: " + imgx + " : " + (imgy -
- // image.getHeight()));
- contentStream.drawXObject(pdImage, imgx, imgy - image.getHeight(),
- image.getWidth(), image.getHeight());
- } catch (IOException e) {
- logger.warn("IO Exception", e);
- throw new PdfAsException("Error", e);
- }
-
- }
-
- public static float[] getColSizes(PDFBoxTable abstractTable) {
- float[] origcolsSizes = abstractTable.getColsRelativeWith();
- int max_cols = abstractTable.getColCount();
- float[] colsSizes = new float[max_cols];
- if (origcolsSizes == null) {
- // set the column ratio for all columns to 1
- Arrays.fill(colsSizes, 1);
- } else {
- // set the column ratio for all columns to 1
- System.arraycopy(origcolsSizes, 0, colsSizes, 0, colsSizes.length);
- }
-
- // adapt
- float total = 0;
-
- for (float colsSize : colsSizes) {
- total += colsSize;
- }
-
- for (int cols_idx = 0; cols_idx < colsSizes.length; cols_idx++) {
- colsSizes[cols_idx] = (colsSizes[cols_idx] / total)
- * abstractTable.getWidth();
- }
-
- float sum = 0;
-
- for (float colsSize : colsSizes) {
- sum += colsSize;
- }
-
- logger.debug("Table Col Sizes SUM {} Table Width {}", sum,
- abstractTable.getWidth());
- logger.debug("Table Table Height {}", abstractTable.getHeight());
-
- return colsSizes;
- }
-
- private static void drawLine(PDPageContentStream stream, float startX, float startY, float endX, float endY)
- throws IOException
- {
- stream.moveTo(startX, startY);
- stream.lineTo(endX, endY);
- stream.stroke();
- }
-
- public static void drawBorder(PDPage page,
- PDPageContentStream contentStream, float x, float y, float width,
- float height, PDFBoxTable abstractTable, PDDocument doc,
- boolean subtable, ISettings settings) throws PdfAsException {
- try {
-
- logger.debug("Drawing Table borders for "
- + abstractTable.getOrigTable().getName());
-
- final int rows = abstractTable.getRowCount();
- float border = abstractTable.style.getBorder();
- float[] colsSizes = getColSizes(abstractTable);
-
- if (border > 0) {
- contentStream.setLineWidth(border);
-
- float x_from = x;
- float x_to = x + width;
- float y_from = y + height;
- float y_to = y + height;
-
- // draw first line
- logger.debug("ROW LINE: {} {} {} {}", x_from, y_from, x_to,
- y_from);
- drawLine(contentStream, x, y_from, x_to, y_from);
-
- // Draw all row borders
- for (int i = 0; i < rows; i++) {
- y_from -= abstractTable.getRowHeights()[i];
-
- // Draw row border!
- logger.debug("ROW LINE: {} {} {} {}", x_from, y_from, x_to,
- y_from);
- drawLine(contentStream, x, y_from, x_to, y_from);
-
- }
-
- // reset y for "line feed"
- y_from = y + height;
- y_to = y_from - abstractTable.getRowHeights()[0];
-
- // Draw all column borders
- for (int i = 0; i < rows; i++) {
- ArrayList<Entry> row = abstractTable.getRow(i);
-
- // reset x for "line feed"
- x_from = x;
-
- // draw first line
- logger.debug("COL LINE: {} {} {} {}", x_from, y_from,
- x_from, y_to);
-
- drawLine(contentStream, x_from, y_from, x_from, y_to);
-
- for (int j = 0; j < row.size(); j++) {
- Entry cell = (Entry) row.get(j);
-
- for (int k = 0; k < cell.getColSpan(); k++) {
- if (k + j < colsSizes.length) {
- x_from += colsSizes[k + j];
- }
- }
- logger.debug("COL LINE: {} {} {} {}", x_from, y_from,
- x_from, y_to);
- drawLine(contentStream, x_from, y_from, x_from, y_to);
- }
-
- if (i + 1 < rows) {
- y_from = y_to;
- y_to = y_from - abstractTable.getRowHeights()[i + 1];
- }
- }
-
- }
- } catch (Throwable e) {
- logger.warn("drawing table borders", e);
- throw new PdfAsException("drawing table borders", e);
- }
- }
-
- public static void drawTableBackground(PDPage page,
- PDPageContentStream contentStream, float x, float y, float width,
- float height, PDFBoxTable abstractTable, ISettings settings)
- throws PdfAsException {
- try {
- if (abstractTable.getBGColor() != null) {
- contentStream.setNonStrokingColor(abstractTable.getBGColor());
- contentStream
- .addRect(x, y, abstractTable.getWidth(), abstractTable.getHeight());
- contentStream.fill();
- contentStream.setNonStrokingColor(Color.BLACK);
- }
- } catch (Throwable e) {
- logger.warn("drawing table borders", e);
- throw new PdfAsException("drawing table borders", e);
- }
- }
-
- private static void drawDebugLine(PDPageContentStream contentStream,
- float x, float y, float width, float height, ISettings settings) {
- if ("true".equals(settings.getValue(TABLE_DEBUG))) {
- try {
- contentStream.setStrokingColor(Color.RED);
- drawLine(contentStream, x, y, x + width, y);
- contentStream.setStrokingColor(Color.BLUE);
- drawLine(contentStream, x, y, x, y - height);
- contentStream.setStrokingColor(Color.GREEN);
- drawLine(contentStream, x + width, y, x + width, y - height);
- contentStream.setStrokingColor(Color.ORANGE);
- drawLine(contentStream, x, y - height, x + width, y - height);
-
- contentStream.setStrokingColor(Color.BLACK);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
- private static void drawDebugLineString(PDPageContentStream contentStream,
- float x, float y, float width, float height, float descent, ISettings settings) {
- if ("true".equals(settings.getValue(TABLE_DEBUG))) {
- try {
- contentStream.setStrokingColor(Color.RED);
- drawLine(contentStream, x, y, x + width, y);
- contentStream.setStrokingColor(Color.BLUE);
- drawLine(contentStream, x, y, x, y - height);
- contentStream.setStrokingColor(Color.GREEN);
- drawLine(contentStream, x + width, y, x + width, y - height);
- contentStream.setStrokingColor(Color.ORANGE);
- drawLine(contentStream, x, y - height, x + width, y - height);
- contentStream.setStrokingColor(Color.MAGENTA);
- drawLine(contentStream, x, y + (descent * (-1)) - height, x + width, y + (descent * (-1)) - height);
-
- contentStream.setStrokingColor(Color.BLACK);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
- private static void drawDebugPadding(PDPageContentStream contentStream,
- float x, float y, float padding, float width, float height,
- ISettings settings) {
- if ("true".equals(settings.getValue(TABLE_DEBUG))) {
- try {
- contentStream.setStrokingColor(Color.RED);
- drawLine(contentStream, x, y, x + padding, y - padding);
- drawLine(contentStream, x + width, y, x + width - padding, y
- - padding);
- drawLine(contentStream, x + width, y - height, x + width
- - padding, y - height + padding);
- drawLine(contentStream, x, y - height, x + padding, y - height
- + padding);
- contentStream.setStrokingColor(Color.BLACK);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
- private static String getFontID(PDFont font, PDResources resources) {
-// Iterator<java.util.Map.Entry<String, PDFont>> it = resources.getfon
-// .entrySet().iterator();
- Iterator<COSName> it = resources.getFontNames().iterator();
- while (it.hasNext()) {
- COSName entry = it.next();
- if (entry.getName().equals(font.getName())) {
- return entry.getName();
- }
- }
- return "";
- }
-
- private static void addToAlternateTableCaption(Entry cell, StringBuilder alternateTableCaption){
- alternateTableCaption.append(cell.getValue());
- alternateTableCaption.append("\n");//better for screen reader
- }
-
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/pdfbox2/PDFBOXVerifier.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/pdfbox2/PDFBOXVerifier.java
deleted file mode 100644
index 0c943027..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/verify/pdfbox2/PDFBOXVerifier.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package at.gv.egiz.pdfas.lib.impl.verify.pdfbox2;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import at.gv.egiz.pdfas.lib.impl.verify.*;
-import org.apache.commons.io.IOUtils;
-import org.apache.pdfbox.cos.COSArray;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSString;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PDFASError;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
-import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
-import at.gv.egiz.pdfas.lib.impl.ErrorExtractor;
-
-public class PDFBOXVerifier implements VerifyBackend {
-
- private static final Logger logger = LoggerFactory.getLogger(PDFBOXVerifier.class);
-
- @Override
- public List<VerifyResult> verify(VerifyParameter parameter) throws PDFASError {
- int signatureToVerify = parameter.getWhichSignature();
-
- PDDocument doc = null;
- try {
- List<VerifyResult> result = new ArrayList<VerifyResult>();
- ISettings settings = (ISettings) parameter.getConfiguration();
- VerifierDispatcher verifier = new VerifierDispatcher(settings);
- doc = PDDocument.load(parameter.getDataSource().getInputStream());
-
- COSDictionary trailer = doc.getDocument().getTrailer();
- if (trailer == null) {
- // No signatures ...
- return result;
- }
- COSDictionary root = (COSDictionary) trailer.getDictionaryObject(COSName.ROOT);
- if (root == null) {
- // No signatures ...
- return result;
- }
- COSDictionary acroForm = (COSDictionary) root.getDictionaryObject(COSName.ACRO_FORM);
- if (acroForm == null) {
- // No signatures ...
- return result;
- }
- COSArray fields = (COSArray) acroForm.getDictionaryObject(COSName.FIELDS);
- if (fields == null) {
- // No signatures ...
- return result;
- }
-
- int lastSig = selectLastSigIndex(fields);
- byte[] inputData = IOUtils.toByteArray(parameter.getDataSource().getInputStream());
-
- int currentSignature = 0;
- for (int i = 0; i < fields.size(); i++) {
- COSDictionary field = (COSDictionary) fields.getObject(i);
- String type = field.getNameAsString("FT");
- if ("Sig".equals(type)) {
- if (verifyCurrentSig(signatureToVerify, i, lastSig, currentSignature)) {
- logger.trace("Found Signature Form: ");
- COSBase base = field.getDictionaryObject("V");
- if (base != null) {
- checkTechicalSig(base, inputData, verifier, parameter, result, i);
-
- } else {
- logger.info("Skipping signature form, because it looks empty");
-
- }
-
- }
-
- currentSignature++;
- }
- }
- return result;
-
- } catch (IOException e) {
- logger.warn("Failed to verify document", e);
- throw ErrorExtractor.searchPdfAsError(e, null);
-
- } catch (PdfAsException e) {
- logger.warn("Failed to verify document", e);
- throw ErrorExtractor.searchPdfAsError(e, null);
-
- } finally {
- if (doc != null) {
- try {
- doc.close();
-
- } catch (IOException e) {
- logger.info("Failed to close doc");
-
- }
- }
- }
- }
-
- private boolean verifyCurrentSig(int signatureToVerify, int i, int lastSig, int currentSignature) {
- if (signatureToVerify >= 0) {
- // verify only specific siganture!
- return signatureToVerify == currentSignature;
-
- }
-
- if (signatureToVerify == -2) {
- return i == lastSig;
-
- }
-
- return true;
- }
-
- private int selectLastSigIndex(COSArray fields) {
- int lastSig = -1;
- for (int i = 0; i < fields.size(); i++) {
- COSDictionary field = (COSDictionary) fields.getObject(i);
- String type = field.getNameAsString("FT");
- if ("Sig".equals(type)) {
- lastSig = i;
- }
- }
-
- return lastSig;
-
- }
-
- private void checkTechicalSig(COSBase base, byte[] inputData, VerifierDispatcher verifier, VerifyParameter parameter,
- List<VerifyResult> result, int i) throws IOException, PdfAsException {
- try {
- COSDictionary dict = (COSDictionary) base;
-
- logger.debug("Signer: " + dict.getNameAsString("Name"));
- logger.debug("SubFilter: " + dict.getNameAsString("SubFilter"));
- logger.debug("Filter: " + dict.getNameAsString("Filter"));
- logger.debug("Modified: " + dict.getNameAsString("M"));
- COSArray byteRange = (COSArray) dict.getDictionaryObject("ByteRange");
-
- StringBuilder sb = new StringBuilder();
- final int[] bytes = new int[byteRange.size()];
- for (int j = 0; j < byteRange.size(); j++) {
- bytes[j] = byteRange.getInt(j);
- sb.append(" " + bytes[j]);
- }
-
- logger.debug("ByteRange" + sb.toString());
-
- COSString content = (COSString) dict.getDictionaryObject("Contents");
-
- IVerifyFilter verifyFilter = verifier.getVerifier(dict.getNameAsString("Filter"),
- dict.getNameAsString("SubFilter"));
-
- IVerifier lvlVerifier = verifier.getVerifierByLevel(parameter.getSignatureVerificationLevel());
- synchronized (lvlVerifier) {
- lvlVerifier.setConfiguration(parameter.getConfiguration());
- if (verifyFilter != null) {
- List<VerifyResult> results = verifyFilter.verify(new SignatureInputData(inputData, bytes),
- content.getBytes(), parameter.getVerificationTime(), lvlVerifier);
- if (results != null && !results.isEmpty()) {
- result.addAll(results);
- }
- }
- }
-
- } catch (NullPointerException e) {
- logger.info("Verification of signature #{} failed with generic error", i);
- }
-
- }
-
-}
-
-
-
-
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFPage.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFPage.java
deleted file mode 100644
index c49d99a5..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFPage.java
+++ /dev/null
@@ -1,660 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- *
- * $Id: PDFPage.java,v 1.5 2006/10/31 08:09:33 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf;
-
-import java.awt.Rectangle;
-import java.awt.geom.GeneralPath;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSStream;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.PDResources;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.font.PDFont;
-import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
-import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
-import org.apache.pdfbox.text.PDFTextStripper;
-import org.apache.pdfbox.text.TextPosition;
-import org.apache.pdfbox.util.Matrix;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.knowcenter.wag.egov.egiz.pdf.Pos;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.ClosePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.CurveTo;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.CurveToReplicateFinalPoint;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.CurveToReplicateInitialPoint;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.LineTo;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.MoveTo;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.CloseAndStrokePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.CloseFillEvenOddAndStrokePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.CloseFillNonZeroAndStrokePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.EndPath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.FillEvenOddAndStrokePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.FillNonZeroAndStrokePath;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.FillPathEvenOddRule;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.FillPathNonZeroWindingNumberRule;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting.StrokePath;
-
-/**
- * PDFPage is an inner class that is used to calculate the page length of a PDF
- * Document page. It extends the PDFTextStripper class and implement one
- * interested method:
- * {@link at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage#showCharacter(TextPosition)}<br>
- * This method is called when processing the FileStream. By calling the method
- * {@link org.apache.pdfbox.util.PDFStreamEngine#processStream(org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.PDResources, org.pdfbox.cos.COSStream)}
- * the implemented method showCharacter is called.
- *
- * @author wlackner
- * @see PDFTextStripper
- */
-public class PDFPage extends PDFTextStripper{
- /**
- * The logger definition.
- */
- private static final Logger logger = LoggerFactory.getLogger(PDFPage.class);
-
- /**
- * The maximum (lowest) y position of a character.
- */
- protected float max_character_ypos = Float.NEGATIVE_INFINITY;
-
- /**
- * The maximum (lowest y position of an image.
- */
- protected float max_image_ypos = Float.NEGATIVE_INFINITY;
-
- /**
- * The effective page height.
- */
- protected float effectivePageHeight;
-
- /**
- * The path currently being constructed.
- * -- SETTER --
- * Sets the current path.
- *
- *
- * -- GETTER --
- * Returns the path currently being constructed.
- *
- @param currentPath
- * The new current path.
- * @return The path currently being constructed.
-
- */
- @Getter
- @Setter
- private GeneralPath currentPath = new GeneralPath();
-
- private boolean legacy40;
-
- /**
- * The lowest position of a drawn path (originating from top).
- */
- private float maxPathRelatedYPositionFromTop = Float.NEGATIVE_INFINITY;
-
- /**
- * Constructor.
- *
- * @param effectivePageHeight
- * The height of the page to be evaluated. PDF elements outside
- * this height will not be considered.
- *
- * @throws java.io.IOException
- */
- public PDFPage(float effectivePageHeight, boolean legacy32, boolean legacy40)
- throws IOException {
- super();
-
- this.legacy40 = legacy40;
-
- this.effectivePageHeight = effectivePageHeight;
-
- OperatorProcessor newInvoke = new MyInvoke(this);
- this.addOperator(newInvoke);
-
- if (!legacy32) {
- registerCustomPathOperators();
- }
- }
-
- /**
- * Registers operators responsible for path construction and painting in
- * order to fix auto positioning on pages with path elements.
- *
- * @author Datentechnik Innovation GmbH
- */
- private void registerCustomPathOperators() {
-
- // *** path construction
- this.addOperator(new MoveTo(this));
- this.addOperator(new LineTo(this));
- this.addOperator(new CurveTo(this));
- this.addOperator(new CurveToReplicateFinalPoint(this));
- this.addOperator(new CurveToReplicateInitialPoint(this));
- this.addOperator(new ClosePath(this));
-
- // *** path painting
-
- // "S": stroke path
- this.addOperator(new StrokePath(this));
- this.addOperator(new CloseAndStrokePath(this));
- this.addOperator(new FillPathNonZeroWindingNumberRule(this, true));
- this.addOperator(new FillPathNonZeroWindingNumberRule(this, false));
- this.addOperator(new FillPathEvenOddRule(this));
- this.addOperator(new CloseFillNonZeroAndStrokePath(this));
- this.addOperator(new FillNonZeroAndStrokePath(this));
- this.addOperator(new CloseFillEvenOddAndStrokePath(this));
- this.addOperator(new FillEvenOddAndStrokePath(this));
- this.addOperator(new EndPath(this));
-
- // Note: The graphic context
- // (org.pdfbox.pdmodel.graphics.PDGraphicsState) of the underlying
- // pdfbox library does
- // not yet support clipping. This prevents feasible usage of clipping
- // operators (W, W*).
- // operators.put("W", new ...(this));
- // operators.put("W*", new ...(this));
-
- }
-
- /**
- * Registers a rectangle that bounds the path currently being drawn.
- *
- * @param bounds
- * A rectangle depicting the bounds (coordinates originating from
- * bottom left).
- * @author Datentechnik Innovation GmbH
- */
- public void registerPathBounds(Rectangle bounds) {
- if (!bounds.isEmpty()) {
- logger.debug("Registering path bounds: " + bounds);
-
- // vertical start of rectangle (counting from top of page)
- float upperBoundYPositionFromTop;
-
- // vertical end of rectangle (counting from top of page)
- // this depicts the current end of path-related page content
- float lowerBoundYPositionFromTop;
-
- PDRectangle boundaryBox = this.getCurrentPage().getCropBox();
-
- if (boundaryBox == null) {
- boundaryBox = this.getCurrentPage().getMediaBox();
- }
-
- float pageHeight;
-
- switch (this.getCurrentPage().getRotation()) {
- case 90: // CW
- pageHeight = boundaryBox.getWidth();
- upperBoundYPositionFromTop = (float) bounds.getMinX();
- lowerBoundYPositionFromTop = (float) bounds.getMaxX();
- break;
- case 180:
- pageHeight = boundaryBox.getHeight();
- upperBoundYPositionFromTop = (float) bounds.getMinY();
- lowerBoundYPositionFromTop = (float) bounds.getMaxY();
- break;
- case 270: // CCW
- pageHeight = boundaryBox.getWidth();
- upperBoundYPositionFromTop = pageHeight
- - (float) bounds.getMaxX();
- lowerBoundYPositionFromTop = pageHeight
- - (float) bounds.getMinX();
- break;
- default:
- pageHeight = boundaryBox.getHeight();
- upperBoundYPositionFromTop = pageHeight
- - (float) bounds.getMaxY();
- lowerBoundYPositionFromTop = pageHeight
- - (float) bounds.getMinY();
- break;
- }
-
- // new maximum ?
- if (lowerBoundYPositionFromTop > maxPathRelatedYPositionFromTop) {
- // Is the rectangle (at least partly) located above the footer
- // line?
- // (effective page height := page height - footer line)
- if (upperBoundYPositionFromTop <= effectivePageHeight) {
- // yes: update current end of path-related page content
- maxPathRelatedYPositionFromTop = lowerBoundYPositionFromTop;
- logger.trace("New max path related y position (from top): "
- + maxPathRelatedYPositionFromTop);
- } else {
- // no: rectangle is fully located below the footer line ->
- // ignore
- logger.trace("Ignoring path bound below the footer line.");
- }
- }
- }
- }
-
- protected void processOperator(Operator operator, List<COSBase> arguments)
- throws IOException {
- logger.trace("operator = " + operator);
- super.processOperator(operator, arguments);
- }
-
- @Override
- protected void processTextPosition(TextPosition text) {
- showCharacter(text);
- }
-
- // exthex
- /**
- * A method provided as an event interface to allow a subclass to perform
- * some specific functionality when a character needs to be displayed. This
- * method is used to calculate the latest position of a text in the page.
- * Sorry for this missinterpretation of the method, but it is the only way
- * to do this (provided by PDFBox)!!!
- *
- * @param text
- * the character to be displayed -> calculate there y position.
- */
- protected void showCharacter(TextPosition text) {
- float current_y = text.getY();
- final String character = text.toString();
-
- if (at.gv.egiz.pdfas.common.utils.StringUtils.whiteSpaceTrim(character)
- .isEmpty()) {
- return;
- }
-
- int pageRotation = this.getCurrentPage().getRotation();
- // logger_.debug("PageRotation = " + pageRotation);
- /*if (pageRotation == 0) {
- current_y = text.getY();
- }
- if (pageRotation == 90) {
- current_y = text.getY();
- }
- if (pageRotation == 180) {
- current_y = text.getY();
- }
- if (pageRotation == 270) {
- current_y = text.getY();
- }
-
- if (current_y > this.effectivePageHeight) {
- this.max_character_ypos = this.effectivePageHeight;
- return;
- }
-
- // store ypos of the char if it is not empty
- if (current_y > this.max_character_ypos) {
- this.max_character_ypos = current_y;
- }*/
-
- if (pageRotation == 0) {
- current_y = text.getY();
- }
- if (pageRotation == 90) {
- current_y = text.getX();
- }
- if (pageRotation == 180) {
- float page_height = this.getCurrentPage().getMediaBox().getHeight();
- current_y = page_height - text.getY();
- }
- if (pageRotation == 270) {
- float page_height = this.getCurrentPage().getMediaBox().getHeight();
- current_y = page_height - text.getX();
- }
-
- if (current_y > this.effectivePageHeight) {
- // logger_.debug("character is below footer_line. footer_line = " +
- // this.footer_line + ", text.character=" + character + ", y=" +
- // current_y);
- return;
- }
-
- // store ypos of the char if it is not empty
- if (current_y > this.max_character_ypos) {
- this.max_character_ypos = current_y;
- }
- }
-
- // use this funtion getting an unsorted text output
- // public void showString(byte[] string) {
- // logger_.debug(new String(string));
- // }
-
- /**
- * Returns the calculated page length.
- *
- * @return the max page length value
- */
- public float getMaxPageLength() {
- if (logger.isDebugEnabled()) {
- logger.debug("Determining page content length: text="
- + max_character_ypos + ", image=" + max_image_ypos
- + ", path=" + maxPathRelatedYPositionFromTop);
- }
- return NumberUtils.max(max_character_ypos, max_image_ypos,
- maxPathRelatedYPositionFromTop);
- }
-
-// public Map<String, PDFont> getFonts() { //TODO: pdfbox2 - was @override
-//
-// COSBase fontObj = null;
-//
-// if (getCurrentPage().getResources() != null
-// && getCurrentPage().getResources().getCOSObject() != null
-// && getCurrentPage().getResources().getCOSObject()
-// .getDictionaryObject(COSName.FONT) != null) {
-// fontObj = getCurrentPage().getResources().getCOSObject()
-// .getDictionaryObject(COSName.FONT);
-// }
-//
-// Map<String, PDFont> fontMap = new HashMap<String, PDFont>();
-//
-// Iterable<COSName> fontNames = getCurrentPage().getResources().getFontNames();
-// for(COSName fn : fontNames){
-// fontMap.put(fn.getName(), getCurrentPage().getResources().getFont(fn));
-// }
-//
-// if (fontObj != null) {
-// getCurrentPage().getResources().getCOSObject()
-// .setItem(COSName.FONT, fontObj);
-// }
-//
-// return fontMap;
-// }
-
- public class MyInvoke extends OperatorProcessor {
-
- private PDFPage mypage;
-
- public MyInvoke(PDFPage page) {
- this.mypage = page;
- }
-
- public void process(Operator operator, List<COSBase> arguments)
- throws IOException {
- COSName name = (COSName) arguments.get(0);
-
- // PDResources res = context.getResources();
-
- PDXObject xobject = context.getResources().getXObject(name);
-
- PDStream stream = xobject.getStream();
- COSStream cos_stream = stream.getCOSObject();
-
- COSName subtype = (COSName) cos_stream
- .getDictionaryObject(COSName.SUBTYPE);
- if (subtype.equals(COSName.IMAGE)) {
- logger.debug("XObject Image");
-
- Matrix ctm = context.getGraphicsState()
- .getCurrentTransformationMatrix();
- logger.debug("ctm = " + ctm);
-
- Pos[] coordinates = new Pos[] { new Pos(0, 0, 1),
- new Pos(1, 0, 1), new Pos(0, 1, 1), new Pos(1, 1, 1) };
-
- Pos[] transformed_coordinates = transtormCoordinates(
- coordinates, ctm);
-
- /**********************************************************
- * pdf-as fix: calculating min and max point of an image to look
- * where the signature should be placed fix solves problems with
- * footer and images and placement of the signature in an image
- * only pdf document
- **********************************************************/
-
- float actual_lowest_point = Float.NaN;
- float actual_starting_point = Float.NaN;
-
- int pageRotation = this.mypage.getCurrentPage().getRotation();
- logger.debug("PageRotation = " + pageRotation);
- if (pageRotation == 0) {
- float min_y = findMinY(transformed_coordinates);
- logger.debug("min_y = " + min_y);
- float page_height = this.mypage.getCurrentPage()
- .getMediaBox().getHeight();
- logger.debug("page_height = " + page_height);
-
- actual_lowest_point = page_height - min_y;
- actual_starting_point = page_height
- - findMaxY(transformed_coordinates);
- }
- if (pageRotation == 90) {
- float max_x = findMaxX(transformed_coordinates);
- logger.debug("max_x = " + max_x);
- float page_width = this.mypage.getCurrentPage()
- .getMediaBox().getWidth();
- logger.debug("page_width = " + page_width);
-
- actual_lowest_point = max_x;
- actual_starting_point = findMinX(transformed_coordinates);
- }
- if (pageRotation == 180) {
- float min_y = findMinY(transformed_coordinates);
- logger.debug("min_y = " + min_y);
- actual_lowest_point = findMaxY(transformed_coordinates);
- actual_starting_point = actual_lowest_point + min_y;
- }
- if (pageRotation == 270) {
- float min_x = findMinX(transformed_coordinates);
- logger.debug("min_x = " + min_x);
-
- float page_width = this.mypage.getCurrentPage()
- .getMediaBox().getWidth();
- logger.debug("page_width = " + page_width);
-
- actual_lowest_point = page_width - min_x;
- actual_starting_point = page_width
- - findMaxX(transformed_coordinates);
- }
-
- logger.debug("actual_lowest_point = " + actual_lowest_point);
-
- if (actual_lowest_point > PDFPage.this.effectivePageHeight
- && actual_starting_point > PDFPage.this.effectivePageHeight) {
- logger.debug("image is below footer_line");
- return;
- }
-
- if (actual_lowest_point > PDFPage.this.max_image_ypos) {
- PDFPage.this.max_image_ypos = actual_lowest_point;
- }
-
- return;
- }
-
- if (xobject instanceof PDFormXObject) {
- PDFormXObject form = (PDFormXObject) xobject;
- COSStream invoke = (COSStream) form.getCOSObject();
- PDResources pdResources = form.getResources();
- PDPage page = context.getCurrentPage();
- if (pdResources == null) {
- pdResources = page.getResources();
- }
-
- //getContext().processSubStream(page, pdResources, invoke);//TODO: pdfbox2 - correct?
- getContext().processPage(page);
-
- }
- }
-
- @Override
- public String getName() {
- return "Do";
- }
- }
-
- public static Pos[] transtormCoordinates(Pos[] coordinates, Matrix m) {
- Pos[] transformed = new Pos[coordinates.length];
- for (int i = 0; i < coordinates.length; i++) {
- transformed[i] = transtormCoordinate(coordinates[i], m);
- }
- return transformed;
- }
-
- public static Pos transtormCoordinate(Pos pos, Matrix m) {
- Pos transformed = new Pos();
- transformed.x = pos.x * m.getValue(0, 0) + pos.y * m.getValue(1, 0)
- + pos.z * m.getValue(2, 0);
- transformed.y = pos.x * m.getValue(0, 1) + pos.y * m.getValue(1, 1)
- + pos.z * m.getValue(2, 1);
- transformed.z = pos.x * m.getValue(0, 2) + pos.y * m.getValue(1, 2)
- + pos.z * m.getValue(2, 2);
-
- logger.debug(" transformed " + pos + " --> " + transformed);
- return transformed;
- }
-
- public static float findMinY(Pos[] coordinates) {
- float min = Float.POSITIVE_INFINITY;
- for (int i = 0; i < coordinates.length; i++) {
- if (coordinates[i].y < min) {
- min = coordinates[i].y;
- }
- }
- return min;
- }
-
- public static float findMaxY(Pos[] coordinates) {
- float max = 0;
- for (int i = 0; i < coordinates.length; i++) {
- if (coordinates[i].y > max) {
- max = coordinates[i].y;
- }
- }
- return max;
- }
-
- public static float findMaxX(Pos[] coordinates) {
- float max = Float.NEGATIVE_INFINITY;
- for (int i = 0; i < coordinates.length; i++) {
- if (coordinates[i].x > max) {
- max = coordinates[i].x;
- }
- }
- return max;
- }
-
- public static float findMinX(Pos[] coordinates) {
- float min = Float.POSITIVE_INFINITY;
- for (int i = 0; i < coordinates.length; i++) {
- if (coordinates[i].x < min) {
- min = coordinates[i].x;
- }
- }
- return min;
- }
-
- public void processAnnotation(PDAnnotation anno) {
- float current_y = anno.getRectangle().getLowerLeftY();
- float upper_y = 0;
- PDPage page = anno.getPage();
-
- if (page == null) {
- page = getCurrentPage();
- }
-
- if (page == null) {
- logger.warn("Annotation without page! The position might not be correct!");
- return;
- }
-
- int pageRotation = page.getRotation();
- // logger_.debug("PageRotation = " + pageRotation);
- if (pageRotation == 0) {
- float page_height = page.getMediaBox().getHeight();
- current_y = page_height - anno.getRectangle().getLowerLeftY();
- upper_y = page_height - anno.getRectangle().getUpperRightY();
- }
- if (pageRotation == 90) {
- current_y = anno.getRectangle().getUpperRightX();
- upper_y = anno.getRectangle().getLowerLeftX();
- }
- if (pageRotation == 180) {
- current_y = anno.getRectangle().getUpperRightY();
- upper_y = anno.getRectangle().getLowerLeftY();
- }
- if (pageRotation == 270) {
- float page_width = page.getMediaBox().getWidth();
- current_y = page_width - anno.getRectangle().getLowerLeftX();
- upper_y = page_width - anno.getRectangle().getUpperRightX();
- }
-
-
-
- if (current_y > this.effectivePageHeight) {
- if(!this.legacy40 && upper_y < this.effectivePageHeight) {
- // Bottom of annotation is below footer line,
- // but top of annotation is above footer line!
- // so no place left on this page!
- this.max_character_ypos = this.effectivePageHeight;
- }
- return;
- }
-
- // store ypos of the char if it is not empty
- if (current_y > this.max_character_ypos) {
- this.max_character_ypos = current_y;
- }
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFUtilities.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFUtilities.java
deleted file mode 100644
index 6fef7549..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/PDFUtilities.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- *
- * $Id: PDFUtilities.java,v 1.3 2006/10/31 08:09:33 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf;
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.tools.imageio.ImageIOUtil;
-
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.positioning.PositioningRenderer;
-import at.gv.egiz.pdfas.lib.impl.stamping.IPDFVisualObject;
-
-public abstract class PDFUtilities implements IConfigurationConstants{
-
- public static Color MAGIC_COLOR = new Color(152,254,52);// green-ish background
-
- public static float getMaxYPosition(
- PDDocument pdfDataSource, int page, IPDFVisualObject pdfTable, float signatureMarginVertical, float footer_line, ISettings settings) throws IOException {
-
- int width = (int) pdfDataSource.getPage(page).getCropBox().getWidth();
- int height = (int) pdfDataSource.getPage(page).getCropBox().getHeight();
-
- // flip image in case of page rotation is 90 or 270
- BufferedImage bim = (pdfDataSource.getPage(page).getRotation() % 180 == 0)
- ? new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
- : new BufferedImage(height, width, BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D graphics = bim.createGraphics();
- graphics.setBackground(MAGIC_COLOR);
-
- PositioningRenderer renderer = new PositioningRenderer(pdfDataSource);
- renderer.renderPageToGraphics(page, graphics);
-
- /*
- * Only used if background color should be determined automatically.
- * That can be necessary of PDF contains page-size images.
- */
- Color bgColor = Boolean.parseBoolean(settings.getValue(BG_COLOR_DETECTION))
- ? determineBackgroundColor(bim)
- : MAGIC_COLOR;
-
- int yCoord = bim.getHeight() - 1 - (int)footer_line;
-
- for(int row = yCoord; row >= 0; row--)
- {
- if (row == 0) {
- yCoord = row;
-
- } else {
- for(int col = 0; col < bim.getWidth(); col++){
- int val = bim.getRGB(col, row);
- if(val != bgColor.getRGB()){
- yCoord = row;
- row=-1;
- break;
- }
- }
- }
- }
-
- String outFile = settings.getValue(SIG_PLACEMENT_DEBUG_OUTPUT);
- if(outFile != null){
- ImageIOUtil.writeImage(bim, outFile, 72);
- }
-
- return yCoord;
-
- }
-
- public static Color determineBackgroundColor(BufferedImage bim){
-
- int inset = 5;//px
-
- int pixelUpLeft = bim.getRGB(inset,inset);
- int pixelUpRight = bim.getRGB(bim.getWidth()-inset,inset);
- int pixelDownLeft = bim.getRGB(inset, bim.getHeight()-inset);
- int pixelDownRight = bim.getRGB(bim.getWidth()-inset, bim.getHeight()-inset);
-
- HashMap<Integer, Integer> stats = new HashMap<Integer, Integer>();
- stats.put(pixelUpLeft, 0);
- stats.put(pixelUpRight, 0);
- stats.put(pixelDownLeft, 0);
- stats.put(pixelDownRight, 0);
-
- stats.put(pixelUpLeft, stats.get(pixelUpLeft)+1);
- stats.put(pixelUpRight, stats.get(pixelUpRight)+1);
- stats.put(pixelDownLeft, stats.get(pixelDownLeft)+1);
- stats.put(pixelDownRight, stats.get(pixelDownRight)+1);
-
- int bgValue = -1;
- int cnt =0;
- for(int key:stats.keySet()){
- if(stats.get(key) > cnt){
- cnt = stats.get(key);
- bgValue = key;
- }
- }
-
- return new Color(bgValue);
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathConstructionOperatorProcessor.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathConstructionOperatorProcessor.java
deleted file mode 100644
index ab273cd3..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathConstructionOperatorProcessor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path;
-
-import java.awt.geom.Point2D;
-
-import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-
-/**
- * Provides functions for path construction operators.
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author Datentechnik Innovation GmbH
- *
- */
-public abstract class PathConstructionOperatorProcessor extends OperatorProcessor {
-
- public PathConstructionOperatorProcessor(PDFPage context) {
- setContext(context);
- }
-
- /**
- * Transforms the given point from user space coordinates to device space coordinates based on the current
- * transition matrix.
- *
- * @param x
- * The x axis value of the user space coordinates.
- * @param y
- * The y axis value of the user space coordinates.
- * @return The transformed point.
- */
- public Point2D transform(double x, double y) {
- double[] position = { x, y };
- context.getGraphicsState().getCurrentTransformationMatrix().createAffineTransform()
- .transform(position, 0, position, 0, 1);
- return new Point2D.Double(position[0], position[1]);
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathPaintingOperatorProcessor.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathPaintingOperatorProcessor.java
deleted file mode 100644
index 1d2cdd98..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/PathPaintingOperatorProcessor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path;
-
-import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-
-/**
- * Provides functions for path painting operators.
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author Datentechnik Innovation GmbH
- *
- */
-public abstract class PathPaintingOperatorProcessor extends OperatorProcessor {
-
- public PathPaintingOperatorProcessor(PDFPage context) {
- setContext(context);
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/ClosePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/ClosePath.java
deleted file mode 100644
index 098ce8f6..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/ClosePath.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Close the current subpath by appending a straight line segment from the current point to the starting point of the
- * subpath. If the current subpath is already closed, h shall donothing. This operator terminates the current subpath.
- * Appending another segment to the current path shall begin a new subpath, even if the new segment begins at the
- * endpoint reached by the h operation.
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class ClosePath extends PathConstructionOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public ClosePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- pdfPage.getCurrentPath().closePath();
-
- if (log.isTraceEnabled()) {
- log.trace("Closing current path.");
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'h'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "h";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveTo.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveTo.java
deleted file mode 100644
index e6b76400..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveTo.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.awt.geom.Point2D;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Append a cubic Bezier curve to the current path. The curve shall extend from the current point to the point (x3, y3),
- * using (x1, y1) and (x2, y2) as the Bezier control points (see 8.5.2.2, "Cubic Bezier Curves"). The new current point
- * shall be (x3, y3).
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CurveTo extends PathConstructionOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CurveTo(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- COSNumber x1 = (COSNumber) operands.get(0);
- COSNumber y1 = (COSNumber) operands.get(1);
- COSNumber x2 = (COSNumber) operands.get(2);
- COSNumber y2 = (COSNumber) operands.get(3);
- COSNumber x3 = (COSNumber) operands.get(4);
- COSNumber y3 = (COSNumber) operands.get(5);
-
- Point2D p1 = transform(x1.floatValue(), y1.floatValue());
- Point2D p2 = transform(x2.floatValue(), y2.floatValue());
- Point2D p3 = transform(x3.floatValue(), y3.floatValue());
-
- pdfPage.getCurrentPath().curveTo(
- (float) p1.getX(), (float) p1.getY(),
- (float) p2.getX(), (float) p2.getY(),
- (float) p3.getX(), (float) p3.getY()
- );
-
- if (log.isTraceEnabled()) {
- log.trace("Appending cubic Bezier curve with x1:" + p1.getX() + ",y1:" + p1.getY() + ", x2:"
- + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY());
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'c'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "c";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateFinalPoint.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateFinalPoint.java
deleted file mode 100644
index 86c95c17..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateFinalPoint.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.awt.geom.Point2D;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Append a cubic Bezier curve to the current path. The curve shall extend from the current point to the point (x3, y3),
- * using (x1, y1) and (x3, y3) as the Bezier control points (see 8.5.2.2, "Cubic Bezier Curves"). The new current point
- * shall be (x3, y3).
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CurveToReplicateFinalPoint extends PathConstructionOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CurveToReplicateFinalPoint(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- COSNumber x1 = (COSNumber) operands.get(0);
- COSNumber y1 = (COSNumber) operands.get(1);
- COSNumber x3 = (COSNumber) operands.get(2);
- COSNumber y3 = (COSNumber) operands.get(3);
-
- Point2D p1 = transform(x1.floatValue(), y1.floatValue());
- Point2D p3 = transform(x3.floatValue(), y3.floatValue());
-
- pdfPage.getCurrentPath().curveTo(
- (float) p1.getX(), (float) p1.getY(),
- (float) p3.getX(), (float) p3.getY(),
- (float) p3.getX(), (float) p3.getY()
- );
-
- if (log.isTraceEnabled()) {
- log.trace("Appending cubic Bezier curve with x1:" + p1.getX() + ",y1:" + p1.getY() + ", x3:"
- + p3.getX() + ",y3:" + p3.getY());
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'y'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "y";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateInitialPoint.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateInitialPoint.java
deleted file mode 100644
index 91c90589..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/CurveToReplicateInitialPoint.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.awt.geom.Point2D;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Append a cubic Bezier curve to the current path. The curve shall extend from the current point to the point (x3, y3),
- * using the current point and (x2, y2) as the Bezier control points (see 8.5.2.2, "Cubic Bezier Curves"). The new
- * current point shall be (x3, y3).
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CurveToReplicateInitialPoint extends PathConstructionOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CurveToReplicateInitialPoint(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- COSNumber x2 = (COSNumber) operands.get(0);
- COSNumber y2 = (COSNumber) operands.get(1);
- COSNumber x3 = (COSNumber) operands.get(2);
- COSNumber y3 = (COSNumber) operands.get(3);
-
- Point2D currentPoint = pdfPage.getCurrentPath().getCurrentPoint();
- Point2D p2 = transform(x2.floatValue(), y2.floatValue());
- Point2D p3 = transform(x3.floatValue(), y3.floatValue());
-
- pdfPage.getCurrentPath().curveTo(
- (float)currentPoint.getX(), (float)currentPoint.getY(),
- (float) p2.getX(), (float) p2.getY(),
- (float) p3.getX(), (float) p3.getY()
- );
-
- if (log.isTraceEnabled()) {
- log.trace("Appending cubic Bezier curve with x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:"
- + p3.getX() + ",y3:" + p3.getY() + ", using current point x:" + currentPoint.getX() + ",y:"
- + currentPoint.getY());
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'v'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "v";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/LineTo.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/LineTo.java
deleted file mode 100644
index 94fbbbb0..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/LineTo.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.awt.geom.Point2D;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Append a straight line segment from the current point to the point (x, y). The new current point shall be (x, y).
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class LineTo extends PathConstructionOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public LineTo(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- COSNumber x = (COSNumber) operands.get(0);
- COSNumber y = (COSNumber) operands.get(1);
- Point2D p = transform(x.floatValue(), y.floatValue());
-
- pdfPage.getCurrentPath().lineTo((float) p.getX(), (float) p.getY());
-
- if (log.isTraceEnabled()) {
- log.trace("Adding line to x:" + p.getX() + ",y:" + p.getY());
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'l'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "l";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/MoveTo.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/MoveTo.java
deleted file mode 100644
index 3fe123ea..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/construction/MoveTo.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction;
-
-import java.awt.geom.Point2D;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSNumber;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathConstructionOperatorProcessor;
-
-/**
- * Begin a new subpath by moving the current point to coordinates (x, y), omitting any connecting line segment. If the
- * previous path construction operator in the current path was also m, the new m overrides it; no vestige of the
- * previous m operation remains in the path.
- *
- * @see "PDF 1.7 specification, Section 8.5.2 'Path Construction Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class MoveTo extends PathConstructionOperatorProcessor{
-
- public MoveTo(PDFPage context) {
- super(context);
- // TODO Auto-generated constructor stub
- }
-
- private Log log = LogFactory.getLog(getClass());
-
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- COSNumber x = (COSNumber) operands.get(0);
- COSNumber y = (COSNumber) operands.get(1);
- Point2D p = transform(x.floatValue(), y.floatValue());
-
- pdfPage.getCurrentPath().moveTo((float) p.getX(), (float) p.getY());
-
- if (log.isTraceEnabled()) {
- log.trace("Moving current path to x:" + p.getX() + ",y:" + p.getY());
- }
- } catch (Exception e) {
- log.warn("Error processing operator 'm'.", e);
- }
- }
-
-
- @Override
- public String getName() {
- return "m";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseAndStrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseAndStrokePath.java
deleted file mode 100644
index 37182ddc..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseAndStrokePath.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Close and stroke the path. This operator shall have the same effect as the sequence <code>h S</code>.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CloseAndStrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CloseAndStrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- if (log.isTraceEnabled()) {
- log.trace("Closing and stroking path.");
- }
- context.processOperator("h", operands);
- context.processOperator("S", operands);
- }
-
- @Override
- public String getName() {
- return "s";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillEvenOddAndStrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillEvenOddAndStrokePath.java
deleted file mode 100644
index 597084e8..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillEvenOddAndStrokePath.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Close, fill, and then stroke the path, using the even-odd rule to determine the region to fill. This operator shall
- * have the same effect as the sequence <code>h B*</code>.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CloseFillEvenOddAndStrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CloseFillEvenOddAndStrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- if (log.isTraceEnabled()) {
- log.trace("Closing, filling (even odd rule) and stroking path.");
- }
- context.processOperator("h", operands);
- context.processOperator("B*", operands);
- }
-
- @Override
- public String getName() {
- return "b*";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillNonZeroAndStrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillNonZeroAndStrokePath.java
deleted file mode 100644
index 8ab72438..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/CloseFillNonZeroAndStrokePath.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Close, fill, and then stroke the path, using the nonzero winding number rule to determine the region to fill. This
- * operator shall have the same effect as the sequence <code>h B</code>.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class CloseFillNonZeroAndStrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public CloseFillNonZeroAndStrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- if (log.isTraceEnabled()) {
- log.trace("Closing, filling (non zero rule) and stroking path.");
- }
- context.processOperator("h", operands);
- context.processOperator("B", operands);
- }
-
- @Override
- public String getName() {
- return "b";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/EndPath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/EndPath.java
deleted file mode 100644
index a43df0a2..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/EndPath.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * End the path object without filling or stroking it. This operator shall be a path-painting no-op, used primarily for
- * the side effect of changing the current clipping path.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class EndPath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public EndPath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- log.debug("Ending path " + pdfPage.getCurrentPath());
- pdfPage.getCurrentPath().reset();
-
- if (log.isTraceEnabled()) {
- log.trace("End path without filling or stroking.");
- }
-
- } catch (Exception e) {
- log.warn("Error processing operator 'n'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "n";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillEvenOddAndStrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillEvenOddAndStrokePath.java
deleted file mode 100644
index 77e65666..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillEvenOddAndStrokePath.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.awt.geom.GeneralPath;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Fill and then stroke the path, using the even-odd rule to determine the region to fill. This operator shall produce
- * the same result as <code>B</code>, except that the path is filled as if with <code>f*</code> instead of
- * <code>f</code>.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class FillEvenOddAndStrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public FillEvenOddAndStrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- if (log.isTraceEnabled()) {
- log.trace("Filling (even odd rule) and stroking path.");
- }
-
- GeneralPath currentPath = (GeneralPath) pdfPage.getCurrentPath().clone();
- context.processOperator("f*", operands);
- pdfPage.setCurrentPath(currentPath);
- context.processOperator("S", operands);
-
- } catch (Exception e) {
- log.warn("Error processing operator 'B*'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "B*";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillNonZeroAndStrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillNonZeroAndStrokePath.java
deleted file mode 100644
index 9a1f0b69..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillNonZeroAndStrokePath.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.awt.geom.GeneralPath;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Fill and then stroke the path, using the nonzero winding number rule to determine the region to fill. This operator
- * shall produce the same result as constructing two identical path objects, painting the first with <code>f</code> and
- * the second with <code>S</code>.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class FillNonZeroAndStrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public FillNonZeroAndStrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- if (log.isTraceEnabled()) {
- log.trace("Filling (non zero rule) and stroking path.");
- }
-
- GeneralPath currentPath = (GeneralPath) pdfPage.getCurrentPath().clone();
- context.processOperator("f", operands);
- pdfPage.setCurrentPath(currentPath);
- context.processOperator("S", operands);
-
- } catch (Exception e) {
- log.warn("Error processing operator 'B'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "B";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathEvenOddRule.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathEvenOddRule.java
deleted file mode 100644
index 092ba751..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathEvenOddRule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.awt.Rectangle;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Fill the path, using the even-odd rule to determine the region to fill.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class FillPathEvenOddRule extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public FillPathEvenOddRule(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- pdfPage.getCurrentPath().setWindingRule(java.awt.geom.GeneralPath.WIND_EVEN_ODD);
- Rectangle bounds = pdfPage.getCurrentPath().getBounds();
- pdfPage.getCurrentPath().reset();
-
- if (log.isTraceEnabled()) {
- log.trace("Filling path, using even-odd rule.");
- }
-
- pdfPage.registerPathBounds(bounds);
-
- } catch (Exception e) {
- log.warn("Error processing operator 'f*'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "f*";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathNonZeroWindingNumberRule.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathNonZeroWindingNumberRule.java
deleted file mode 100644
index 3b8d13f9..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/FillPathNonZeroWindingNumberRule.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.awt.Rectangle;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Fill the path, using the nonzero winding number rule to determine the region to fill. Any subpaths that are open
- * shall be implicitly closed before being filled.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class FillPathNonZeroWindingNumberRule extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
- private final boolean lowercase;
-
- public FillPathNonZeroWindingNumberRule(PDFPage context, boolean lowercase) {
- super(context);
- this.lowercase = lowercase;
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- pdfPage.getCurrentPath().setWindingRule(java.awt.geom.GeneralPath.WIND_NON_ZERO);
- Rectangle bounds = pdfPage.getCurrentPath().getBounds();
- pdfPage.getCurrentPath().reset();
-
- if (log.isTraceEnabled()) {
- log.trace("Filling path, using nonzero winding number rule.");
- }
-
- pdfPage.registerPathBounds(bounds);
-
- } catch (Exception e) {
- log.warn("Error processing operator 'f/F'.", e);
- }
- }
-
- @Override
- public String getName() {
- return lowercase ? "f" : "F";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/StrokePath.java b/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/StrokePath.java
deleted file mode 100644
index ef9fc24b..00000000
--- a/pdf-as-pdfbox-2/src/main/java/at/knowcenter/wag/egov/egiz/pdfbox2/pdf/operator/path/painting/StrokePath.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- ******************************************************************************/
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
- * joint initiative of the Federal Chancellery Austria and Graz University of
- * Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-package at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.painting;
-
-import java.awt.Rectangle;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.pdfbox.contentstream.operator.Operator;
-import org.apache.pdfbox.cos.COSBase;
-
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage;
-import at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.PathPaintingOperatorProcessor;
-
-/**
- * Strokes the path.
- *
- * @see "PDF 1.7 specification, Section 8.5.3 'Path-Painting Operators'"
- * @author PdfBox, modified by Datentechnik Innovation GmbH
- */
-public class StrokePath extends PathPaintingOperatorProcessor {
-
- private Log log = LogFactory.getLog(getClass());
-
- public StrokePath(PDFPage context) {
- super(context);
- }
-
- @Override
- public void process(Operator operator, List<COSBase> operands) throws IOException {
- try {
- PDFPage pdfPage = (PDFPage) context;
-
- Rectangle bounds = pdfPage.getCurrentPath().getBounds();
- pdfPage.getCurrentPath().reset();
-
- if (log.isTraceEnabled()) {
- log.trace("Stroking path.");
- }
-
- pdfPage.registerPathBounds(bounds);
-
- } catch (Exception e) {
- log.warn("Error processing operator 'S'.", e);
- }
- }
-
- @Override
- public String getName() {
- return "S";
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.backend.PDFASBackend b/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.backend.PDFASBackend
deleted file mode 100644
index 130d219c..00000000
--- a/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.backend.PDFASBackend
+++ /dev/null
@@ -1 +0,0 @@
-at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXBackend \ No newline at end of file
diff --git a/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator b/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator
deleted file mode 100644
index ac38ebbf..00000000
--- a/pdf-as-pdfbox-2/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator
+++ /dev/null
@@ -1 +0,0 @@
-at.gv.egiz.pdfas.lib.impl.pdfbox2.configuration.ProfileValidator \ No newline at end of file
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java
deleted file mode 100644
index c110a8d4..00000000
--- a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package at.gv.egiz.pdfas.lib.testpdfbox;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-import lombok.SneakyThrows;
-
-public class PDFBoxPlaceholderExtractorTest {
-
- @Test
- @SneakyThrows
- public void nextPlaceholder() {
- SignaturePlaceholderData result = getNextSignaturePlaceHolder("/data/platzhalter_en_de_test.pdf");
- assertEquals("Im48", result.getPlaceholderName());
- }
-
- @Test
- @SneakyThrows
- public void allPlaceHolders() {
- List<String> listOfPlaceHolders = getPlaceHolders("/data/platzhalter_en_de_test.pdf");
- assertNotNull(listOfPlaceHolders);
- assertTrue(listOfPlaceHolders.isEmpty());
- }
-
- @Test
- @SneakyThrows
- public void nextPlaceholderDuplicateElements() {
- assertEquals("Im0_1", getNextSignaturePlaceHolder("/data/Testdoc_Signatur.pdf").getPlaceholderName());
- assertEquals("Im0_2", getNextSignaturePlaceHolder("/data/own_Testdoc+Signatur-sign-sign.pdf").getPlaceholderName());
- assertEquals("Im0_2", getNextSignaturePlaceHolder("/data/own_Testdoc+Signatur-sign-sign-4_sign.pdf").getPlaceholderName());
- assertEquals("Im0", getNextSignaturePlaceHolder("/data/own_Testdoc+Signatur-sign-sign-4_sign-sign.pdf").getPlaceholderName());
-
- }
-
- @Test
- @Ignore
- @SneakyThrows
- public void placeHolderInAnnotation() {
- SignaturePlaceholderData listOfPlaceHolders = getNextSignaturePlaceHolder("/data/Test-sign.pdf");
- assertNotNull(listOfPlaceHolders);
-
- }
-
- private static List<String> getPlaceHolders(String filePath) throws IOException {
- try (final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream(
- filePath))) {
- return SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(doc);
- }
- }
-
- private static SignaturePlaceholderData getNextSignaturePlaceHolder(String filePath) throws IOException {
- try (final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream(
- filePath))) {
- return SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(doc);
- }
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java
deleted file mode 100644
index 0ed05eb5..00000000
--- a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package at.gv.egiz.pdfas.lib.testpdfbox;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-
-@RunWith(JUnit4.class)
-public class SignatureFieldsAndPlaceHolderExtractorTest {
-
- public String getPath(String resourceName) {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(resourceName).getFile());
- String absolutePath = file.getAbsolutePath();
-
- System.out.println(absolutePath);
- return absolutePath;
- }
-
- @Test
- public void notSigned(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
- }
- @Test
- public void signedOnce(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed.pdf"));
- Assert.assertEquals("Image8",result.getPlaceholderName());
- }
- @Test
- public void signedTwice(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed.pdf"));
- Assert.assertEquals(null,result);
- }
- @Test
- public void signedThrice(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed_signed.pdf"));
- Assert.assertEquals(null,result);
- }
-
- @Test
- public void noPlaceHolder(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("manySignFields.pdf"));
- Assert.assertEquals(null,result);
- }
-
- @Test
- public void firstQrCodeOnUnsignedDoc() {
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
-
- }
-
- @Test
- public void subsequentCalls(){
- SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed_signed.pdf"));
- Assert.assertEquals(null,result);
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed.pdf"));
- Assert.assertEquals("Image8",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed.pdf"));
- Assert.assertEquals("Image8",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed_signed.pdf"));
- Assert.assertEquals(null,result);
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
- Assert.assertEquals("Image5",result.getPlaceholderName());
-
- result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed.pdf"));
- Assert.assertEquals("Image8",result.getPlaceholderName());
- }
- @Test
- public void notSignedAndNoFields(){
- List<String> result = getPlaceHolders(getPath("new_qr_2-2.pdf"));
-
- List<String> expectedResult = new ArrayList<>();
- Assert.assertEquals(expectedResult,result);
- }
-
- @Test
- public void notSignedFields(){
- List<String> result = getPlaceHolders(getPath("manySignFields.pdf"));
-
- List<String> expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_4", "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
- }
-
- @Test
- public void signedOncePosition4FieldTest(){
- List<String> result = getPlaceHolders(getPath("manySignFields_signed4.pdf"));
-
- List<String> expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
- }
-
- @Test
- public void multipleCallsFieldTest(){
- List<String> result = getPlaceHolders(getPath("manySignFields_signed4.pdf"));
- List<String> expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields_signed4.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_4", "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_4", "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields_signed4.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields_signed4.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- result = getPlaceHolders(getPath("manySignFields.pdf"));
- expectedResult = Arrays.asList("Signature_0", "Signature_1", "Signature_2", "Signature_3",
- "Signature_4", "Signature_5", "Signature_6", "Signature_7");
- Assert.assertEquals(expectedResult,result);
-
- }
-
- private static List<String> getPlaceHolders(String filePath) {
- try {
- PDDocument doc = PDDocument.load(new File(filePath));
- List<String> results = SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(doc);
-// System.out.println(filePath + ": " + result);
- return results;
- } catch (Throwable e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public static SignaturePlaceholderData getNextSignaturePlaceHolder(String filePath) {
- try {
- PDDocument doc = PDDocument.load(new File(filePath));
- SignaturePlaceholderData result =
- SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(doc);
-// System.out.println(filePath + ": " + result);
- return result;
- } catch (Throwable e) {
- e.printStackTrace();
- }
- return null;
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/TTFFontTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/TTFFontTest.java
deleted file mode 100644
index 78a89708..00000000
--- a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/TTFFontTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package at.gv.egiz.pdfas.lib.testpdfbox;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.pdfbox.cos.COSBase;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.cos.COSObject;
-import org.apache.pdfbox.pdmodel.PDDocument;
-
-public class TTFFontTest {
-
- public static void main(String[] args) {
- try {
- PDDocument doc = PDDocument.load(new File("/home/afitzek/Downloads/pdf_groesse/willenserklaerung_signedByUser.pdf"));
-
- List<COSObject> cosObjects = doc.getDocument().getObjectsByType(COSName.FONT);
-
- Iterator<COSObject> cosObjectIt = cosObjects.iterator();
-
- while(cosObjectIt.hasNext()) {
- COSObject cosObject = cosObjectIt.next();
- COSBase subType = ((COSDictionary)cosObject.getObject()).getItem(COSName.SUBTYPE);
- COSBase baseFont = ((COSDictionary)cosObject.getObject()).getItem(COSName.BASE_FONT);
- COSBase aTest = ((COSDictionary)cosObject.getObject()).getItem(COSName.A);
-
- System.out.println(aTest);
-
- if(subType.equals(COSName.TRUE_TYPE)) {
- System.out.println("Object Number: " + cosObject.getObjectNumber() +
- subType.toString());
- System.out.println(" BaseFont: " + baseFont.toString());
- }
-
-
- }
-
-
- } catch(Throwable e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/pdf-as-pdfbox-2/src/test/resources/1Sign_manyQR.pdf b/pdf-as-pdfbox-2/src/test/resources/1Sign_manyQR.pdf
deleted file mode 100644
index 0784592a..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/1Sign_manyQR.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/Test-sign.pdf b/pdf-as-pdfbox-2/src/test/resources/data/Test-sign.pdf
deleted file mode 100644
index 7395663e..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/Test-sign.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/Testdoc_Signatur.pdf b/pdf-as-pdfbox-2/src/test/resources/data/Testdoc_Signatur.pdf
deleted file mode 100644
index 81af9006..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/Testdoc_Signatur.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign-sign.pdf b/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign-sign.pdf
deleted file mode 100644
index d1623f5e..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign-sign.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign.pdf b/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign.pdf
deleted file mode 100644
index 72d6007f..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign-4_sign.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign.pdf b/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign.pdf
deleted file mode 100644
index 5c472d46..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign-sign.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign.pdf b/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign.pdf
deleted file mode 100644
index 1bda36c6..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/own_Testdoc+Signatur-sign.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/data/platzhalter_en_de_test.pdf b/pdf-as-pdfbox-2/src/test/resources/data/platzhalter_en_de_test.pdf
deleted file mode 100644
index 06b9aa0e..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/data/platzhalter_en_de_test.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/manySignFields.pdf b/pdf-as-pdfbox-2/src/test/resources/manySignFields.pdf
deleted file mode 100644
index 970cd132..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/manySignFields.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/manySignFields_signed4.pdf b/pdf-as-pdfbox-2/src/test/resources/manySignFields_signed4.pdf
deleted file mode 100644
index fb639c99..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/manySignFields_signed4.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/new_qr_2-2.pdf b/pdf-as-pdfbox-2/src/test/resources/new_qr_2-2.pdf
deleted file mode 100644
index 565ce8e6..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/new_qr_2-2.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed.pdf b/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed.pdf
deleted file mode 100644
index be6fdddb..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed.pdf b/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed.pdf
deleted file mode 100644
index ee0f140f..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed_signed.pdf b/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed_signed.pdf
deleted file mode 100644
index 34769dd0..00000000
--- a/pdf-as-pdfbox-2/src/test/resources/new_qr_2_signed_signed_signed.pdf
+++ /dev/null
Binary files differ
diff --git a/pdf-as-pdfbox-3/src/main/kotlin/at/gv/egiz/pdfas/lib/impl/pdfbox3/Placeholder.kt b/pdf-as-pdfbox-3/src/main/kotlin/at/gv/egiz/pdfas/lib/impl/pdfbox3/Placeholder.kt
index 873b0ccd..892d6a91 100644
--- a/pdf-as-pdfbox-3/src/main/kotlin/at/gv/egiz/pdfas/lib/impl/pdfbox3/Placeholder.kt
+++ b/pdf-as-pdfbox-3/src/main/kotlin/at/gv/egiz/pdfas/lib/impl/pdfbox3/Placeholder.kt
@@ -88,7 +88,7 @@ object PDFBoxPlaceholderExtractor : PlaceholderExtractor {
init {
Properties().apply {
load(PDFBoxPlaceholderExtractor::class.java.classLoader
- .getResourceAsStream("placeholder/pdfbox-reader-2.properties"))
+ .getResourceAsStream("placeholder/pdfbox-reader-3.properties"))
}.values.forEach {
val klass = Class.forName(it as String)
diff --git a/pdf-as-tests/build.gradle b/pdf-as-tests/build.gradle
index aad47bb2..9687ff13 100644
--- a/pdf-as-tests/build.gradle
+++ b/pdf-as-tests/build.gradle
@@ -17,14 +17,10 @@ repositories {
}
configurations{
- pdfBox2Compile
pdfBox3Compile
}
sourceSets{
- pdfBox2{
- compileClasspath = configurations.pdfBox2Compile
- }
pdfBox3{
compileClasspath = configurations.pdfBox3Compile
}
@@ -65,10 +61,7 @@ suiteDir.eachDir { File subDir ->
testClassesDirs = testing.suites.test.sources.output.classesDirs
classpath = testing.suites.test.sources.runtimeClasspath
- if (dirname =="public_pdfbox2"){
- classpath += sourceSets.pdfBox2.compileClasspath
- compileTestJava.classpath += sourceSets.pdfBox2.compileClasspath
- } else if (dirname == "public_pdfbox3") {
+ if (dirname == "public_pdfbox3") {
classpath += sourceSets.pdfBox3.compileClasspath
compileTestJava.classpath += sourceSets.pdfBox3.compileClasspath
}
diff --git a/pdf-as-web/build.gradle b/pdf-as-web/build.gradle
index 8a128e6a..b35b0947 100644
--- a/pdf-as-web/build.gradle
+++ b/pdf-as-web/build.gradle
@@ -19,7 +19,6 @@ buildscript {
configurations {
tomcatDist
- pdfbox2
pdfbox3
}
dependencies {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java
index 85d94a7f..08eb4c07 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/PdfAsWeb.java
@@ -13,7 +13,7 @@ import lombok.extern.slf4j.Slf4j;
public class PdfAsWeb extends SpringBootServletInitializer {
@Override
- protected SpringApplicationBuilder createSpringApplicationBuilder() {
+ protected SpringApplicationBuilder createSpringApplicationBuilder() {
SpringApplicationBuilder builder = new SpringApplicationBuilder();
builder.initializers(new PdfAsSpringBootApplicationContextInitializer());
builder.sources(PdfAsWeb.class);
diff --git a/settings.gradle b/settings.gradle
index 25b51cdd..fbd8b79c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include "pdf-as-common", "signature-standards:sigs-pkcs7detached", "signature-standards:sigs-pades", "pdf-as-lib", "pdf-as-pdfbox-2", "pdf-as-pdfbox-3", "pdf-as-moa", "pdf-as-cli", "pdf-as-web-status", "pdf-as-web-statistic-api", "pdf-as-web", "pdf-as-web-db", "pdf-as-web-client", "pdf-as-tests" \ No newline at end of file
+include "pdf-as-common", "signature-standards:sigs-pkcs7detached", "signature-standards:sigs-pades", "pdf-as-lib", "pdf-as-pdfbox-3", "pdf-as-moa", "pdf-as-cli", "pdf-as-web-status", "pdf-as-web-statistic-api", "pdf-as-web", "pdf-as-web-db", "pdf-as-web-client", "pdf-as-tests" \ No newline at end of file