diff options
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv')
4 files changed, 34 insertions, 17 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java index b583e48e..1e33a3cb 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java @@ -171,17 +171,29 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { String posString = pdfObject.getStatus().getSignParamter() .getSignaturePosition(); - if (posString == null) { - posString = signatureProfileConfiguration + TablePos signaturePos = null; + + String signaturePosString = signatureProfileConfiguration .getDefaultPositioning(); - } + if(signaturePosString != null) { + logger.debug("using signature Positioning: " + signaturePos); + signaturePos = new TablePos(signaturePosString); + } + logger.debug("using Positioning: " + posString); - if (posString == null) { - tablePos = new TablePos(); + if (posString != null) { + // Merge Signature Position + tablePos = new TablePos(posString, signaturePos); } else { - tablePos = new TablePos(posString); + // Fallback to signature Position! + tablePos = signaturePos; + } + + if(tablePos == null) { + // Last Fallback default position + tablePos = new TablePos(); } } boolean legacy32Position = signatureProfileConfiguration diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java index d2049f24..e64d735a 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java @@ -52,7 +52,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { .getLogger(PDFAsVisualSignatureBuilder.class); private void drawTable(PDPage page, PDPageContentStream contentStream, - float x, float y, PDFBoxTable abstractTable, PDDocument doc, + float x, float y, float width, float height, PDFBoxTable abstractTable, PDDocument doc, boolean subtable) throws IOException, PdfAsException { final int rows = abstractTable.getRowCount(); @@ -109,9 +109,9 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { for (int i = 0; i < rows; i++) { ArrayList<Entry> row = abstractTable.getRow(i); // Draw row border! - logger.debug("ROW LINE: {} {} {} {}", x, nexty, x + tableWidth, + logger.debug("ROW LINE: {} {} {} {}", x, nexty, x + width, nexty); - contentStream.drawLine(x, nexty, x + tableWidth, nexty); + contentStream.drawLine(x, nexty, x + width, nexty); lasty = nexty; if (i < abstractTable.getRowHeights().length) { nexty -= abstractTable.getRowHeights()[i] + padding * 2; @@ -144,7 +144,9 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { } } } - contentStream.drawLine(nextx, lasty, nextx, nexty); + if(!subtable) { + contentStream.drawLine(nextx, lasty, nextx, nexty); + } } contentStream.drawLine(x, nexty, x + tableWidth, nexty); @@ -359,8 +361,10 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { tbl_value.table.setStyle(inherit_styletab); logger.debug("Table: " + tableX + " : " + tableY); - drawTable(page, contentStream, tableX, tableY, tbl_value, - doc, true); + drawTable(page, contentStream, tableX, tableY, + (colsSizes != null) ? colsSizes[j] : colWidth, + abstractTable.getRowHeights()[i] + padding * 2, + tbl_value, doc, true); } textx += (colsSizes != null) ? colsSizes[j] : colWidth; } @@ -379,6 +383,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { } private PDFAsVisualSignatureProperties properties; + private PDFAsVisualSignatureDesigner designer; private ISettings settings; private PDResources innerFormResources; private Map<String, ImageObject> images = new HashMap<String, ImageObject>(); @@ -396,9 +401,11 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { } public PDFAsVisualSignatureBuilder( - PDFAsVisualSignatureProperties properties, ISettings settings) { + PDFAsVisualSignatureProperties properties, ISettings settings, + PDFAsVisualSignatureDesigner designer) { this.properties = properties; this.settings = settings; + this.designer = designer; } @Override @@ -541,8 +548,8 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { PDPageContentStream stream = new PDPageContentStream(template, getStructure().getPage()); // stream.setFont(PDType1Font.COURIER, 5); - drawTable(getStructure().getPage(), stream, 1, 1, + designer.getWidth(), designer.getHeight(), properties.getMainTable(), template, false); stream.close(); PDStream innterFormStream = getStructure().getPage().getContents(); diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java index 1b3cf688..6ed57703 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureProperties.java @@ -50,7 +50,7 @@ public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties { @Override public void buildSignature() throws IOException { - PDFAsVisualSignatureBuilder builder = new PDFAsVisualSignatureBuilder(this, this.settings); + PDFAsVisualSignatureBuilder builder = new PDFAsVisualSignatureBuilder(this, this.settings, designer); PDFAsTemplateCreator creator = new PDFAsTemplateCreator(builder); setVisibleSignature(creator.buildPDF(designer)); } diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java index 1bbfbe9a..da228dae 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java @@ -11,8 +11,6 @@ import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.sun.org.apache.bcel.internal.generic.Type; - import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; import at.gv.egiz.pdfas.common.settings.ISettings; |