From a0de2a3b2a5f4a99f280f5caebbca0d183ae109a Mon Sep 17 00:00:00 2001 From: tknall Date: Wed, 7 Feb 2007 10:08:21 +0000 Subject: Bugfix: Querformat, BKU 2.7.x, ... git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@35 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/BinarySignature.java | 70 +++++++++------------- 1 file changed, 29 insertions(+), 41 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java index c5acbc4..e10061c 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignature.java @@ -667,17 +667,15 @@ public abstract class BinarySignature * The original document. * @param pdf_table * The PdfPTable that contains the signature block. - * @param pos - * The Position object giving the exact location where to place the - * table. if page is -1, a new page will be appended to the document. - * Then the table will be inserted on that new page using the - * coordinates. + * @param pi + * The PositioningInstruction telling the algorithm where to place + * the signature block. * @return Returns the new document. * @throws PresentableException * Forwarded exception. */ public static IncrementalUpdateInformation writeIncrementalUpdate( - byte[] original_document, PdfPTable pdf_table, TablePos pos, + byte[] original_document, PdfPTable pdf_table, PositioningInstruction pi, List variable_field_definitions, List all_field_definitions) throws PresentableException { try @@ -697,30 +695,20 @@ public abstract class BinarySignature // The stamper allows this by setting append = true PdfStamper stamper = new PdfStamper(reader, baos, '\0', true); - int pdf_page_num = reader.getNumberOfPages(); - - // int signature_page = -1; - // - // if (pos_y >= 0) - // { - // signature_page = pdf_page_num; - // } - if (pos.page == -1) + if (pi.isMakeNewPage()) { - pos.page = pdf_page_num + 1; + int pdf_page_num = reader.getNumberOfPages(); Rectangle psize = reader.getPageSizeWithRotation(pdf_page_num); Rectangle rect = new Rectangle(psize); - stamper.insertPage(pos.page, rect); - - // pos_y *= -1; + stamper.insertPage(pdf_page_num + 1, rect); } - if (pos.page < 1 || pos.page > stamper.getReader().getNumberOfPages()) + if (pi.getPage() < 1 || pi.getPage() > stamper.getReader().getNumberOfPages()) { - throw new PDFDocumentException(224, "The provided pos.page (=" + pos.page + ") is out of range."); + throw new PDFDocumentException(224, "The provided page (=" + pi.getPage() + ") is out of range."); } - PdfContentByte content = stamper.getOverContent(pos.page); + PdfContentByte content = stamper.getOverContent(pi.getPage()); // content = StampContent einer PageStamp. // System.out.println("table_width = " + pdf_table.getTotalWidth() + ", @@ -741,27 +729,27 @@ public abstract class BinarySignature // pdf_table.writeSelectedRows(0, -1, SIGNATURE_BORDER / 2, // table_position, content); - content.addTemplate(table_template, pos.pos_x, pos.pos_y - pdf_table.getTotalHeight()); + content.addTemplate(table_template, pi.getX(), pi.getY() - pdf_table.getTotalHeight()); // For debugging print a 100x100 grid -// { -// Rectangle psize = reader.getPageSizeWithRotation(pos.page); -// float page_width = psize.width(); -// float page_height = psize.height(); -// for (float x = 0; x < page_width; x += 100) -// { -// content.moveTo(x, 0); -// content.lineTo(x, page_height); -// content.stroke(); -// } -// for (float y = 0; y < page_height; y += 100) -// { -// content.moveTo(0, y); -// content.lineTo(page_width, y); -// content.stroke(); -// } -// } - + // { + // Rectangle psize = reader.getPageSizeWithRotation(pos.page); + // float page_width = psize.width(); + // float page_height = psize.height(); + // for (float x = 0; x < page_width; x += 100) + // { + // content.moveTo(x, 0); + // content.lineTo(x, page_height); + // content.stroke(); + // } + // for (float y = 0; y < page_height; y += 100) + // { + // content.moveTo(0, y); + // content.lineTo(page_width, y); + // content.stroke(); + // } + // } + // content.setLineWidth(10.0f); // content.moveTo(0, 0); // content.lineTo(100, 100); -- cgit v1.2.3