Skip to content

Commit 91e04ce

Browse files
author
Open Lowcode SAS
committed
Close #63
1 parent 804a0b6 commit 91e04ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/org/openlowcode/tools/pdf/DocumentTableOfContent.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
package org.openlowcode.tools.pdf;
1212

13+
import java.awt.Color;
1314
import java.io.IOException;
1415
import java.util.ArrayList;
1516

@@ -40,7 +41,9 @@ public void print(PDFPageBand pageband, PDFPage currentpage, float mmfromtopfors
4041
float rightinmm) throws IOException {
4142
for (int i = 0; i < content.size(); i++) {
4243
PagedLabel label = content.get(i);
43-
currentpage.drawSimpleTextAt(false, leftinmm, mmfromtopforsection, i, 0, label.getLabel());
44+
float textsize = PDFPage.getTextSize(new String[] {label.getLabel()}, PDFPage.TEXTTYPE_PLAIN);
45+
currentpage.drawLine(false, leftinmm+10+textsize+ label.getOriginalOffset() / 3,mmfromtopforsection+i*PDFPage.LINE_SPACING_NORMAL_TEXT+PDFPage.PARAGRAPH_MARGIN_VERTICAL,rightinmm-25,mmfromtopforsection+i*PDFPage.LINE_SPACING_NORMAL_TEXT+PDFPage.PARAGRAPH_MARGIN_VERTICAL,Color.GRAY);
46+
currentpage.drawSimpleTextAt(false, leftinmm+ label.getOriginalOffset() / 3, mmfromtopforsection, i, 0, label.getLabel());
4447
currentpage.drawCalculatedText(rightinmm, mmfromtopforsection, i, 0, false,
4548
() -> "" + label.getPageNumber());
4649
}
@@ -69,10 +72,12 @@ public PartialPrintFeedback printPartial(PDFPageBand pageband, float spaceleft,
6972
}
7073
for (int i = 0; i < linestoprint; i++) {
7174
PagedLabel label = content.get(i + currentindex);
72-
currentpage.drawSimpleTextAt(false, leftinmm + 15 + label.getOriginalOffset() / 3, mmfromtopforsection, i,
75+
float textsize = PDFPage.getTextSize(new String[] {label.getLabel()}, PDFPage.TEXTTYPE_PLAIN);
76+
currentpage.drawSimpleTextAt(false, leftinmm+ label.getOriginalOffset() / 3, mmfromtopforsection, i,
7377
0, label.getLabel());
74-
currentpage.drawCalculatedText(leftinmm + 15, mmfromtopforsection, i, 0, false,
78+
currentpage.drawCalculatedText(rightinmm-20, mmfromtopforsection, i, 0, false,
7579
() -> "" + label.getPageNumber());
80+
currentpage.drawLine(false, leftinmm+5+PDFPage.PARAGRAPH_MARGIN_HORIZONTAL/PDFPage.MM_TO_POINT+textsize+ label.getOriginalOffset() / 3,mmfromtopforsection+PDFPage.getTextVerticalOffsetInMM(i,0),rightinmm-25,mmfromtopforsection+PDFPage.getTextVerticalOffsetInMM(i,0),Color.GRAY);
7681
}
7782
currentindex = currentindex + linestoprint;
7883
return new PartialPrintFeedback(

0 commit comments

Comments
 (0)