From 2f2c2bc802cf910893f3349a0529f4f941aade18 Mon Sep 17 00:00:00 2001 From: "Matteo Franci a.k.a. Fugerit" Date: Fri, 17 Nov 2023 22:09:10 +0100 Subject: [PATCH] Temporary commit --- .../java/org/fugerit/java/doc/mod/openpdf/PdfTypeHandler.java | 2 +- .../org/fugerit/java/doc/mod/openpdf/helpers/PdfHelper.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/fugerit/java/doc/mod/openpdf/PdfTypeHandler.java b/src/main/java/org/fugerit/java/doc/mod/openpdf/PdfTypeHandler.java index 8ccdc47..8e9ab20 100644 --- a/src/main/java/org/fugerit/java/doc/mod/openpdf/PdfTypeHandler.java +++ b/src/main/java/org/fugerit/java/doc/mod/openpdf/PdfTypeHandler.java @@ -44,7 +44,7 @@ public void handle(DocInput docInput, DocOutput docOutput) throws Exception { PdfWriter pdfWriter = PdfWriter.getInstance( document, baos ); // create doc handler OpenPpfDocHandler handler = new OpenPpfDocHandler( document, pdfWriter ); - pdfWriter.setPageEvent( new PageNumbersEventHandler( docBase ) ); + //pdfWriter.setPageEvent( new PageNumbersEventHandler( docBase ) ); handler.handleDoc( docBase ); baos.writeTo( outputStream ); baos.close(); diff --git a/src/main/java/org/fugerit/java/doc/mod/openpdf/helpers/PdfHelper.java b/src/main/java/org/fugerit/java/doc/mod/openpdf/helpers/PdfHelper.java index 718233b..b12dcc6 100644 --- a/src/main/java/org/fugerit/java/doc/mod/openpdf/helpers/PdfHelper.java +++ b/src/main/java/org/fugerit/java/doc/mod/openpdf/helpers/PdfHelper.java @@ -75,7 +75,7 @@ public void onEndPage(PdfWriter writer, Document document) { DocElement current = itElements.next(); if ( current instanceof DocPara ) { DocPara para = (DocPara) current; - String text = OpenPpfDocHandler.createText( docHelper.getParams(), para.getText() ); + String text = OpenPpfDocHandler.createText( docHelper.getParams(), para.getText() ).replace( PageNumberHelper.PAGE_COUNT , "" ); float textSize = baseFont.getWidthPoint(text, footerTextSize); float textBase = document.bottom() - totalOffset; int rowOffset = 10; @@ -90,7 +90,6 @@ public void onEndPage(PdfWriter writer, Document document) { cb.setTextMatrix(document.right() - textSize - adjust, textBase); cb.showText(text); } - totalOffset+= rowOffset; } else { throw new ConfigRuntimeException( "Element not allowed in footer (accepted only DocPara) : "+current ); @@ -110,6 +109,7 @@ public void onCloseDocument(PdfWriter writer, Document document) { totalPages.setTextMatrix(0, 0); totalPages.showText(String.valueOf( writer.getPageNumber() - 1) ); totalPages.endText(); + totalPages.sanityCheck(); } public void setPageNumberAlignment(int pageNumberAlignment) {