diff options
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 59a4987..7cd5b29 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -1041,7 +1041,7 @@ public abstract class PdfAS public static PositioningInstruction adjustSignatureTableandCalculatePosition(
final byte[] pdf, PdfPTable pdf_table, TablePos pos) throws PDFDocumentException
{
- //first check pageinstruction in TablePos-object
+ //first check pageinstruction in TablePos-object
//new,auto,absolut
PdfReader reader = readInPdfDocument(pdf);
//get pages of currentdocument
@@ -1068,14 +1068,19 @@ public abstract class PdfAS //we do have absolute x
pre_pos_x = pos.getPosX();
}
- final float pos_x = pre_pos_x;
//calculate width
- float pre_width = page_width - pos_x - SIGNATURE_BORDER / 2;
+ //center
+ float pre_width = page_width - pre_pos_x - 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.setTotalWidth(width);
@@ -1101,28 +1106,43 @@ public abstract class PdfAS return new PositioningInstruction(make_new_page, page, pos_x, pos_y);
}
//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
+ //Now we have to getfreespace in page and reguard footerline
float footer_line = pos.getFooterLine();
float pre_page_length = PDFUtilities.calculatePageLength(pdf, page-1, page_height-footer_line);
if (pre_page_length == Float.NEGATIVE_INFINITY)
{
- //we do have an empty page
- //pre_page_length = page_height;
- pos_y = page_height - SIGNATURE_BORDER / 2;
+ //we do have an empty page or nothing in area above footerline
+ pre_page_length = page_height;
+ //no text --> SIGNATURE_BORDER
+ pos_y = page_height - SIGNATURE_BORDER / 2;
+ if (pos_y - footer_line <= table_height)
+ {
+ make_new_page = true;
+ if (!pos.isPauto())
+ {
+ //we have to correct pagenumber
+ page = reader.getNumberOfPages();
+ }
+ page++;
+ //no text --> SIGNATURE_BORDER
+ pos_y = page_height - SIGNATURE_BORDER / 2;
+ }
return new PositioningInstruction(make_new_page, page, pos_x, pos_y);
}
final float page_length = pre_page_length;
+ //we do have text take SIGNATURE_MARGIN
pos_y = page_height - page_length - SIGNATURE_MARGIN;
if (pos_y - footer_line <= table_height)
{
make_new_page = true;
if (!pos.isPauto())
- {
- page = reader.getNumberOfPages();
-
+ {
+ //we have to correct pagenumber in case of absolute page and not enough space
+ page = reader.getNumberOfPages();
}
page++;
- pos_y = page_height - SIGNATURE_BORDER / 2;
+ //no text --> SIGNATURE_BORDER
+ pos_y = page_height - SIGNATURE_BORDER / 2;
}
return new PositioningInstruction(make_new_page, page, pos_x, pos_y);
}
|