Skip to content

Commit f13ac58

Browse files
Replace {{pages}} template with actual page number (#928)
1 parent ab6fc17 commit f13ac58

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

java/src/main/java/com/genexus/reports/PDFReportPDFBox.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class PDFReportPDFBox extends GXReportPDFCommons{
4848
private String barcodeType = null;
4949
private PDDocument document;
5050
private PDDocumentCatalog writer;
51-
private PDType0Font templateFont;
51+
private PDFont templateFont;
5252
private float templateX;
5353
private float templateY;
5454
public boolean lineCapProjectingSquare = true;
@@ -854,14 +854,14 @@ else if (barcodeType != null) {
854854
// Handle {{Pages}}
855855
if (sTxt.trim().equalsIgnoreCase("{{Pages}}")) {
856856
if (!templateCreated) {
857-
templateFont = new PDType0Font(baseFont.getCOSObject());
857+
templateFont = baseFont;
858858
templateFontSize = fontSize;
859859
templateColorFill = foreColor;
860860
templateX = leftAux + leftMargin;
861861
templateY = this.pageSize.getUpperRightY() - bottomAux - topMargin - bottomMargin;
862862
templateCreated = true;
863863
}
864-
return;
864+
sTxt = String.valueOf(this.page);
865865
}
866866

867867
float textBlockWidth = rightAux - leftAux;
@@ -1271,20 +1271,6 @@ public void GxEndDocument() {
12711271
document.addPage(new PDPage(this.pageSize));
12721272
pages++;
12731273
}
1274-
if (templateCreated) {
1275-
for (PDPage page : document.getPages()){
1276-
try (PDPageContentStream templatePainter = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND,true, true)) {
1277-
templatePainter.beginText();
1278-
templatePainter.setFont(templateFont, templateFontSize);
1279-
templatePainter.setNonStrokingColor(templateColorFill);
1280-
templatePainter.newLineAtOffset(templateX, templateY);
1281-
templatePainter.showText(String.valueOf(pages));
1282-
templatePainter.endText();
1283-
} catch (IOException e){
1284-
log.error("GxEndDocument: failed to apply template" , e);;
1285-
}
1286-
}
1287-
}
12881274
int copies = 1;
12891275
try {
12901276
copies = Integer.parseInt(printerSettings.getProperty(form, Const.COPIES));

0 commit comments

Comments
 (0)