summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-signer/pdf-over-sigpdfas/src
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:35 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:35 +0000
commit74af39df685584f6e9d298648f5e52e51cc99e31 (patch)
treeb06111fa3d564aaccd574ae2b30d8753e92f30c6 /trunk/pdf-over-signer/pdf-over-sigpdfas/src
parent6e3760b19b64b9e00a641a5c6b32d369a895a23b (diff)
downloadpdf-over-74af39df685584f6e9d298648f5e52e51cc99e31.tar.gz
pdf-over-74af39df685584f6e9d298648f5e52e51cc99e31.tar.bz2
pdf-over-74af39df685584f6e9d298648f5e52e51cc99e31.zip
+ implemented fallback for placeholder creation
git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12694 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-signer/pdf-over-sigpdfas/src')
-rw-r--r--trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java58
-rw-r--r--trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.pngbin0 -> 8189 bytes
2 files changed, 34 insertions, 24 deletions
diff --git a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
index 8668a3f3..3879c434 100644
--- a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
+++ b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
@@ -32,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.signator.SignatureDimension;
-import at.asit.pdfover.signator.SignatureException;
import at.asit.pdfover.signator.SignatureParameter;
import at.asit.pdfover.signator.SignaturePosition;
import at.gv.egiz.pdfas.api.io.DataSource;
@@ -113,53 +112,62 @@ public class PdfAsSignatureParameter extends SignatureParameter {
* @see at.asit.pdfover.signator.SignatureParameter#getPlaceholder()
*/
@Override
- public Image getPlaceholder() throws SignatureException {
+ public Image getPlaceholder() {
- try
- {
+ try {
PDFASHelper.getPdfAs();
-
+
SignatureObject sign_obj = at.knowcenter.wag.egov.egiz.PdfAS
.createSignatureObjectFromType(PDFASSigner.PROFILE_ID);
-
+
sign_obj.fillValues(' ', true, false);
sign_obj.setKZ(BinarySignator_1_1_0.MY_ID);
-
+
float width = getPlaceholderDimension().getWidth();
float height = getPlaceholderDimension().getHeight();
-
+
Table table = sign_obj.getAbstractTable();
-
+
table.getStyle().getBgColor();
-
+
log.info(table.toString());
-
- float[] heights = this.getTableHeights(table, table.getStyle(), height);
-
+
+ float[] heights = this.getTableHeights(table, table.getStyle(),
+ height);
+
log.info("Width: " + width + " Height: " + height);
BufferedImage image = new BufferedImage((int) width, (int) height,
BufferedImage.TYPE_INT_RGB);
Graphics graphic = image.getGraphics();
-
+
graphic.setColor(table.getStyle().getBgColor());
graphic.fillRect(0, 0, (int) width, (int) height);
-
+
graphic.setColor(Color.black);
graphic.drawRect(0, 0, (int) width, (int) height);
-
+
this.drawTable(0, 0, (int) width, (int) height, table,
table.getStyle(), graphic, heights);
-
- save(image, "jpg");
-
+
+ //save(image, "png");
+
return image;
- }
- catch (Exception ex) {
- log.error("Failed to create Placeholder!", ex);
- throw new SignatureException(ex.getMessage());
+ } catch (Exception ex) {
+ try {
+ return ImageIO.read(PdfAsSignatureParameter.class
+ .getResourceAsStream("/img/fallbackPlaceholder.png"));
+ } catch (IOException e) {
+ return new BufferedImage(getPlaceholderDimension().getWidth(), getPlaceholderDimension().getHeight(), BufferedImage.TYPE_INT_RGB);
+ }
}
}
+ /**
+ * used for debugging ..
+ * @param image
+ * @param ext
+ */
+ @SuppressWarnings("unused")
private static void save(BufferedImage image, String ext) {
String fileName = "savingAnImage";
File file = new File(fileName + "." + ext);
@@ -186,7 +194,9 @@ public class PdfAsSignatureParameter extends SignatureParameter {
/**
* extracts the value font
- * @param style the table style
+ *
+ * @param style
+ * the table style
* @return the value font
*/
@SuppressWarnings("unused")
diff --git a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png
new file mode 100644
index 00000000..809e08f5
--- /dev/null
+++ b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/resources/img/fallbackPlaceholder.png
Binary files differ